[V2.x OGE tutorial 18] entity-related

Source: Internet
Author: User

 

One of the ways to make game design more flexible is to use the entity/component design method, which treats all objects as entity objects rather than designing a class for each object. Everything drawn on the screen is an entity (scene, layer, text, ry, line, Genie, etc ). These object objects will be dynamically set attributes (or components) later to make corresponding changes.

 

1. Update related

The engine updates the game process in the form of data synchronization by the logic thread and GL thread. The entity updates the onupdate and ondraw methods. In the onupdate method, ignoreupdate is used to determine whether to update the logic (including attribute parameters, such as coordinates), whether the drawing in the ondraw method is determined based on visible.

 

2. Touch-related

Entity includes the ontouch and onareatouched methods, which distribute events from the engine, process them in ontouch, and pass them to onareatouched. Therefore, you must set the parameter when rewriting onareatouched. entity. setignoretouch (false). Otherwise, the ontouch filter will cause the onareatouched to have no response. The onareatouched return value indicates whether the event has been processed.

 

3. Coordinate Transformation

Because entity has the relative concepts of parent and child, the corresponding coordinate also has a relative statement, and the transformation of coordinates is included.

Example:

Convertlocaltoscenecoordinates coordinates of the current coordinate conversion entity in scene

...

 

 

 


[V2.x OGE tutorial 18] entity-related

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.