public class Engine extends java.lang.Object implements android.hardware.SensorEventListener, android.view.View.OnTouchListener, ITouchEventCallback, android.location.LocationListener
| Modifier and Type | Class and Description |
|---|---|
class |
Engine.EngineDestroyedException |
static class |
Engine.EngineLock |
static class |
Engine.UpdateThread |
| Modifier and Type | Field and Description |
|---|---|
protected Camera |
mCamera |
protected Scene |
mScene |
protected int |
mSurfaceHeight |
protected int |
mSurfaceWidth |
| Constructor and Description |
|---|
Engine(EngineOptions pEngineOptions) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearDrawHandlers() |
void |
clearUpdateHandlers() |
protected void |
convertSceneToSurfaceTouchEvent(Camera pCamera,
TouchEvent pSurfaceTouchEvent) |
protected void |
convertSurfaceToSceneTouchEvent(Camera pCamera,
TouchEvent pSurfaceTouchEvent) |
boolean |
disableAccelerationSensor(android.content.Context pContext) |
void |
disableLocationSensor(android.content.Context pContext) |
boolean |
disableOrientationSensor(android.content.Context pContext) |
boolean |
enableAccelerationSensor(android.content.Context pContext,
IAccelerationListener pAccelerationListener) |
boolean |
enableAccelerationSensor(android.content.Context pContext,
IAccelerationListener pAccelerationListener,
AccelerationSensorOptions pAccelerationSensorOptions) |
void |
enableLocationSensor(android.content.Context pContext,
ILocationListener pLocationListener,
LocationSensorOptions pLocationSensorOptions) |
boolean |
enableOrientationSensor(android.content.Context pContext,
IOrientationListener pOrientationListener) |
boolean |
enableOrientationSensor(android.content.Context pContext,
IOrientationListener pOrientationListener,
OrientationSensorOptions pOrientationSensorOptions) |
boolean |
enableVibrator(android.content.Context pContext) |
AccelerationData |
getAccelerationData() |
Camera |
getCamera() |
protected Camera |
getCameraFromSurfaceTouchEvent(TouchEvent pTouchEvent) |
Engine.EngineLock |
getEngineLock()
The
Engine.EngineLock can be used to ReentrantLock.lock()/ReentrantLock.unlock() on, to ensure the code in between runs mutually exclusive to the Engine.UpdateThread and the GLThread. |
EngineOptions |
getEngineOptions() |
FontManager |
getFontManager() |
MusicManager |
getMusicManager() |
OrientationData |
getOrientationData() |
Scene |
getScene() |
protected Scene |
getSceneFromSurfaceTouchEvent(TouchEvent pTouchEvent) |
float |
getSecondsElapsedTotal() |
ShaderProgramManager |
getShaderProgramManager() |
SoundManager |
getSoundManager() |
int |
getSurfaceHeight() |
int |
getSurfaceWidth() |
TextureManager |
getTextureManager() |
ITouchController |
getTouchController() |
VertexBufferObjectManager |
getVertexBufferObjectManager() |
boolean |
isRunning() |
void |
onAccuracyChanged(android.hardware.Sensor pSensor,
int pAccuracy) |
void |
onDestroy() |
void |
onDrawFrame(GLState pGLState) |
protected void |
onDrawScene(GLState pGLState,
Camera pCamera) |
void |
onLocationChanged(android.location.Location pLocation) |
void |
onProviderDisabled(java.lang.String pProvider) |
void |
onProviderEnabled(java.lang.String pProvider) |
void |
onReloadResources() |
void |
onSensorChanged(android.hardware.SensorEvent pEvent) |
void |
onStatusChanged(java.lang.String pProvider,
int pStatus,
android.os.Bundle pExtras) |
boolean |
onTouch(android.view.View pView,
android.view.MotionEvent pSurfaceMotionEvent) |
boolean |
onTouchEvent(TouchEvent pSurfaceTouchEvent) |
protected boolean |
onTouchHUD(Camera pCamera,
TouchEvent pSceneTouchEvent) |
protected boolean |
onTouchScene(Scene pScene,
TouchEvent pSceneTouchEvent) |
void |
onUpdate(long pNanosecondsElapsed) |
protected void |
onUpdateCameraSurface() |
protected void |
onUpdateDrawHandlers(GLState pGLState,
Camera pCamera) |
protected void |
onUpdateScene(float pSecondsElapsed) |
protected void |
onUpdateUpdateHandlers(float pSecondsElapsed) |
void |
registerDrawHandler(IDrawHandler pDrawHandler) |
void |
registerUpdateHandler(IUpdateHandler pUpdateHandler) |
void |
runOnUpdateThread(java.lang.Runnable pRunnable) |
void |
runOnUpdateThread(java.lang.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 |
runSafely(java.lang.Runnable pRunnable) |
void |
setScene(Scene pScene) |
void |
setSurfaceSize(int pSurfaceWidth,
int pSurfaceHeight) |
void |
setTouchController(ITouchController pTouchController) |
void |
start() |
void |
startUpdateThread() |
void |
stop() |
void |
unregisterDrawHandler(IDrawHandler pDrawHandler) |
void |
unregisterUpdateHandler(IUpdateHandler pUpdateHandler) |
void |
vibrate(long pMilliseconds) |
void |
vibrate(long[] pPattern,
int pRepeat) |
protected final Camera mCamera
protected Scene mScene
protected int mSurfaceWidth
protected int mSurfaceHeight
public Engine(EngineOptions pEngineOptions)
public void startUpdateThread()
throws java.lang.IllegalThreadStateException
java.lang.IllegalThreadStateExceptionpublic boolean isRunning()
public void start()
public void stop()
public Engine.EngineLock getEngineLock()
Engine.EngineLock can be used to ReentrantLock.lock()/ReentrantLock.unlock() on, to ensure the code in between runs mutually exclusive to the Engine.UpdateThread and the GLThread.
When the caller already is on the Engine.UpdateThread or the GL-Thread, that code is executed immediately.Engine.EngineLock the Engine locks on to ensure mutually exclusivity to the Engine.UpdateThread and the GLThread.public Scene getScene()
public void setScene(Scene pScene)
public EngineOptions getEngineOptions()
public Camera getCamera()
public float getSecondsElapsedTotal()
public void setSurfaceSize(int pSurfaceWidth,
int pSurfaceHeight)
protected void onUpdateCameraSurface()
public int getSurfaceWidth()
public int getSurfaceHeight()
public ITouchController getTouchController()
public void setTouchController(ITouchController pTouchController)
public AccelerationData getAccelerationData()
public OrientationData getOrientationData()
public VertexBufferObjectManager getVertexBufferObjectManager()
public TextureManager getTextureManager()
public FontManager getFontManager()
public ShaderProgramManager getShaderProgramManager()
public SoundManager getSoundManager() throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic MusicManager getMusicManager() throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void registerUpdateHandler(IUpdateHandler pUpdateHandler)
public void unregisterUpdateHandler(IUpdateHandler pUpdateHandler)
public void clearUpdateHandlers()
public void registerDrawHandler(IDrawHandler pDrawHandler)
public void unregisterDrawHandler(IDrawHandler pDrawHandler)
public void clearDrawHandlers()
public void onAccuracyChanged(android.hardware.Sensor pSensor,
int pAccuracy)
onAccuracyChanged in interface android.hardware.SensorEventListenerpublic void onSensorChanged(android.hardware.SensorEvent pEvent)
onSensorChanged in interface android.hardware.SensorEventListenerpublic void onLocationChanged(android.location.Location pLocation)
onLocationChanged in interface android.location.LocationListenerpublic void onProviderDisabled(java.lang.String pProvider)
onProviderDisabled in interface android.location.LocationListenerpublic void onProviderEnabled(java.lang.String pProvider)
onProviderEnabled in interface android.location.LocationListenerpublic void onStatusChanged(java.lang.String pProvider,
int pStatus,
android.os.Bundle pExtras)
onStatusChanged in interface android.location.LocationListenerpublic boolean onTouch(android.view.View pView,
android.view.MotionEvent pSurfaceMotionEvent)
onTouch in interface android.view.View.OnTouchListenerpublic boolean onTouchEvent(TouchEvent pSurfaceTouchEvent)
onTouchEvent in interface ITouchEventCallbackprotected boolean onTouchHUD(Camera pCamera, TouchEvent pSceneTouchEvent)
protected boolean onTouchScene(Scene pScene, TouchEvent pSceneTouchEvent)
public void runOnUpdateThread(java.lang.Runnable pRunnable)
public void runOnUpdateThread(java.lang.Runnable pRunnable,
boolean pOnlyWhenEngineRunning)
Engine.UpdateThread, even though the Engine is paused.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 runSafely(java.lang.Runnable pRunnable)
pRunnable - the Runnable to run mutually exclusive to the Engine.UpdateThread and the GL-Thread.
When the caller already is on the Engine.UpdateThread or the GL-Thread, the Runnable is executed immediately.Engine#getEngineLock()} to manually {@link EngineLock#lock()}/{@link EngineLock#unlock()} on, while avoiding creating a {@link Runnable}.public void onDestroy()
public void onReloadResources()
protected Camera getCameraFromSurfaceTouchEvent(TouchEvent pTouchEvent)
protected Scene getSceneFromSurfaceTouchEvent(TouchEvent pTouchEvent)
protected void convertSurfaceToSceneTouchEvent(Camera pCamera, TouchEvent pSurfaceTouchEvent)
protected void convertSceneToSurfaceTouchEvent(Camera pCamera, TouchEvent pSurfaceTouchEvent)
public void onUpdate(long pNanosecondsElapsed)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected void onUpdateScene(float pSecondsElapsed)
protected void onUpdateUpdateHandlers(float pSecondsElapsed)
public void onDrawFrame(GLState pGLState) throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic boolean enableVibrator(android.content.Context pContext)
public void vibrate(long pMilliseconds)
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void vibrate(long[] pPattern,
int pRepeat)
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void enableLocationSensor(android.content.Context pContext,
ILocationListener pLocationListener,
LocationSensorOptions pLocationSensorOptions)
public void disableLocationSensor(android.content.Context pContext)
public boolean enableAccelerationSensor(android.content.Context pContext,
IAccelerationListener pAccelerationListener)
Engine#enableAccelerationSensor(Context, IAccelerationListener, AccelerationSensorOptions)}public boolean enableAccelerationSensor(android.content.Context pContext,
IAccelerationListener pAccelerationListener,
AccelerationSensorOptions pAccelerationSensorOptions)
true when the sensor was successfully enabled, false otherwise.public boolean disableAccelerationSensor(android.content.Context pContext)
true when the sensor was successfully disabled, false otherwise.public boolean enableOrientationSensor(android.content.Context pContext,
IOrientationListener pOrientationListener)
Engine#enableOrientationSensor(Context, IOrientationListener, OrientationSensorOptions)}public boolean enableOrientationSensor(android.content.Context pContext,
IOrientationListener pOrientationListener,
OrientationSensorOptions pOrientationSensorOptions)
true when the sensor was successfully enabled, false otherwise.public boolean disableOrientationSensor(android.content.Context pContext)
true when the sensor was successfully disabled, false otherwise.