org.mt4j.sceneManagement
Class AbstractScene

java.lang.Object
  extended by org.mt4j.sceneManagement.AbstractScene
All Implemented Interfaces:
Iscene
Direct Known Subclasses:
AbstractTransition, AirHockeyScene, DrawSurfaceScene, FiducialScene, FlickrScene, FluidSimulationScene, HelloWorldScene, MainDrawingScene, MapsScene, Models3DScene, MTGesturesExampleScene, MTShellScene, PhysicsScene, Scene1, Scene2, Scene3, Space3DScene, SVGScene, TouchTailScene

public abstract class AbstractScene
extends java.lang.Object

    
implements Iscene

    

A class representing a scene in a program or game. It has its own main canvas and global input processors.

Author:
Christopher Ruff

Constructor Summary
AbstractScene(MTApplication mtApplication, java.lang.String name)
          The Constructor.
 
Method Summary
protected  void clear(processing.core.PGraphics graphics)
           
 boolean destroy()
          Destroys the scene.
 void drawAndUpdate(processing.core.PGraphics graphics, long timeDelta)
          Draw and update.
 MTCanvas getCanvas()
          Gets the main canvas.
 MTColor getClearColor()
          Gets the clear color.
 AbstractGlobalInputProcessor[] getGlobalInputProcessors()
          Gets the global input processors.
 MTApplication getMTApplication()
          Gets the MT application instance.
 java.lang.String getName()
          Gets the name of the scene.
 Icamera getSceneCam()
          Gets the scene cam.
 ITransition getTransition()
          Gets the transition.
abstract  void init()
          Is invoked on a scene just before it is set to be the currently active scene.
 boolean isClear()
          Checks if the scene is being cleared each frame.
protected  void registerDefaultGlobalInputProcessors()
          Register default global input processors.
 void registerGlobalInputProcessor(AbstractGlobalInputProcessor processor)
          Registers a global input processor with the current scene.
 void registerPreDrawAction(IPreDrawAction action)
          Registers an action to be processed before the next frame in the main drawing thread.
 void setClear(boolean clearScreen)
          Sets the scene to be cleared each frame or not.
 void setClearColor(MTColor clearColor)
          Sets the clear color to use when the screen is cleared each frame before drawing.
 void setName(java.lang.String name)
          Sets the name.
 void setSceneCam(Icamera sceneCam)
          Sets the scene cam.
 void setTransition(ITransition transition)
          Sets the transition effect to use when a scene change takes place from this scene to another scene.
abstract  void shutDown()
          Gets called on the current scene just before the current scene gets changed to another scene.
 void unregisterGlobalInputProcessor(AbstractGlobalInputProcessor processor)
          Unregisters a global input processor.
 void unregisterPreDrawAction(IPreDrawAction action)
          Unregisters an PreDrawAction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractScene

public AbstractScene(MTApplication mtApplication,
                     java.lang.String name)
The Constructor.

Parameters:
mtApplication - the mt application
name - the name
Method Detail

registerDefaultGlobalInputProcessors

protected void registerDefaultGlobalInputProcessors()
Register default global input processors. Can be overridden for custom behaviour.


init

public abstract void init()
Is invoked on a scene just before it is set to be the currently active scene.

Specified by:
init in interface Iscene

drawAndUpdate

public void drawAndUpdate(processing.core.PGraphics graphics,
                          long timeDelta)
Description copied from interface: Iscene
Draw and update.

Specified by:
drawAndUpdate in interface Iscene
timeDelta - the time delta

clear

protected void clear(processing.core.PGraphics graphics)

shutDown

public abstract void shutDown()
Gets called on the current scene just before the current scene gets changed to another scene.

Specified by:
shutDown in interface Iscene

setClearColor

public void setClearColor(MTColor clearColor)
Sets the clear color to use when the screen is cleared each frame before drawing.

Parameters:
clearColor - the new clear color

getClearColor

public MTColor getClearColor()
Gets the clear color.

Returns:
the clear color

setClear

public void setClear(boolean clearScreen)
Sets the scene to be cleared each frame or not.

Parameters:
clearScreen - the new clear

isClear

public boolean isClear()
Checks if the scene is being cleared each frame.

Returns:
true, if is clear

getCanvas

public MTCanvas getCanvas()
Description copied from interface: Iscene
Gets the main canvas.

Specified by:
getCanvas in interface Iscene
Returns:
the main canvas

getSceneCam

public Icamera getSceneCam()
Description copied from interface: Iscene
Gets the scene cam.

Specified by:
getSceneCam in interface Iscene
Returns:
the scene cam

setSceneCam

public void setSceneCam(Icamera sceneCam)
Sets the scene cam. This is the camera which gets attached to the scene's canvas.

Parameters:
sceneCam - the scene cam

getMTApplication

public MTApplication getMTApplication()
Gets the MT application instance.

Returns:
the mT application

getName

public java.lang.String getName()
Description copied from interface: Iscene
Gets the name of the scene.

Specified by:
getName in interface Iscene
Returns:
the name

setName

public void setName(java.lang.String name)
Sets the name.

Parameters:
name - the name

registerGlobalInputProcessor

public void registerGlobalInputProcessor(AbstractGlobalInputProcessor processor)
Registers a global input processor with the current scene. The global input processor will then recieve input events from all input sources as long as this scene is active. We can then add our own listeners to the global input processor.

Parameters:
processor - the processor

unregisterGlobalInputProcessor

public void unregisterGlobalInputProcessor(AbstractGlobalInputProcessor processor)
Unregisters a global input processor.

Parameters:
processor - the processor

getGlobalInputProcessors

public AbstractGlobalInputProcessor[] getGlobalInputProcessors()
Gets the global input processors.

Returns:
the global input processors

registerPreDrawAction

public void registerPreDrawAction(IPreDrawAction action)
Registers an action to be processed before the next frame in the main drawing thread.

Specified by:
registerPreDrawAction in interface Iscene
Parameters:
action - the action

unregisterPreDrawAction

public void unregisterPreDrawAction(IPreDrawAction action)
Unregisters an PreDrawAction.

Parameters:
action - the action

getTransition

public ITransition getTransition()
Description copied from interface: Iscene
Gets the transition.

Specified by:
getTransition in interface Iscene
Returns:
the transition

setTransition

public void setTransition(ITransition transition)
Sets the transition effect to use when a scene change takes place from this scene to another scene.

Parameters:
transition - the new transition

destroy

public boolean destroy()
Destroys the scene. Call this if the scene definitely isnt going to be used anymore. The scene can only be destroyed if it was added to the application and it isnt the currently active scene. - Destroys the scene's canvas - removes the global input listeners from the input sources

Specified by:
destroy in interface Iscene
Returns:
true, if successful