Setting entity properties based on the time passed
Consistency across devices is one of the more important aspects of mobile game development. Players expect a game to scale properly for their device's screen, but another important, and often overlooked, aspect of game development is basing movements and animations on time instead of engine updates. In this recipe, we will set an entity's property using an update handler.
Getting ready...
Create a new class named SettingEntityPropertiesBasedOnTimePassedActivity
that extends BaseGameActivity
. We will use this class to demonstrate how to set entity properties in time with an update handler.
How to do it...
Follow these steps to see how we can set an entity's property based on how much time has passed in an udate:
Define the following variables in the activity:
public static int cameraWidth = 800; public static int cameraHeight = 480; public Scene mScene; public Rectangle spinningRect;
Then, place these overridden methods in the class:
@Override...