de.unifreiburg.twodeedoo.model
Class SimpleActivity

java.lang.Object
  extended by de.unifreiburg.twodeedoo.model.SimpleActivity
All Implemented Interfaces:
IActivity, IKeyHandler, ISchedulable

public class SimpleActivity
extends java.lang.Object
implements IActivity

Simple Composite of IActors.

Author:
konrad

Field Summary
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.ISchedulable
NULL_OBJECT
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.IKeyHandler
NULL_OBJECT
 
Constructor Summary
SimpleActivity(IScene scene, IGameController gameController)
          Create instance
 
Method Summary
 void addActor(IActor actor)
          Add an actor, becoming its container.
 IScene getScene()
          Getter for scene.
 void keyPressed(int keyCode)
          Dispatch to the actor which likes that key
 void keyReleased(int keyCode)
          Dispatch to the actor which likes that key
 boolean run(int elapsedTimeMillis)
          Let all the contained actors run.
 void setScene(IScene scene)
          Setter for scene.
 void switchToActivity(IActivity otherActivity)
          Tell the IGameController that a different IActivity should be run.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleActivity

public SimpleActivity(IScene scene,
                      IGameController gameController)
Create instance

Parameters:
scene - the scene for new puppets
Method Detail

run

public boolean run(int elapsedTimeMillis)
Let all the contained actors run. Follow their wishes for removal.

Specified by:
run in interface ISchedulable
Parameters:
elapsedTimeMillis - elapsed time since last run in ms
Returns:
true: this should be run again, false: finished, don't call again.

addActor

public void addActor(IActor actor)
Add an actor, becoming its container.

Specified by:
addActor in interface IActivity
Parameters:
actor - an actor

setScene

public void setScene(IScene scene)
Setter for scene.

Parameters:
scene - a scene, non-null.

getScene

public IScene getScene()
Getter for scene.

Returns:
the scene.

keyPressed

public void keyPressed(int keyCode)
Dispatch to the actor which likes that key

Specified by:
keyPressed in interface IKeyHandler
Parameters:
keyCode - a code from KeyEvent, e.g. KeyEvent.VK_LEFT

keyReleased

public void keyReleased(int keyCode)
Dispatch to the actor which likes that key

Specified by:
keyReleased in interface IKeyHandler
Parameters:
keyCode - a code from KeyEvent, e.g. KeyEvent.VK_LEFT

switchToActivity

public void switchToActivity(IActivity otherActivity)
Tell the IGameController that a different IActivity should be run.

Specified by:
switchToActivity in interface IActivity
Parameters:
otherActivity - another IActivity.