java.lang.Object
   ↳ org.andengine.engine.Engine
Known Direct Subclasses

Class Overview

(c) 2010 Nicolas Gramlich (c) 2011 Zynga Inc.

Summary

Nested Classes
class Engine.EngineDestroyedException  
class Engine.EngineLock  
class Engine.UpdateThread  
[Expand]
Inherited Constants
From interface org.andengine.util.time.TimeConstants
Fields
protected final Camera mCamera
protected Scene mScene
protected int mSurfaceHeight
protected int mSurfaceWidth
Public Constructors
Engine(EngineOptions pEngineOptions)
Public Methods
void clearDrawHandlers()
void clearUpdateHandlers()
boolean disableAccelerationSensor(Context pContext)
void disableLocationSensor(Context pContext)
boolean disableOrientationSensor(Context pContext)
boolean enableAccelerationSensor(Context pContext, IAccelerationListener pAccelerationListener, AccelerationSensorOptions pAccelerationSensorOptions)
boolean enableAccelerationSensor(Context pContext, IAccelerationListener pAccelerationListener)
void enableLocationSensor(Context pContext, ILocationListener pLocationListener, LocationSensorOptions pLocationSensorOptions)
boolean enableOrientationSensor(Context pContext, IOrientationListener pOrientationListener)
boolean enableOrientationSensor(Context pContext, IOrientationListener pOrientationListener, OrientationSensorOptions pOrientationSensorOptions)
boolean enableVibrator(Context pContext)
AccelerationData getAccelerationData()
Camera getCamera()
Engine.EngineLock getEngineLock()
The Engine.EngineLock can be used to lock()/unlock() on, to ensure the code in between runs mutually exclusive to the Engine.UpdateThread and the GLEngine.UpdateThread.
EngineOptions getEngineOptions()
FontManager getFontManager()
MusicManager getMusicManager()
OrientationData getOrientationData()
Scene getScene()
float getSecondsElapsedTotal()
ShaderProgramManager getShaderProgramManager()
SoundManager getSoundManager()
int getSurfaceHeight()
int getSurfaceWidth()
TextureManager getTextureManager()
ITouchController getTouchController()
VertexBufferObjectManager getVertexBufferObjectManager()
synchronized boolean isRunning()
void onAccuracyChanged(Sensor pSensor, int pAccuracy)
void onDestroy()
void onDrawFrame(GLState pGLState)
void onLocationChanged(Location pLocation)
void onProviderDisabled(String pProvider)
void onProviderEnabled(String pProvider)
void onReloadResources()
void onSensorChanged(SensorEvent pEvent)
void onStatusChanged(String pProvider, int pStatus, Bundle pExtras)
boolean onTouch(View pView, MotionEvent pSurfaceMotionEvent)
boolean onTouchEvent(TouchEvent pSurfaceTouchEvent)
void onUpdate(long pNanosecondsElapsed)
void registerDrawHandler(IDrawHandler pDrawHandler)
void registerUpdateHandler(IUpdateHandler pUpdateHandler)
void runOnUpdateThread(Runnable pRunnable, boolean pOnlyWhenEngineRunning)
This method is useful when you want to execute code on the Engine.UpdateThread, even though the Engine is paused.
void runOnUpdateThread(Runnable pRunnable)
void runSafely(Runnable pRunnable)
void setScene(Scene pScene)
void setSurfaceSize(int pSurfaceWidth, int pSurfaceHeight)
void setTouchController(ITouchController pTouchController)
synchronized void start()
synchronized void stop()
void unregisterDrawHandler(IDrawHandler pDrawHandler)
void unregisterUpdateHandler(IUpdateHandler pUpdateHandler)
void vibrate(long pMilliseconds)
void vibrate(long[] pPattern, int pRepeat)
Protected Methods
void convertSceneToSurfaceTouchEvent(Camera pCamera, TouchEvent pSurfaceTouchEvent)
void convertSurfaceToSceneTouchEvent(Camera pCamera, TouchEvent pSurfaceTouchEvent)
Camera getCameraFromSurfaceTouchEvent(TouchEvent pTouchEvent)
Scene getSceneFromSurfaceTouchEvent(TouchEvent pTouchEvent)
void onDrawScene(GLState pGLState, Camera pCamera)
boolean onTouchHUD(Camera pCamera, TouchEvent pSceneTouchEvent)
boolean onTouchScene(Scene pScene, TouchEvent pSceneTouchEvent)
void onUpdateCameraSurface()
void onUpdateDrawHandlers(GLState pGLState, Camera pCamera)
void onUpdateScene(float pSecondsElapsed)
void onUpdateUpdateHandlers(float pSecondsElapsed)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.hardware.SensorEventListener
From interface android.location.LocationListener
From interface android.view.View.OnTouchListener
From interface org.andengine.input.touch.controller.ITouchController.ITouchEventCallback

Fields

protected final Camera mCamera

protected Scene mScene

protected int mSurfaceHeight

protected int mSurfaceWidth

Public Constructors

public Engine (EngineOptions pEngineOptions)

Public Methods

public void clearDrawHandlers ()

public void clearUpdateHandlers ()

public boolean disableAccelerationSensor (Context pContext)

Returns
  • true when the sensor was successfully disabled, false otherwise.

public void disableLocationSensor (Context pContext)

public boolean disableOrientationSensor (Context pContext)

Returns
  • true when the sensor was successfully disabled, false otherwise.

