Alarms - Gornova/MarteEngine GitHub Wiki
Now you should know everything about Tweens, so you can explore a useful feature of MarteEngine: Alarms.
In most of games you want to build, sometimes you need to perform some action after some times, for example update player position: you can develop by yourself a system to keep track of time passing or use Alarms.
Alarm is not an Entity or World, is a general class that helps you to perform some actions.. but you can define as many alarms as you like! Let's start with a basic AlarmEntity:
public class AlarmEntity extends Entity { private static final String MOVE_RIGHT = "move right"; public AlarmEntity(float x, float y, Image image) { super(x, y, image); // now add an Alarm: we define an alarm to be triggered every 2 seconds setAlarm(MOVE_RIGHT, 2, false, true); } @Override public void alarmTriggered(String name) { // this method is called for every triggered method we can define on this entity if (name.equalsIgnoreCase(MOVE_RIGHT)){ // in this case we just move right x = x + 2; } } }
It's possible to see that to create a new Alarm we define few properties and add to Entity itself, because MarteEngine take care to update internal logic of alarms and call alarmTriggered method when alarms is triggered, so you can override this method and catch particular alarm triggered.
Now using alarm you can Rotate and scale your entities!
MarteEngine version 0.2