[V2.x OGE tutorial 17] Transaction Processing

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.