android.gameengine.icadroids.alarms
Class Alarm

java.lang.Object
  extended by android.gameengine.icadroids.alarms.Alarm

public class Alarm
extends java.lang.Object

Set alarms who will trigger after a specified time. Time is measured in cycles of the game loop. Alarms will trigger a method (specified in IAlarm) after the given time To make use of alarms, create a alarm object. This alarm will start immediately.

Author:
Bas van der Zandt

Constructor Summary
Alarm(int id, int Time, IAlarm alarmedObject)
          Create a new Alarm with the given time.
 
Method Summary
 void pauseAlarm()
          Pause the alarm, it will stop ticking.
 void restartAlarm()
          Reset the clock to zero and start the alarm
 void setTime(int time)
          Change the time of the alarm.
 void startAlarm()
          Restart an alarm without resetting the clock.
 boolean targets(IAlarm ia)
          Test if this alarm targets the specified Object (that must implement IAlarm)
 void update()
          Update will be triggered by the GameEngine every update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Alarm

public Alarm(int id,
             int Time,
             IAlarm alarmedObject)
Create a new Alarm with the given time. The alarm will start immediately.

Parameters:
id - ID to identify the alarm
Time - How many updates must occur before the alarm goes off
alarmedObject - The object that must be informed when the alarm goes off
Method Detail

update

public final void update()
Update will be triggered by the GameEngine every update. The update does the counting, so don't call this update yourself!


pauseAlarm

public final void pauseAlarm()
Pause the alarm, it will stop ticking. You can restart the alarm with startAlarm().


startAlarm

public final void startAlarm()
Restart an alarm without resetting the clock. Use this method when an alarm has been paused.


restartAlarm

public final void restartAlarm()
Reset the clock to zero and start the alarm


setTime

public final void setTime(int time)
Change the time of the alarm. This will not influence the clock, when an alarm is already ticking. If you set a time that the counter has already passed, the alarm will go off immediately.

Parameters:
time - The time

targets

public boolean targets(IAlarm ia)
Test if this alarm targets the specified Object (that must implement IAlarm)

Parameters:
ia - The object you want want to test
Returns:
true if this Alarm is set for the specified object