Overriding the onManagedUpdate method
Overriding an Entity
object's onManagedUpdate()
method can be extremely useful in all types of situations. By doing so, we can allow our entities to execute code every time the entity is updated through the update thread, occuring many times per second unless the entity is set to ignore updates. There are so many possibilities including animating our entity, checking for collisions, producing timed events, and much more. Using our Entity
objects's onManagedUpdate()
method also saves us from having to create and register new timer handlers for time-based events for a single entity.
Getting ready…
This recipe requires basic knowledge of the Entity
object in AndEngine. Please read through the entire recipe, Understanding AndEngine entities given in this chapter, then create a new empty AndEngine project with a BaseGameActivity
class and refer to the class named OverridingUpdates
in the code bundle.
How to do it…
In this recipe, we are creating two Rectangle...