The game code often has some logic to process, so the OGE engine adds an iupdatehandler class. The iupdatehandler class is one of the frequently used components in the OGE engine. It is an interface and has two functions, onupdate and reset, waiting for implementation, almost all OGE engine applications are bound to see it. It is also one of the main ways for ogengine open-source engines to add specific businesses to the game business thread.
1. Create iupdatehandler
Private iupdatehandler handler = new iupdatehandler (){
@ Override
Public void reset (){
// Todo auto-generated method stub
}
@ Override
Public void onupdate (float synchronized condselapsed ){
// Todo auto-generated method stub
}
};
2. Update and reset Methods
In the update method, mongocondselapsed is the last time (in seconds) after the last logical thread runs. After iupdatehandler registers, the update method is executed each time.
The reset method is not called in the engine.
3. Register iupdatehandler
// Register a handler
Public void registerupdatehandler (final iupdatehandler pupdatehandler)
After registration, iupdatehandler will be added to the list, and the logic thread will loop through these lists to update each time.
4. Register iupdatehandler
Public void unregisterupdatehandler (final iupdatehandler pupdatehandler)
After Anti-Registration, iupdatehandler will remove it from the list.
5. timerhandler
Timerhandler is a subclass of iupdatehandler and regularly executes the update method.
/**
* @ Param ptimerseconds interval of each response (must be greater than 0)
* @ Param pautoreset whether repeated execution is performed
* @ Param ptimercallback timer triggers callback
*/
Public timerhandler (final float ptimerseconds, final Boolean pautoreset, final itimercallback ptimercallback)
[V2.x OGE tutorial 17] Transaction Processing