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