public boolean enableAccelerationSensor (Context pContext, IAccelerationListener pAccelerationListener, AccelerationSensorOptions pAccelerationSensorOptions)

Returns
  • true when the sensor was successfully enabled, false otherwise.

public boolean enableAccelerationSensor (Context pContext, IAccelerationListener pAccelerationListener)

See Also
  • {@link Engine#enableAccelerationSensor(Context, IAccelerationListener, AccelerationSensorOptions)}

public void enableLocationSensor (Context pContext, ILocationListener pLocationListener, LocationSensorOptions pLocationSensorOptions)

public boolean enableOrientationSensor (Context pContext, IOrientationListener pOrientationListener)

See Also
  • {@link Engine#enableOrientationSensor(Context, IOrientationListener, OrientationSensorOptions)}

public boolean enableOrientationSensor (Context pContext, IOrientationListener pOrientationListener, OrientationSensorOptions pOrientationSensorOptions)

Returns
  • true when the sensor was successfully enabled, false otherwise.

public boolean enableVibrator (Context pContext)

public AccelerationData getAccelerationData ()

public Camera getCamera ()

public Engine.EngineLock getEngineLock ()

The Engine.EngineLock can be used to lock()/unlock() on, to ensure the code in between runs mutually exclusive to the Engine.UpdateThread and the GLEngine.UpdateThread. When the caller already is on the Engine.UpdateThread or the GL-Engine.UpdateThread, that code is executed immediately.

Returns

public EngineOptions getEngineOptions ()

public FontManager getFontManager ()

public MusicManager getMusicManager ()

public OrientationData getOrientationData ()

public Scene getScene ()

public float getSecondsElapsedTotal ()

public ShaderProgramManager getShaderProgramManager ()

public SoundManager getSoundManager ()

public int getSurfaceHeight ()

public int getSurfaceWidth ()

public TextureManager getTextureManager ()

public ITouchController getTouchController ()

public VertexBufferObjectManager getVertexBufferObjectManager ()

public synchronized boolean isRunning ()

public void onAccuracyChanged (Sensor pSensor, int pAccuracy)

public void onDestroy ()

public void onDrawFrame (GLState pGLState)

public void onLocationChanged (Location pLocation)

public void onProviderDisabled (String pProvider)

public void onProviderEnabled (String pProvider)

public void onReloadResources ()

public void onSensorChanged (SensorEvent pEvent)

public void onStatusChanged (String pProvider, int pStatus, Bundle pExtras)

public boolean onTouch (View pView, MotionEvent pSurfaceMotionEvent)

public boolean onTouchEvent (TouchEvent pSurfaceTouchEvent)

public void onUpdate (long pNanosecondsElapsed)

public void registerDrawHandler (IDrawHandler pDrawHandler)

public void registerUpdateHandler (IUpdateHandler pUpdateHandler)

public void runOnUpdateThread (Runnable pRunnable, boolean pOnlyWhenEngineRunning)

This method is useful when you want to execute code on the Engine.UpdateThread, even though the Engine is paused.

Parameters
pRunnable the Runnable to be run on the Engine.UpdateThread.
pOnlyWhenEngineRunning if true, the execution of the Runnable will be delayed until the next time onUpdateUpdateHandlers(float) is picked up, which is when isRunning() is true. if false, the execution of the Runnable will happen as soon as possible on the Engine.UpdateThread, no matter what isRunning() is.

public void runOnUpdateThread (Runnable pRunnable)

public void runSafely (Runnable pRunnable)

Parameters
pRunnable the Runnable to run mutually exclusive to the Engine.UpdateThread and the GL-Engine.UpdateThread. When the caller already is on the Engine.UpdateThread or the GL-Engine.UpdateThread, the Runnable is executed immediately.
See Also
  • {@link Engine#getEngineLock()} to manually {@link EngineLock#lock()}/{@link EngineLock#unlock()} on, while avoiding creating a {@link Runnable}.

public void setScene (Scene pScene)

public void setSurfaceSize (int pSurfaceWidth, int pSurfaceHeight)

public void setTouchController (ITouchController pTouchController)

public synchronized void start ()

public synchronized void stop ()

public void unregisterDrawHandler (IDrawHandler pDrawHandler)

public void unregisterUpdateHandler (IUpdateHandler pUpdateHandler)

public void vibrate (long pMilliseconds)

public void vibrate (long[] pPattern, int pRepeat)

Protected Methods

protected void convertSceneToSurfaceTouchEvent (Camera pCamera, TouchEvent pSurfaceTouchEvent)

protected void convertSurfaceToSceneTouchEvent (Camera pCamera, TouchEvent pSurfaceTouchEvent)

protected Camera getCameraFromSurfaceTouchEvent (TouchEvent pTouchEvent)

protected Scene getSceneFromSurfaceTouchEvent (TouchEvent pTouchEvent)

protected void onDrawScene (GLState pGLState, Camera pCamera)

protected boolean onTouchHUD (Camera pCamera, TouchEvent pSceneTouchEvent)

protected boolean onTouchScene (Scene pScene, TouchEvent pSceneTouchEvent)

protected void onUpdateCameraSurface ()

protected void onUpdateDrawHandlers (GLState pGLState, Camera pCamera)

protected void onUpdateScene (float pSecondsElapsed)

protected void onUpdateUpdateHandlers (float pSecondsElapsed)