code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package org.anddev.andengine.entity.util; import org.anddev.andengine.util.Debug; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:52:31 - 09.03.2010 */ public class FPSLogger extends AverageFPSCounter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mShortestFrame = Float.MAX_VALUE; protected float mLongestFrame = Float.MIN_VALUE; // =========================================================== // Constructors // =========================================================== public FPSLogger() { super(); } public FPSLogger(final float pAverageDuration) { super(pAverageDuration); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onHandleAverageDurationElapsed(final float pFPS) { this.onLogFPS(); this.mLongestFrame = Float.MIN_VALUE; this.mShortestFrame = Float.MAX_VALUE; } @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); this.mShortestFrame = Math.min(this.mShortestFrame, pSecondsElapsed); this.mLongestFrame = Math.max(this.mLongestFrame, pSecondsElapsed); } @Override public void reset() { super.reset(); this.mShortestFrame = Float.MAX_VALUE; this.mLongestFrame = Float.MIN_VALUE; } // =========================================================== // Methods // =========================================================== protected void onLogFPS() { Debug.d(String.format("FPS: %.2f (MIN: %.0f ms | MAX: %.0f ms)", this.mFrames / this.mSecondsElapsed, this.mShortestFrame * MILLISECONDSPERSECOND, this.mLongestFrame * MILLISECONDSPERSECOND)); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/util/FPSLogger.java
Java
lgpl
2,421
package org.anddev.andengine.entity.util; import org.anddev.andengine.util.constants.TimeConstants; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:52:31 - 09.03.2010 */ public abstract class AverageFPSCounter extends FPSCounter implements TimeConstants { // =========================================================== // Constants // =========================================================== private static final float AVERAGE_DURATION_DEFAULT = 5; // =========================================================== // Fields // =========================================================== protected final float mAverageDuration; // =========================================================== // Constructors // =========================================================== public AverageFPSCounter() { this(AVERAGE_DURATION_DEFAULT); } public AverageFPSCounter(final float pAverageDuration) { this.mAverageDuration = pAverageDuration; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onHandleAverageDurationElapsed(final float pFPS); @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if(this.mSecondsElapsed > this.mAverageDuration){ this.onHandleAverageDurationElapsed(this.getFPS()); this.mSecondsElapsed -= this.mAverageDuration; this.mFrames = 0; } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/util/AverageFPSCounter.java
Java
lgpl
2,072
package org.anddev.andengine.entity.util; import java.io.FileNotFoundException; import java.io.FileOutputStream; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.Entity; import org.anddev.andengine.entity.util.ScreenGrabber.IScreenGrabberCallback; import org.anddev.andengine.util.Debug; import org.anddev.andengine.util.StreamUtils; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:11:50 - 15.03.2010 */ public class ScreenCapture extends Entity implements IScreenGrabberCallback { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private String mFilePath; private final ScreenGrabber mScreenGrabber = new ScreenGrabber(); private IScreenCaptureCallback mScreenCaptureCallback; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { this.mScreenGrabber.onManagedDraw(pGL, pCamera); } @Override protected void onManagedUpdate(final float pSecondsElapsed) { /* Nothing */ } @Override public void reset() { /* Nothing */ } @Override public void onScreenGrabbed(final Bitmap pBitmap) { try { ScreenCapture.saveCapture(pBitmap, this.mFilePath); this.mScreenCaptureCallback.onScreenCaptured(this.mFilePath); } catch (final FileNotFoundException e) { this.mScreenCaptureCallback.onScreenCaptureFailed(this.mFilePath, e); } } @Override public void onScreenGrabFailed(final Exception pException) { this.mScreenCaptureCallback.onScreenCaptureFailed(this.mFilePath, pException); } // =========================================================== // Methods // =========================================================== public void capture(final int pCaptureWidth, final int pCaptureHeight, final String pFilePath, final IScreenCaptureCallback pScreenCaptureCallback) { this.capture(0, 0, pCaptureWidth, pCaptureHeight, pFilePath, pScreenCaptureCallback); } public void capture(final int pCaptureX, final int pCaptureY, final int pCaptureWidth, final int pCaptureHeight, final String pFilePath, final IScreenCaptureCallback pScreencaptureCallback) { this.mFilePath = pFilePath; this.mScreenCaptureCallback = pScreencaptureCallback; this.mScreenGrabber.grab(pCaptureX, pCaptureY, pCaptureWidth, pCaptureHeight, this); } private static void saveCapture(final Bitmap pBitmap, final String pFilePath) throws FileNotFoundException { FileOutputStream fos = null; try { fos = new FileOutputStream(pFilePath); pBitmap.compress(CompressFormat.PNG, 100, fos); } catch (final FileNotFoundException e) { StreamUtils.flushCloseStream(fos); Debug.e("Error saving file to: " + pFilePath, e); throw e; } } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface IScreenCaptureCallback { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== public void onScreenCaptured(final String pFilePath); public void onScreenCaptureFailed(final String pFilePath, final Exception pException); } }
zzy421-andengine
src/org/anddev/andengine/entity/util/ScreenCapture.java
Java
lgpl
4,295
package org.anddev.andengine.entity.util; import org.anddev.andengine.engine.handler.IUpdateHandler; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:52:31 - 09.03.2010 */ public class FPSCounter implements IUpdateHandler { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mSecondsElapsed; protected int mFrames; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== public float getFPS() { return this.mFrames / this.mSecondsElapsed; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onUpdate(final float pSecondsElapsed) { this.mFrames++; this.mSecondsElapsed += pSecondsElapsed; } @Override public void reset() { this.mFrames = 0; this.mSecondsElapsed = 0; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/util/FPSCounter.java
Java
lgpl
1,743
package org.anddev.andengine.entity.util; import java.nio.IntBuffer; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.Entity; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:27:22 - 10.01.2011 */ public class ScreenGrabber extends Entity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private int mGrabX; private int mGrabY; private int mGrabWidth; private int mGrabHeight; private boolean mScreenGrabPending = false; private IScreenGrabberCallback mScreenGrabCallback; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { if(this.mScreenGrabPending) { try { final Bitmap screenGrab = ScreenGrabber.grab(this.mGrabX, this.mGrabY, this.mGrabWidth, this.mGrabHeight, pGL); this.mScreenGrabCallback.onScreenGrabbed(screenGrab); } catch (final Exception e) { this.mScreenGrabCallback.onScreenGrabFailed(e); } this.mScreenGrabPending = false; } } @Override protected void onManagedUpdate(final float pSecondsElapsed) { /* Nothing */ } @Override public void reset() { /* Nothing */ } // =========================================================== // Methods // =========================================================== public void grab(final int pGrabWidth, final int pGrabHeight, final IScreenGrabberCallback pScreenGrabCallback) { this.grab(0, 0, pGrabWidth, pGrabHeight, pScreenGrabCallback); } public void grab(final int pGrabX, final int pGrabY, final int pGrabWidth, final int pGrabHeight, final IScreenGrabberCallback pScreenGrabCallback) { this.mGrabX = pGrabX; this.mGrabY = pGrabY; this.mGrabWidth = pGrabWidth; this.mGrabHeight = pGrabHeight; this.mScreenGrabCallback = pScreenGrabCallback; this.mScreenGrabPending = true; } private static Bitmap grab(final int pGrabX, final int pGrabY, final int pGrabWidth, final int pGrabHeight, final GL10 pGL) { final int[] source = new int[pGrabWidth * (pGrabY + pGrabHeight)]; final IntBuffer sourceBuffer = IntBuffer.wrap(source); sourceBuffer.position(0); // TODO Check availability of OpenGL and GL10.GL_RGBA combinations that require less conversion operations. // Note: There is (said to be) a bug with glReadPixels when 'y != 0', so we simply read starting from 'y == 0'. pGL.glReadPixels(pGrabX, 0, pGrabWidth, pGrabY + pGrabHeight, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, sourceBuffer); final int[] pixels = new int[pGrabWidth * pGrabHeight]; // Convert from RGBA_8888 (Which is actually ABGR as the whole buffer seems to be inverted) --> ARGB_8888 for (int y = 0; y < pGrabHeight; y++) { for (int x = 0; x < pGrabWidth; x++) { final int pixel = source[x + ((pGrabY + y) * pGrabWidth)]; final int blue = (pixel & 0x00FF0000) >> 16; final int red = (pixel & 0x000000FF) << 16; final int greenAlpha = pixel & 0xFF00FF00; pixels[x + ((pGrabHeight - y - 1) * pGrabWidth)] = greenAlpha | red | blue; } } return Bitmap.createBitmap(pixels, pGrabWidth, pGrabHeight, Config.ARGB_8888); } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface IScreenGrabberCallback { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== public void onScreenGrabbed(final Bitmap pBitmap); public void onScreenGrabFailed(final Exception pException); } }
zzy421-andengine
src/org/anddev/andengine/entity/util/ScreenGrabber.java
Java
lgpl
4,674
package org.anddev.andengine.entity.scene; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.shape.Shape; import org.anddev.andengine.input.touch.TouchEvent; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:35:53 - 29.03.2010 */ public class CameraScene extends Scene { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected Camera mCamera; // =========================================================== // Constructors // =========================================================== /** * {@link CameraScene#setCamera(Camera)} needs to be called manually. Otherwise nothing will be drawn. */ public CameraScene() { this(null); } public CameraScene(final Camera pCamera) { this.mCamera = pCamera; } // =========================================================== // Getter & Setter // =========================================================== public Camera getCamera() { return this.mCamera; } public void setCamera(final Camera pCamera) { this.mCamera = pCamera; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public boolean onSceneTouchEvent(final TouchEvent pSceneTouchEvent) { if(this.mCamera == null) { return false; } else { this.mCamera.convertSceneToCameraSceneTouchEvent(pSceneTouchEvent); final boolean handled = super.onSceneTouchEvent(pSceneTouchEvent); if(handled) { return true; } else { this.mCamera.convertCameraSceneToSceneTouchEvent(pSceneTouchEvent); return false; } } } @Override protected boolean onChildSceneTouchEvent(final TouchEvent pSceneTouchEvent) { final boolean childIsCameraScene = this.mChildScene instanceof CameraScene; if(childIsCameraScene) { this.mCamera.convertCameraSceneToSceneTouchEvent(pSceneTouchEvent); final boolean result = super.onChildSceneTouchEvent(pSceneTouchEvent); this.mCamera.convertSceneToCameraSceneTouchEvent(pSceneTouchEvent); return result; } else { return super.onChildSceneTouchEvent(pSceneTouchEvent); } } @Override protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { if(this.mCamera != null) { pGL.glMatrixMode(GL10.GL_PROJECTION); this.mCamera.onApplyCameraSceneMatrix(pGL); { pGL.glMatrixMode(GL10.GL_MODELVIEW); pGL.glPushMatrix(); pGL.glLoadIdentity(); super.onManagedDraw(pGL, pCamera); pGL.glPopMatrix(); } pGL.glMatrixMode(GL10.GL_PROJECTION); } } // =========================================================== // Methods // =========================================================== public void centerShapeInCamera(final Shape pShape) { final Camera camera = this.mCamera; pShape.setPosition((camera.getWidth() - pShape.getWidth()) * 0.5f, (camera.getHeight() - pShape.getHeight()) * 0.5f); } public void centerShapeInCameraHorizontally(final Shape pShape) { pShape.setPosition((this.mCamera.getWidth() - pShape.getWidth()) * 0.5f, pShape.getY()); } public void centerShapeInCameraVertically(final Shape pShape) { pShape.setPosition(pShape.getX(), (this.mCamera.getHeight() - pShape.getHeight()) * 0.5f); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/CameraScene.java
Java
lgpl
3,872
package org.anddev.andengine.entity.scene; import java.util.ArrayList; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.engine.handler.runnable.RunnableHandler; import org.anddev.andengine.entity.Entity; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.entity.scene.Scene.ITouchArea.ITouchAreaMatcher; import org.anddev.andengine.entity.scene.background.ColorBackground; import org.anddev.andengine.entity.scene.background.IBackground; import org.anddev.andengine.entity.shape.Shape; import org.anddev.andengine.input.touch.TouchEvent; import org.anddev.andengine.opengl.util.GLHelper; import org.anddev.andengine.util.IMatcher; import org.anddev.andengine.util.SmartList; import org.anddev.andengine.util.constants.Constants; import android.util.SparseArray; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:47:39 - 08.03.2010 */ public class Scene extends Entity { // =========================================================== // Constants // =========================================================== private static final int TOUCHAREAS_CAPACITY_DEFAULT = 4; // =========================================================== // Fields // =========================================================== private float mSecondsElapsedTotal; protected Scene mParentScene; protected Scene mChildScene; private boolean mChildSceneModalDraw; private boolean mChildSceneModalUpdate; private boolean mChildSceneModalTouch; protected SmartList<ITouchArea> mTouchAreas = new SmartList<ITouchArea>(TOUCHAREAS_CAPACITY_DEFAULT); private final RunnableHandler mRunnableHandler = new RunnableHandler(); private IOnSceneTouchListener mOnSceneTouchListener; private IOnAreaTouchListener mOnAreaTouchListener; private IBackground mBackground = new ColorBackground(0, 0, 0); // Black private boolean mBackgroundEnabled = true; private boolean mOnAreaTouchTraversalBackToFront = true; private boolean mTouchAreaBindingEnabled = false; private final SparseArray<ITouchArea> mTouchAreaBindings = new SparseArray<ITouchArea>(); private boolean mOnSceneTouchListenerBindingEnabled = false; private final SparseArray<IOnSceneTouchListener> mOnSceneTouchListenerBindings = new SparseArray<IOnSceneTouchListener>(); // =========================================================== // Constructors // =========================================================== public Scene() { } @Deprecated public Scene(final int pChildCount) { for(int i = 0; i < pChildCount; i++) { this.attachChild(new Entity()); } } // =========================================================== // Getter & Setter // =========================================================== public float getSecondsElapsedTotal() { return this.mSecondsElapsedTotal; } public IBackground getBackground() { return this.mBackground; } public void setBackground(final IBackground pBackground) { this.mBackground = pBackground; } public boolean isBackgroundEnabled() { return this.mBackgroundEnabled; } public void setBackgroundEnabled(final boolean pEnabled) { this.mBackgroundEnabled = pEnabled; } public void setOnSceneTouchListener(final IOnSceneTouchListener pOnSceneTouchListener) { this.mOnSceneTouchListener = pOnSceneTouchListener; } public IOnSceneTouchListener getOnSceneTouchListener() { return this.mOnSceneTouchListener; } public boolean hasOnSceneTouchListener() { return this.mOnSceneTouchListener != null; } public void setOnAreaTouchListener(final IOnAreaTouchListener pOnAreaTouchListener) { this.mOnAreaTouchListener = pOnAreaTouchListener; } public IOnAreaTouchListener getOnAreaTouchListener() { return this.mOnAreaTouchListener; } public boolean hasOnAreaTouchListener() { return this.mOnAreaTouchListener != null; } private void setParentScene(final Scene pParentScene) { this.mParentScene = pParentScene; } public boolean hasChildScene() { return this.mChildScene != null; } public Scene getChildScene() { return this.mChildScene; } public void setChildSceneModal(final Scene pChildScene) { this.setChildScene(pChildScene, true, true, true); } public void setChildScene(final Scene pChildScene) { this.setChildScene(pChildScene, false, false, false); } public void setChildScene(final Scene pChildScene, final boolean pModalDraw, final boolean pModalUpdate, final boolean pModalTouch) { pChildScene.setParentScene(this); this.mChildScene = pChildScene; this.mChildSceneModalDraw = pModalDraw; this.mChildSceneModalUpdate = pModalUpdate; this.mChildSceneModalTouch = pModalTouch; } public void clearChildScene() { this.mChildScene = null; } public void setOnAreaTouchTraversalBackToFront() { this.mOnAreaTouchTraversalBackToFront = true; } public void setOnAreaTouchTraversalFrontToBack() { this.mOnAreaTouchTraversalBackToFront = false; } public boolean isTouchAreaBindingEnabled() { return this.mTouchAreaBindingEnabled; } /** * Enable or disable the binding of TouchAreas to PointerIDs (fingers). * When enabled: TouchAreas get bound to a PointerID (finger) when returning true in * {@link Shape#onAreaTouched(TouchEvent, float, float)} or * {@link IOnAreaTouchListener#onAreaTouched(TouchEvent, ITouchArea, float, float)} * with {@link TouchEvent#ACTION_DOWN}, they will receive all subsequent {@link TouchEvent}s * that are made with the same PointerID (finger) * <b>even if the {@link TouchEvent} is outside of the actual {@link ITouchArea}</b>! * * @param pTouchAreaBindingEnabled */ public void setTouchAreaBindingEnabled(final boolean pTouchAreaBindingEnabled) { if(this.mTouchAreaBindingEnabled && !pTouchAreaBindingEnabled) { this.mTouchAreaBindings.clear(); } this.mTouchAreaBindingEnabled = pTouchAreaBindingEnabled; } public boolean isOnSceneTouchListenerBindingEnabled() { return this.mOnSceneTouchListenerBindingEnabled; } /** * Enable or disable the binding of TouchAreas to PointerIDs (fingers). * When enabled: The OnSceneTouchListener gets bound to a PointerID (finger) when returning true in * {@link Shape#onAreaTouched(TouchEvent, float, float)} or * {@link IOnAreaTouchListener#onAreaTouched(TouchEvent, ITouchArea, float, float)} * with {@link TouchEvent#ACTION_DOWN}, it will receive all subsequent {@link TouchEvent}s * that are made with the same PointerID (finger) * <b>even if the {@link TouchEvent} is would belong to an overlaying {@link ITouchArea}</b>! * * @param pOnSceneTouchListenerBindingEnabled */ public void setOnSceneTouchListenerBindingEnabled(final boolean pOnSceneTouchListenerBindingEnabled) { if(this.mOnSceneTouchListenerBindingEnabled && !pOnSceneTouchListenerBindingEnabled) { this.mOnSceneTouchListenerBindings.clear(); } this.mOnSceneTouchListenerBindingEnabled = pOnSceneTouchListenerBindingEnabled; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { final Scene childScene = this.mChildScene; if(childScene == null || !this.mChildSceneModalDraw) { if(this.mBackgroundEnabled) { pCamera.onApplySceneBackgroundMatrix(pGL); GLHelper.setModelViewIdentityMatrix(pGL); this.mBackground.onDraw(pGL, pCamera); } pCamera.onApplySceneMatrix(pGL); GLHelper.setModelViewIdentityMatrix(pGL); super.onManagedDraw(pGL, pCamera); } if(childScene != null) { childScene.onDraw(pGL, pCamera); } } @Override protected void onManagedUpdate(final float pSecondsElapsed) { this.mSecondsElapsedTotal += pSecondsElapsed; this.mRunnableHandler.onUpdate(pSecondsElapsed); final Scene childScene = this.mChildScene; if(childScene == null || !this.mChildSceneModalUpdate) { this.mBackground.onUpdate(pSecondsElapsed); super.onManagedUpdate(pSecondsElapsed); } if(childScene != null) { childScene.onUpdate(pSecondsElapsed); } } public boolean onSceneTouchEvent(final TouchEvent pSceneTouchEvent) { final int action = pSceneTouchEvent.getAction(); final boolean isActionDown = pSceneTouchEvent.isActionDown(); if(!isActionDown) { if(this.mOnSceneTouchListenerBindingEnabled) { final IOnSceneTouchListener boundOnSceneTouchListener = this.mOnSceneTouchListenerBindings.get(pSceneTouchEvent.getPointerID()); if (boundOnSceneTouchListener != null) { /* Check if boundTouchArea needs to be removed. */ switch(action) { case TouchEvent.ACTION_UP: case TouchEvent.ACTION_CANCEL: this.mOnSceneTouchListenerBindings.remove(pSceneTouchEvent.getPointerID()); } final Boolean handled = this.mOnSceneTouchListener.onSceneTouchEvent(this, pSceneTouchEvent); if(handled != null && handled) { return true; } } } if(this.mTouchAreaBindingEnabled) { final SparseArray<ITouchArea> touchAreaBindings = this.mTouchAreaBindings; final ITouchArea boundTouchArea = touchAreaBindings.get(pSceneTouchEvent.getPointerID()); /* In the case a ITouchArea has been bound to this PointerID, * we'll pass this this TouchEvent to the same ITouchArea. */ if(boundTouchArea != null) { final float sceneTouchEventX = pSceneTouchEvent.getX(); final float sceneTouchEventY = pSceneTouchEvent.getY(); /* Check if boundTouchArea needs to be removed. */ switch(action) { case TouchEvent.ACTION_UP: case TouchEvent.ACTION_CANCEL: touchAreaBindings.remove(pSceneTouchEvent.getPointerID()); } final Boolean handled = this.onAreaTouchEvent(pSceneTouchEvent, sceneTouchEventX, sceneTouchEventY, boundTouchArea); if(handled != null && handled) { return true; } } } } final Scene childScene = this.mChildScene; if(childScene != null) { final boolean handledByChild = this.onChildSceneTouchEvent(pSceneTouchEvent); if(handledByChild) { return true; } else if(this.mChildSceneModalTouch) { return false; } } final float sceneTouchEventX = pSceneTouchEvent.getX(); final float sceneTouchEventY = pSceneTouchEvent.getY(); final ArrayList<ITouchArea> touchAreas = this.mTouchAreas; if(touchAreas != null) { final int touchAreaCount = touchAreas.size(); if(touchAreaCount > 0) { if(this.mOnAreaTouchTraversalBackToFront) { /* Back to Front. */ for(int i = 0; i < touchAreaCount; i++) { final ITouchArea touchArea = touchAreas.get(i); if(touchArea.contains(sceneTouchEventX, sceneTouchEventY)) { final Boolean handled = this.onAreaTouchEvent(pSceneTouchEvent, sceneTouchEventX, sceneTouchEventY, touchArea); if(handled != null && handled) { /* If binding of ITouchAreas is enabled and this is an ACTION_DOWN event, * bind this ITouchArea to the PointerID. */ if(this.mTouchAreaBindingEnabled && isActionDown) { this.mTouchAreaBindings.put(pSceneTouchEvent.getPointerID(), touchArea); } return true; } } } } else { /* Front to back. */ for(int i = touchAreaCount - 1; i >= 0; i--) { final ITouchArea touchArea = touchAreas.get(i); if(touchArea.contains(sceneTouchEventX, sceneTouchEventY)) { final Boolean handled = this.onAreaTouchEvent(pSceneTouchEvent, sceneTouchEventX, sceneTouchEventY, touchArea); if(handled != null && handled) { /* If binding of ITouchAreas is enabled and this is an ACTION_DOWN event, * bind this ITouchArea to the PointerID. */ if(this.mTouchAreaBindingEnabled && isActionDown) { this.mTouchAreaBindings.put(pSceneTouchEvent.getPointerID(), touchArea); } return true; } } } } } } /* If no area was touched, the Scene itself was touched as a fallback. */ if(this.mOnSceneTouchListener != null){ final Boolean handled = this.mOnSceneTouchListener.onSceneTouchEvent(this, pSceneTouchEvent); if(handled != null && handled) { /* If binding of ITouchAreas is enabled and this is an ACTION_DOWN event, * bind the active OnSceneTouchListener to the PointerID. */ if(this.mOnSceneTouchListenerBindingEnabled && isActionDown) { this.mOnSceneTouchListenerBindings.put(pSceneTouchEvent.getPointerID(), this.mOnSceneTouchListener); } return true; } else { return false; } } else { return false; } } private Boolean onAreaTouchEvent(final TouchEvent pSceneTouchEvent, final float sceneTouchEventX, final float sceneTouchEventY, final ITouchArea touchArea) { final float[] touchAreaLocalCoordinates = touchArea.convertSceneToLocalCoordinates(sceneTouchEventX, sceneTouchEventY); final float touchAreaLocalX = touchAreaLocalCoordinates[Constants.VERTEX_INDEX_X]; final float touchAreaLocalY = touchAreaLocalCoordinates[Constants.VERTEX_INDEX_Y]; final boolean handledSelf = touchArea.onAreaTouched(pSceneTouchEvent, touchAreaLocalX, touchAreaLocalY); if(handledSelf) { return Boolean.TRUE; } else if(this.mOnAreaTouchListener != null) { return this.mOnAreaTouchListener.onAreaTouched(pSceneTouchEvent, touchArea, touchAreaLocalX, touchAreaLocalY); } else { return null; } } protected boolean onChildSceneTouchEvent(final TouchEvent pSceneTouchEvent) { return this.mChildScene.onSceneTouchEvent(pSceneTouchEvent); } @Override public void reset() { super.reset(); this.clearChildScene(); } @Override public void setParent(final IEntity pEntity) { // super.setParent(pEntity); } // =========================================================== // Methods // =========================================================== public void postRunnable(final Runnable pRunnable) { this.mRunnableHandler.postRunnable(pRunnable); } public void registerTouchArea(final ITouchArea pTouchArea) { this.mTouchAreas.add(pTouchArea); } public boolean unregisterTouchArea(final ITouchArea pTouchArea) { return this.mTouchAreas.remove(pTouchArea); } public boolean unregisterTouchAreas(final ITouchAreaMatcher pTouchAreaMatcher) { return this.mTouchAreas.removeAll(pTouchAreaMatcher); } public void clearTouchAreas() { this.mTouchAreas.clear(); } public ArrayList<ITouchArea> getTouchAreas() { return this.mTouchAreas; } public void back() { this.clearChildScene(); if(this.mParentScene != null) { this.mParentScene.clearChildScene(); this.mParentScene = null; } } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface ITouchArea { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public boolean contains(final float pX, final float pY); public float[] convertSceneToLocalCoordinates(final float pX, final float pY); public float[] convertLocalToSceneCoordinates(final float pX, final float pY); /** * This method only fires if this {@link ITouchArea} is registered to the {@link Scene} via {@link Scene#registerTouchArea(ITouchArea)}. * @param pSceneTouchEvent * @return <code>true</code> if the event was handled (that means {@link IOnAreaTouchListener} of the {@link Scene} will not be fired!), otherwise <code>false</code>. */ public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY); // =========================================================== // Inner and Anonymous Classes // =========================================================== public interface ITouchAreaMatcher extends IMatcher<ITouchArea> { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== } } /** * An interface for a callback to be invoked when a {@link TouchEvent} is * dispatched to an {@link ITouchArea} area. The callback will be invoked * before the {@link TouchEvent} is passed to the {@link ITouchArea}. */ public static interface IOnAreaTouchListener { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== /** * Called when a {@link TouchEvent} is dispatched to an {@link ITouchArea}. This allows * listeners to get a chance to respond before the target {@link ITouchArea#onAreaTouched(TouchEvent, float, float)} is called. * * @param pTouchArea The {@link ITouchArea} that the {@link TouchEvent} has been dispatched to. * @param pSceneTouchEvent The {@link TouchEvent} object containing full information about the event. * @param pTouchAreaLocalX the x coordinate within the area touched. * @param pTouchAreaLocalY the y coordinate within the area touched. * * @return <code>true</code> if this {@link IOnAreaTouchListener} has consumed the {@link TouchEvent}, <code>false</code> otherwise. */ public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final ITouchArea pTouchArea, final float pTouchAreaLocalX, final float pTouchAreaLocalY); } /** * An interface for a callback to be invoked when a {@link TouchEvent} is * dispatched to a {@link Scene}. The callback will be invoked * after all {@link ITouchArea}s have been checked and none consumed the {@link TouchEvent}. */ public static interface IOnSceneTouchListener { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== /** * Called when a {@link TouchEvent} is dispatched to a {@link Scene}. * * @param pScene The {@link Scene} that the {@link TouchEvent} has been dispatched to. * @param pSceneTouchEvent The {@link TouchEvent} object containing full information about the event. * * @return <code>true</code> if this {@link IOnSceneTouchListener} has consumed the {@link TouchEvent}, <code>false</code> otherwise. */ public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent); } }
zzy421-andengine
src/org/anddev/andengine/entity/scene/Scene.java
Java
lgpl
19,459
package org.anddev.andengine.entity.scene.popup; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.modifier.IEntityModifier; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.entity.text.Text; import org.anddev.andengine.opengl.font.Font; import org.anddev.andengine.util.HorizontalAlign; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 17:19:30 - 03.08.2010 */ public class TextPopupScene extends PopupScene { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final Text mText; // =========================================================== // Constructors // =========================================================== public TextPopupScene(final Camera pCamera, final Scene pParentScene, final Font pFont, final String pText, final float pDurationSeconds) { this(pCamera, pParentScene, pFont, pText, pDurationSeconds, null, null); } public TextPopupScene(final Camera pCamera, final Scene pParentScene, final Font pFont, final String pText, final float pDurationSeconds, final IEntityModifier pShapeModifier) { this(pCamera, pParentScene, pFont, pText, pDurationSeconds, pShapeModifier, null); } public TextPopupScene(final Camera pCamera, final Scene pParentScene, final Font pFont, final String pText, final float pDurationSeconds, final Runnable pRunnable) { this(pCamera, pParentScene, pFont, pText, pDurationSeconds, null, pRunnable); } public TextPopupScene(final Camera pCamera, final Scene pParentScene, final Font pFont, final String pText, final float pDurationSeconds, final IEntityModifier pShapeModifier, final Runnable pRunnable) { super(pCamera, pParentScene, pDurationSeconds, pRunnable); this.mText = new Text(0, 0, pFont, pText, HorizontalAlign.CENTER); this.centerShapeInCamera(this.mText); if(pShapeModifier != null) { this.mText.registerEntityModifier(pShapeModifier); } this.attachChild(this.mText); } // =========================================================== // Getter & Setter // =========================================================== public Text getText() { return this.mText; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/popup/TextPopupScene.java
Java
lgpl
2,975
package org.anddev.andengine.entity.scene.popup; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.engine.handler.timer.ITimerCallback; import org.anddev.andengine.engine.handler.timer.TimerHandler; import org.anddev.andengine.entity.scene.CameraScene; import org.anddev.andengine.entity.scene.Scene; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:36:51 - 03.08.2010 */ public class PopupScene extends CameraScene { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public PopupScene(final Camera pCamera, final Scene pParentScene, final float pDurationSeconds) { this(pCamera, pParentScene, pDurationSeconds, null); } public PopupScene(final Camera pCamera, final Scene pParentScene, final float pDurationSeconds, final Runnable pRunnable) { super(pCamera); this.setBackgroundEnabled(false); pParentScene.setChildScene(this, false, true, true); this.registerUpdateHandler(new TimerHandler(pDurationSeconds, new ITimerCallback() { @Override public void onTimePassed(final TimerHandler pTimerHandler) { PopupScene.this.unregisterUpdateHandler(pTimerHandler); pParentScene.clearChildScene(); if(pRunnable != null) { pRunnable.run(); } } })); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/popup/PopupScene.java
Java
lgpl
2,347
package org.anddev.andengine.entity.scene.menu; import java.util.ArrayList; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.scene.CameraScene; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.entity.scene.Scene.IOnAreaTouchListener; import org.anddev.andengine.entity.scene.Scene.IOnSceneTouchListener; import org.anddev.andengine.entity.scene.menu.animator.IMenuAnimator; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; import org.anddev.andengine.input.touch.TouchEvent; import android.view.MotionEvent; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:06:51 - 01.04.2010 */ public class MenuScene extends CameraScene implements IOnAreaTouchListener, IOnSceneTouchListener { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final ArrayList<IMenuItem> mMenuItems = new ArrayList<IMenuItem>(); private IOnMenuItemClickListener mOnMenuItemClickListener; private IMenuAnimator mMenuAnimator = IMenuAnimator.DEFAULT; private IMenuItem mSelectedMenuItem; // =========================================================== // Constructors // =========================================================== public MenuScene() { this(null, null); } public MenuScene(final IOnMenuItemClickListener pOnMenuItemClickListener) { this(null, pOnMenuItemClickListener); } public MenuScene(final Camera pCamera) { this(pCamera, null); } public MenuScene(final Camera pCamera, final IOnMenuItemClickListener pOnMenuItemClickListener) { super(pCamera); this.mOnMenuItemClickListener = pOnMenuItemClickListener; this.setOnSceneTouchListener(this); this.setOnAreaTouchListener(this); } // =========================================================== // Getter & Setter // =========================================================== public IOnMenuItemClickListener getOnMenuItemClickListener() { return this.mOnMenuItemClickListener; } public void setOnMenuItemClickListener(final IOnMenuItemClickListener pOnMenuItemClickListener) { this.mOnMenuItemClickListener = pOnMenuItemClickListener; } public int getMenuItemCount() { return this.mMenuItems.size(); } public void addMenuItem(final IMenuItem pMenuItem) { this.mMenuItems.add(pMenuItem); this.attachChild(pMenuItem); this.registerTouchArea(pMenuItem); } @Override public MenuScene getChildScene() { return (MenuScene)super.getChildScene(); } @Override public void setChildScene(final Scene pChildScene, final boolean pModalDraw, final boolean pModalUpdate, final boolean pModalTouch) throws IllegalArgumentException { if(pChildScene instanceof MenuScene) { super.setChildScene(pChildScene, pModalDraw, pModalUpdate, pModalTouch); } else { throw new IllegalArgumentException("MenuScene accepts only MenuScenes as a ChildScene."); } } @Override public void clearChildScene() { if(this.getChildScene() != null) { this.getChildScene().reset(); super.clearChildScene(); } } public void setMenuAnimator(final IMenuAnimator pMenuAnimator) { this.mMenuAnimator = pMenuAnimator; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final ITouchArea pTouchArea, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { final IMenuItem menuItem = ((IMenuItem)pTouchArea); switch(pSceneTouchEvent.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: if(this.mSelectedMenuItem != null && this.mSelectedMenuItem != menuItem) { this.mSelectedMenuItem.onUnselected(); } this.mSelectedMenuItem = menuItem; this.mSelectedMenuItem.onSelected(); break; case MotionEvent.ACTION_UP: if(this.mOnMenuItemClickListener != null) { final boolean handled = this.mOnMenuItemClickListener.onMenuItemClicked(this, menuItem, pTouchAreaLocalX, pTouchAreaLocalY); menuItem.onUnselected(); this.mSelectedMenuItem = null; return handled; } break; case MotionEvent.ACTION_CANCEL: menuItem.onUnselected(); this.mSelectedMenuItem = null; break; } return true; } @Override public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) { if(this.mSelectedMenuItem != null) { this.mSelectedMenuItem.onUnselected(); this.mSelectedMenuItem = null; } return false; } @Override public void back() { super.back(); this.reset(); } @Override public void reset() { super.reset(); final ArrayList<IMenuItem> menuItems = this.mMenuItems; for(int i = menuItems.size() - 1; i >= 0; i--) { menuItems.get(i).reset(); } this.prepareAnimations(); } // =========================================================== // Methods // =========================================================== public void closeMenuScene() { this.back(); } public void buildAnimations() { this.prepareAnimations(); final float cameraWidthRaw = this.mCamera.getWidthRaw(); final float cameraHeightRaw = this.mCamera.getHeightRaw(); this.mMenuAnimator.buildAnimations(this.mMenuItems, cameraWidthRaw, cameraHeightRaw); } public void prepareAnimations() { final float cameraWidthRaw = this.mCamera.getWidthRaw(); final float cameraHeightRaw = this.mCamera.getHeightRaw(); this.mMenuAnimator.prepareAnimations(this.mMenuItems, cameraWidthRaw, cameraHeightRaw); } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface IOnMenuItemClickListener { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public boolean onMenuItemClicked(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pMenuItemLocalX, final float pMenuItemLocalY); } }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/MenuScene.java
Java
lgpl
6,673
package org.anddev.andengine.entity.scene.menu.animator; import java.util.ArrayList; import org.anddev.andengine.entity.modifier.MoveModifier; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; import org.anddev.andengine.util.HorizontalAlign; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:04:35 - 02.04.2010 */ public class SlideMenuAnimator extends BaseMenuAnimator { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SlideMenuAnimator(){ super(); } public SlideMenuAnimator(final IEaseFunction pEaseFunction) { super(pEaseFunction); } public SlideMenuAnimator(final HorizontalAlign pHorizontalAlign) { super(pHorizontalAlign); } public SlideMenuAnimator(final HorizontalAlign pHorizontalAlign, final IEaseFunction pEaseFunction) { super(pHorizontalAlign, pEaseFunction); } public SlideMenuAnimator(final float pMenuItemSpacing) { super(pMenuItemSpacing); } public SlideMenuAnimator(final float pMenuItemSpacing, final IEaseFunction pEaseFunction) { super(pMenuItemSpacing, pEaseFunction); } public SlideMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing) { super(pHorizontalAlign, pMenuItemSpacing); } public SlideMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing, final IEaseFunction pEaseFunction) { super(pHorizontalAlign, pMenuItemSpacing, pEaseFunction); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void buildAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) { final IEaseFunction easeFunction = this.mEaseFunction; final float maximumWidth = this.getMaximumWidth(pMenuItems); final float overallHeight = this.getOverallHeight(pMenuItems); final float baseX = (pCameraWidth - maximumWidth) * 0.5f; final float baseY = (pCameraHeight - overallHeight) * 0.5f; float offsetY = 0; final int menuItemCount = pMenuItems.size(); for(int i = 0; i < menuItemCount; i++) { final IMenuItem menuItem = pMenuItems.get(i); final float offsetX; switch(this.mHorizontalAlign) { case LEFT: offsetX = 0; break; case RIGHT: offsetX = maximumWidth - menuItem.getWidthScaled(); break; case CENTER: default: offsetX = (maximumWidth - menuItem.getWidthScaled()) * 0.5f; break; } final MoveModifier moveModifier = new MoveModifier(DURATION, -maximumWidth, baseX + offsetX, baseY + offsetY, baseY + offsetY, easeFunction); moveModifier.setRemoveWhenFinished(false); menuItem.registerEntityModifier(moveModifier); offsetY += menuItem.getHeight() + this.mMenuItemSpacing; } } @Override public void prepareAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) { final float maximumWidth = this.getMaximumWidth(pMenuItems); final float overallHeight = this.getOverallHeight(pMenuItems); final float baseY = (pCameraHeight - overallHeight) * 0.5f; final float menuItemSpacing = this.mMenuItemSpacing; float offsetY = 0; final int menuItemCount = pMenuItems.size(); for(int i = 0; i < menuItemCount; i++) { final IMenuItem menuItem = pMenuItems.get(i); menuItem.setPosition(-maximumWidth, baseY + offsetY); offsetY += menuItem.getHeight() + menuItemSpacing; } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/animator/SlideMenuAnimator.java
Java
lgpl
4,526
package org.anddev.andengine.entity.scene.menu.animator; import java.util.ArrayList; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; import org.anddev.andengine.util.HorizontalAlign; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:17:32 - 02.04.2010 */ public abstract class BaseMenuAnimator implements IMenuAnimator { // =========================================================== // Constants // =========================================================== protected static final float DURATION = 1.0f; private static final float MENUITEMSPACING_DEFAULT = 1.0f; private static final HorizontalAlign HORIZONTALALIGN_DEFAULT = HorizontalAlign.CENTER; // =========================================================== // Fields // =========================================================== protected final float mMenuItemSpacing; protected final HorizontalAlign mHorizontalAlign; protected final IEaseFunction mEaseFunction; // =========================================================== // Constructors // =========================================================== public BaseMenuAnimator() { this(MENUITEMSPACING_DEFAULT); } public BaseMenuAnimator(final IEaseFunction pEaseFunction) { this(MENUITEMSPACING_DEFAULT, pEaseFunction); } public BaseMenuAnimator(final float pMenuItemSpacing) { this(HORIZONTALALIGN_DEFAULT, pMenuItemSpacing); } public BaseMenuAnimator(final float pMenuItemSpacing, final IEaseFunction pEaseFunction) { this(HORIZONTALALIGN_DEFAULT, pMenuItemSpacing, pEaseFunction); } public BaseMenuAnimator(final HorizontalAlign pHorizontalAlign) { this(pHorizontalAlign, MENUITEMSPACING_DEFAULT); } public BaseMenuAnimator(final HorizontalAlign pHorizontalAlign, final IEaseFunction pEaseFunction) { this(pHorizontalAlign, MENUITEMSPACING_DEFAULT, pEaseFunction); } public BaseMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing) { this(pHorizontalAlign, pMenuItemSpacing, IEaseFunction.DEFAULT); } public BaseMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing, final IEaseFunction pEaseFunction) { this.mHorizontalAlign = pHorizontalAlign; this.mMenuItemSpacing = pMenuItemSpacing; this.mEaseFunction = pEaseFunction; } // =========================================================== // Getter & Setter // =========================================================== protected float getMaximumWidth(final ArrayList<IMenuItem> pMenuItems) { float maximumWidth = Float.MIN_VALUE; for(int i = pMenuItems.size() - 1; i >= 0; i--) { final IMenuItem menuItem = pMenuItems.get(i); maximumWidth = Math.max(maximumWidth, menuItem.getWidthScaled()); } return maximumWidth; } protected float getOverallHeight(final ArrayList<IMenuItem> pMenuItems) { float overallHeight = 0; for(int i = pMenuItems.size() - 1; i >= 0; i--) { final IMenuItem menuItem = pMenuItems.get(i); overallHeight += menuItem.getHeight(); } overallHeight += (pMenuItems.size() - 1) * this.mMenuItemSpacing; return overallHeight; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/animator/BaseMenuAnimator.java
Java
lgpl
3,790
package org.anddev.andengine.entity.scene.menu.animator; import java.util.ArrayList; import org.anddev.andengine.entity.modifier.AlphaModifier; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; import org.anddev.andengine.util.HorizontalAlign; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:04:35 - 02.04.2010 */ public class AlphaMenuAnimator extends BaseMenuAnimator { // =========================================================== // Constants // =========================================================== private static final float ALPHA_FROM = 0.0f; private static final float ALPHA_TO = 1.0f; // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public AlphaMenuAnimator(){ super(); } public AlphaMenuAnimator(final IEaseFunction pEaseFunction) { super(pEaseFunction); } public AlphaMenuAnimator(final HorizontalAlign pHorizontalAlign) { super(pHorizontalAlign); } public AlphaMenuAnimator(final HorizontalAlign pHorizontalAlign, final IEaseFunction pEaseFunction) { super(pHorizontalAlign, pEaseFunction); } public AlphaMenuAnimator(final float pMenuItemSpacing) { super(pMenuItemSpacing); } public AlphaMenuAnimator(final float pMenuItemSpacing, final IEaseFunction pEaseFunction) { super(pMenuItemSpacing, pEaseFunction); } public AlphaMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing) { super(pHorizontalAlign, pMenuItemSpacing); } public AlphaMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing, final IEaseFunction pEaseFunction) { super(pHorizontalAlign, pMenuItemSpacing, pEaseFunction); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void buildAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) { final IEaseFunction easeFunction = this.mEaseFunction; final int menuItemCount = pMenuItems.size(); for(int i = menuItemCount - 1; i >= 0; i--) { final AlphaModifier alphaModifier = new AlphaModifier(DURATION, ALPHA_FROM, ALPHA_TO, easeFunction); alphaModifier.setRemoveWhenFinished(false); pMenuItems.get(i).registerEntityModifier(alphaModifier); } } @Override public void prepareAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) { final float maximumWidth = this.getMaximumWidth(pMenuItems); final float overallHeight = this.getOverallHeight(pMenuItems); final float baseX = (pCameraWidth - maximumWidth) * 0.5f; final float baseY = (pCameraHeight - overallHeight) * 0.5f; final float menuItemSpacing = this.mMenuItemSpacing; float offsetY = 0; final int menuItemCount = pMenuItems.size(); for(int i = 0; i < menuItemCount; i++) { final IMenuItem menuItem = pMenuItems.get(i); final float offsetX; switch(this.mHorizontalAlign) { case LEFT: offsetX = 0; break; case RIGHT: offsetX = maximumWidth - menuItem.getWidthScaled(); break; case CENTER: default: offsetX = (maximumWidth - menuItem.getWidthScaled()) * 0.5f; break; } menuItem.setPosition(baseX + offsetX , baseY + offsetY); menuItem.setAlpha(ALPHA_FROM); offsetY += menuItem.getHeight() + menuItemSpacing; } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/animator/AlphaMenuAnimator.java
Java
lgpl
4,302
package org.anddev.andengine.entity.scene.menu.animator; import java.util.ArrayList; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:50:36 - 02.04.2010 */ public interface IMenuAnimator { // =========================================================== // Constants // =========================================================== public static final IMenuAnimator DEFAULT = new AlphaMenuAnimator(); // =========================================================== // Methods // =========================================================== public void prepareAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight); public void buildAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight); }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/animator/IMenuAnimator.java
Java
lgpl
938
package org.anddev.andengine.entity.scene.menu.animator; import java.util.ArrayList; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; import org.anddev.andengine.util.HorizontalAlign; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:46:34 - 14.05.2010 */ public class DirectMenuAnimator extends BaseMenuAnimator { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public DirectMenuAnimator(){ super(); } public DirectMenuAnimator(final HorizontalAlign pHorizontalAlign) { super(pHorizontalAlign); } public DirectMenuAnimator(final float pMenuItemSpacing) { super(pMenuItemSpacing); } public DirectMenuAnimator(final HorizontalAlign pHorizontalAlign, final float pMenuItemSpacing) { super(pHorizontalAlign, pMenuItemSpacing); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void buildAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) { } @Override public void prepareAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) { final float maximumWidth = this.getMaximumWidth(pMenuItems); final float overallHeight = this.getOverallHeight(pMenuItems); final float baseX = (pCameraWidth - maximumWidth) * 0.5f; final float baseY = (pCameraHeight - overallHeight) * 0.5f; final float menuItemSpacing = this.mMenuItemSpacing; float offsetY = 0; final int menuItemCount = pMenuItems.size(); for(int i = 0; i < menuItemCount; i++) { final IMenuItem menuItem = pMenuItems.get(i); final float offsetX; switch(this.mHorizontalAlign) { case LEFT: offsetX = 0; break; case RIGHT: offsetX = maximumWidth - menuItem.getWidthScaled(); break; case CENTER: default: offsetX = (maximumWidth - menuItem.getWidthScaled()) * 0.5f; break; } menuItem.setPosition(baseX + offsetX , baseY + offsetY); offsetY += menuItem.getHeight() + menuItemSpacing; } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/animator/DirectMenuAnimator.java
Java
lgpl
3,087
package org.anddev.andengine.entity.scene.menu.item; import org.anddev.andengine.entity.text.Text; import org.anddev.andengine.opengl.font.Font; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:15:20 - 01.04.2010 */ public class TextMenuItem extends Text implements IMenuItem{ // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final int mID; // =========================================================== // Constructors // =========================================================== public TextMenuItem(final int pID, final Font pFont, final String pText) { super(0, 0, pFont, pText); this.mID = pID; } // =========================================================== // Getter & Setter // =========================================================== @Override public int getID() { return this.mID; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onSelected() { /* Nothing. */ } @Override public void onUnselected() { /* Nothing. */ } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/TextMenuItem.java
Java
lgpl
1,932
package org.anddev.andengine.entity.scene.menu.item; import org.anddev.andengine.entity.sprite.AnimatedSprite; import org.anddev.andengine.opengl.texture.region.TiledTextureRegion; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:44:39 - 07.07.2010 */ public class AnimatedSpriteMenuItem extends AnimatedSprite implements IMenuItem { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final int mID; // =========================================================== // Constructors // =========================================================== public AnimatedSpriteMenuItem(final int pID, final TiledTextureRegion pTiledTextureRegion) { super(0, 0, pTiledTextureRegion); this.mID = pID; } // =========================================================== // Getter & Setter // =========================================================== @Override public int getID() { return this.mID; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onSelected() { /* Nothing. */ } @Override public void onUnselected() { /* Nothing. */ } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/AnimatedSpriteMenuItem.java
Java
lgpl
2,014
package org.anddev.andengine.entity.scene.menu.item; import org.anddev.andengine.entity.sprite.Sprite; import org.anddev.andengine.opengl.texture.region.TextureRegion; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:15:20 - 01.04.2010 */ public class SpriteMenuItem extends Sprite implements IMenuItem { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final int mID; // =========================================================== // Constructors // =========================================================== public SpriteMenuItem(final int pID, final TextureRegion pTextureRegion) { super(0, 0, pTextureRegion); this.mID = pID; } // =========================================================== // Getter & Setter // =========================================================== @Override public int getID() { return this.mID; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onSelected() { /* Nothing. */ } @Override public void onUnselected() { /* Nothing. */ } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/SpriteMenuItem.java
Java
lgpl
1,962
package org.anddev.andengine.entity.scene.menu.item; import org.anddev.andengine.entity.shape.IShape; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 13:27:16 - 07.07.2010 */ public interface IMenuItem extends IShape { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public int getID(); public abstract void onSelected(); public abstract void onUnselected(); }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/IMenuItem.java
Java
lgpl
681
package org.anddev.andengine.entity.scene.menu.item.decorator; import java.util.Comparator; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.engine.handler.IUpdateHandler; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.entity.modifier.IEntityModifier; import org.anddev.andengine.entity.modifier.IEntityModifier.IEntityModifierMatcher; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; import org.anddev.andengine.entity.shape.IShape; import org.anddev.andengine.input.touch.TouchEvent; import org.anddev.andengine.util.Transformation; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:05:44 - 18.11.2010 */ public abstract class BaseMenuItemDecorator implements IMenuItem { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final IMenuItem mMenuItem; // =========================================================== // Constructors // =========================================================== public BaseMenuItemDecorator(final IMenuItem pMenuItem) { this.mMenuItem = pMenuItem; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onMenuItemSelected(final IMenuItem pMenuItem); protected abstract void onMenuItemUnselected(final IMenuItem pMenuItem); protected abstract void onMenuItemReset(final IMenuItem pMenuItem); @Override public int getID() { return this.mMenuItem.getID(); } @Override public final void onSelected() { this.mMenuItem.onSelected(); this.onMenuItemSelected(this.mMenuItem); } @Override public final void onUnselected() { this.mMenuItem.onUnselected(); this.onMenuItemUnselected(this.mMenuItem); } @Override public float getX() { return this.mMenuItem.getX(); } @Override public float getY() { return this.mMenuItem.getY(); } @Override public void setPosition(final IEntity pOtherEntity) { this.mMenuItem.setPosition(pOtherEntity); } @Override public void setPosition(final float pX, final float pY) { this.mMenuItem.setPosition(pX, pY); } @Override public float getBaseWidth() { return this.mMenuItem.getBaseWidth(); } @Override public float getBaseHeight() { return this.mMenuItem.getBaseHeight(); } @Override public float getWidth() { return this.mMenuItem.getWidth(); } @Override public float getWidthScaled() { return this.mMenuItem.getWidthScaled(); } @Override public float getHeight() { return this.mMenuItem.getHeight(); } @Override public float getHeightScaled() { return this.mMenuItem.getHeightScaled(); } @Override public float getInitialX() { return this.mMenuItem.getInitialX(); } @Override public float getInitialY() { return this.mMenuItem.getInitialY(); } @Override public float getRed() { return this.mMenuItem.getRed(); } @Override public float getGreen() { return this.mMenuItem.getGreen(); } @Override public float getBlue() { return this.mMenuItem.getBlue(); } @Override public float getAlpha() { return this.mMenuItem.getAlpha(); } @Override public void setAlpha(final float pAlpha) { this.mMenuItem.setAlpha(pAlpha); } @Override public void setColor(final float pRed, final float pGreen, final float pBlue) { this.mMenuItem.setColor(pRed, pGreen, pBlue); } @Override public void setColor(final float pRed, final float pGreen, final float pBlue, final float pAlpha) { this.mMenuItem.setColor(pRed, pGreen, pBlue, pAlpha); } @Override public boolean isRotated() { return this.mMenuItem.isRotated(); } @Override public float getRotation() { return this.mMenuItem.getRotation(); } @Override public void setRotation(final float pRotation) { this.mMenuItem.setRotation(pRotation); } @Override public float getRotationCenterX() { return this.mMenuItem.getRotationCenterX(); } @Override public float getRotationCenterY() { return this.mMenuItem.getRotationCenterY(); } @Override public void setRotationCenterX(final float pRotationCenterX) { this.mMenuItem.setRotationCenterX(pRotationCenterX); } @Override public void setRotationCenterY(final float pRotationCenterY) { this.mMenuItem.setRotationCenterY(pRotationCenterY); } @Override public void setRotationCenter(final float pRotationCenterX, final float pRotationCenterY) { this.mMenuItem.setRotationCenter(pRotationCenterX, pRotationCenterY); } @Override public boolean isScaled() { return this.mMenuItem.isScaled(); } @Override public float getScaleX() { return this.mMenuItem.getScaleX(); } @Override public float getScaleY() { return this.mMenuItem.getScaleY(); } @Override public void setScale(final float pScale) { this.mMenuItem.setScale(pScale); } @Override public void setScale(final float pScaleX, final float pScaleY) { this.mMenuItem.setScale(pScaleX, pScaleY); } @Override public void setScaleX(final float pScaleX) { this.mMenuItem.setScaleX(pScaleX); } @Override public void setScaleY(final float pScaleY) { this.mMenuItem.setScaleY(pScaleY); } @Override public float getScaleCenterX() { return this.mMenuItem.getScaleCenterX(); } @Override public float getScaleCenterY() { return this.mMenuItem.getScaleCenterY(); } @Override public void setScaleCenterX(final float pScaleCenterX) { this.mMenuItem.setScaleCenterX(pScaleCenterX); } @Override public void setScaleCenterY(final float pScaleCenterY) { this.mMenuItem.setScaleCenterY(pScaleCenterY); } @Override public void setScaleCenter(final float pScaleCenterX, final float pScaleCenterY) { this.mMenuItem.setScaleCenter(pScaleCenterX, pScaleCenterY); } @Override public boolean collidesWith(final IShape pOtherShape) { return this.mMenuItem.collidesWith(pOtherShape); } @Override public float[] getSceneCenterCoordinates() { return this.mMenuItem.getSceneCenterCoordinates(); } @Override public boolean isCullingEnabled() { return this.mMenuItem.isCullingEnabled(); } @Override public void registerEntityModifier(final IEntityModifier pEntityModifier) { this.mMenuItem.registerEntityModifier(pEntityModifier); } @Override public boolean unregisterEntityModifier(final IEntityModifier pEntityModifier) { return this.mMenuItem.unregisterEntityModifier(pEntityModifier); } @Override public boolean unregisterEntityModifiers(final IEntityModifierMatcher pEntityModifierMatcher) { return this.mMenuItem.unregisterEntityModifiers(pEntityModifierMatcher); } @Override public void clearEntityModifiers() { this.mMenuItem.clearEntityModifiers(); } @Override public void setInitialPosition() { this.mMenuItem.setInitialPosition(); } @Override public void setBlendFunction(final int pSourceBlendFunction, final int pDestinationBlendFunction) { this.mMenuItem.setBlendFunction(pSourceBlendFunction, pDestinationBlendFunction); } @Override public void setCullingEnabled(final boolean pCullingEnabled) { this.mMenuItem.setCullingEnabled(pCullingEnabled); } @Override public int getZIndex() { return this.mMenuItem.getZIndex(); } @Override public void setZIndex(final int pZIndex) { this.mMenuItem.setZIndex(pZIndex); } @Override public void onDraw(final GL10 pGL, final Camera pCamera) { this.mMenuItem.onDraw(pGL, pCamera); } @Override public void onUpdate(final float pSecondsElapsed) { this.mMenuItem.onUpdate(pSecondsElapsed); } @Override public void reset() { this.mMenuItem.reset(); this.onMenuItemReset(this.mMenuItem); } @Override public boolean contains(final float pX, final float pY) { return this.mMenuItem.contains(pX, pY); } @Override public float[] convertLocalToSceneCoordinates(final float pX, final float pY) { return this.mMenuItem.convertLocalToSceneCoordinates(pX, pY); } @Override public float[] convertLocalToSceneCoordinates(final float pX, final float pY, final float[] pReuse) { return this.mMenuItem.convertLocalToSceneCoordinates(pX, pY, pReuse); } @Override public float[] convertLocalToSceneCoordinates(final float[] pCoordinates) { return this.mMenuItem.convertLocalToSceneCoordinates(pCoordinates); } @Override public float[] convertLocalToSceneCoordinates(final float[] pCoordinates, final float[] pReuse) { return this.mMenuItem.convertLocalToSceneCoordinates(pCoordinates, pReuse); } @Override public float[] convertSceneToLocalCoordinates(final float pX, final float pY) { return this.mMenuItem.convertSceneToLocalCoordinates(pX, pY); } @Override public float[] convertSceneToLocalCoordinates(final float pX, final float pY, final float[] pReuse) { return this.mMenuItem.convertSceneToLocalCoordinates(pX, pY, pReuse); } @Override public float[] convertSceneToLocalCoordinates(final float[] pCoordinates) { return this.mMenuItem.convertSceneToLocalCoordinates(pCoordinates); } @Override public float[] convertSceneToLocalCoordinates(final float[] pCoordinates, final float[] pReuse) { return this.mMenuItem.convertSceneToLocalCoordinates(pCoordinates, pReuse); } @Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { return this.mMenuItem.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY); } @Override public int getChildCount() { return this.mMenuItem.getChildCount(); } @Override public void attachChild(final IEntity pEntity) { this.mMenuItem.attachChild(pEntity); } @Override public boolean attachChild(final IEntity pEntity, final int pIndex) { return this.mMenuItem.attachChild(pEntity, pIndex); } @Override public IEntity getFirstChild() { return this.mMenuItem.getFirstChild(); } @Override public IEntity getLastChild() { return this.mMenuItem.getLastChild(); } @Override public IEntity getChild(final int pIndex) { return this.mMenuItem.getChild(pIndex); } @Override public int getChildIndex(final IEntity pEntity) { return this.mMenuItem.getChildIndex(pEntity); } @Override public boolean setChildIndex(final IEntity pEntity, final int pIndex) { return this.mMenuItem.setChildIndex(pEntity, pIndex); } @Override public IEntity findChild(final IEntityMatcher pEntityMatcher) { return this.mMenuItem.findChild(pEntityMatcher); } @Override public boolean swapChildren(final IEntity pEntityA, final IEntity pEntityB) { return this.mMenuItem.swapChildren(pEntityA, pEntityB); } @Override public boolean swapChildren(final int pIndexA, final int pIndexB) { return this.mMenuItem.swapChildren(pIndexA, pIndexB); } @Override public void sortChildren() { this.mMenuItem.sortChildren(); } @Override public void sortChildren(final Comparator<IEntity> pEntityComparator) { this.mMenuItem.sortChildren(pEntityComparator); } @Override public boolean detachSelf() { return this.mMenuItem.detachSelf(); } @Override public boolean detachChild(final IEntity pEntity) { return this.mMenuItem.detachChild(pEntity); } @Override public IEntity detachChild(final IEntityMatcher pEntityMatcher) { return this.mMenuItem.detachChild(pEntityMatcher); } @Override public boolean detachChildren(final IEntityMatcher pEntityMatcher) { return this.mMenuItem.detachChildren(pEntityMatcher); } @Override public void detachChildren() { this.mMenuItem.detachChildren(); } @Override public void callOnChildren(final IEntityCallable pEntityCallable) { this.callOnChildren(pEntityCallable); } @Override public void callOnChildren(final IEntityMatcher pEntityMatcher, final IEntityCallable pEntityCallable) { this.mMenuItem.callOnChildren(pEntityMatcher, pEntityCallable); } @Override public Transformation getLocalToSceneTransformation() { return this.mMenuItem.getLocalToSceneTransformation(); } @Override public Transformation getSceneToLocalTransformation() { return this.mMenuItem.getSceneToLocalTransformation(); } @Override public boolean hasParent() { return this.mMenuItem.hasParent(); } @Override public IEntity getParent() { return this.mMenuItem.getParent(); } @Override public void setParent(final IEntity pEntity) { this.mMenuItem.setParent(pEntity); } @Override public boolean isVisible() { return this.mMenuItem.isVisible(); } @Override public void setVisible(final boolean pVisible) { this.mMenuItem.setVisible(pVisible); } @Override public boolean isChildrenVisible() { return this.mMenuItem.isChildrenVisible(); } @Override public void setChildrenVisible(final boolean pChildrenVisible) { this.mMenuItem.setChildrenVisible(pChildrenVisible); } @Override public boolean isIgnoreUpdate() { return this.mMenuItem.isIgnoreUpdate(); } @Override public void setIgnoreUpdate(final boolean pIgnoreUpdate) { this.mMenuItem.setIgnoreUpdate(pIgnoreUpdate); } @Override public boolean isChildrenIgnoreUpdate() { return this.mMenuItem.isChildrenIgnoreUpdate(); } @Override public void setChildrenIgnoreUpdate(final boolean pChildrenIgnoreUpdate) { this.mMenuItem.setChildrenIgnoreUpdate(pChildrenIgnoreUpdate); } @Override public void setUserData(final Object pUserData) { this.mMenuItem.setUserData(pUserData); } @Override public Object getUserData() { return this.mMenuItem.getUserData(); } @Override public void onAttached() { this.mMenuItem.onAttached(); } @Override public void onDetached() { this.mMenuItem.onDetached(); } @Override public void registerUpdateHandler(final IUpdateHandler pUpdateHandler) { this.mMenuItem.registerUpdateHandler(pUpdateHandler); } @Override public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler) { return this.mMenuItem.unregisterUpdateHandler(pUpdateHandler); } @Override public void clearUpdateHandlers() { this.mMenuItem.clearUpdateHandlers(); } @Override public boolean unregisterUpdateHandlers(final IUpdateHandlerMatcher pUpdateHandlerMatcher) { return this.mMenuItem.unregisterUpdateHandlers(pUpdateHandlerMatcher); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/decorator/BaseMenuItemDecorator.java
Java
lgpl
15,426
package org.anddev.andengine.entity.scene.menu.item.decorator; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:04:29 - 18.11.2010 */ public class ScaleMenuItemDecorator extends BaseMenuItemDecorator { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mSelectedScale; private final float mUnselectedScale; // =========================================================== // Constructors // =========================================================== public ScaleMenuItemDecorator(final IMenuItem pMenuItem, final float pSelectedScale, final float pUnselectedScale) { super(pMenuItem); this.mSelectedScale = pSelectedScale; this.mUnselectedScale = pUnselectedScale; pMenuItem.setScale(pUnselectedScale); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onMenuItemSelected(final IMenuItem pMenuItem) { this.setScale(this.mSelectedScale); } @Override public void onMenuItemUnselected(final IMenuItem pMenuItem) { this.setScale(this.mUnselectedScale); } @Override public void onMenuItemReset(final IMenuItem pMenuItem) { this.setScale(this.mUnselectedScale); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/decorator/ScaleMenuItemDecorator.java
Java
lgpl
2,283
package org.anddev.andengine.entity.scene.menu.item.decorator; import org.anddev.andengine.entity.scene.menu.item.IMenuItem; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:25:35 - 07.07.2010 */ public class ColorMenuItemDecorator extends BaseMenuItemDecorator { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mSelectedRed; private final float mSelectedGreen; private final float mSelectedBlue; private final float mUnselectedRed; private final float mUnselectedGreen; private final float mUnselectedBlue; // =========================================================== // Constructors // =========================================================== public ColorMenuItemDecorator(final IMenuItem pMenuItem, final float pSelectedRed, final float pSelectedGreen, final float pSelectedBlue, final float pUnselectedRed, final float pUnselectedGreen, final float pUnselectedBlue) { super(pMenuItem); this.mSelectedRed = pSelectedRed; this.mSelectedGreen = pSelectedGreen; this.mSelectedBlue = pSelectedBlue; this.mUnselectedRed = pUnselectedRed; this.mUnselectedGreen = pUnselectedGreen; this.mUnselectedBlue = pUnselectedBlue; pMenuItem.setColor(this.mUnselectedRed, this.mUnselectedGreen, this.mUnselectedBlue); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onMenuItemSelected(final IMenuItem pMenuItem) { pMenuItem.setColor(this.mSelectedRed, this.mSelectedGreen, this.mSelectedBlue); } @Override public void onMenuItemUnselected(final IMenuItem pMenuItem) { pMenuItem.setColor(this.mUnselectedRed, this.mUnselectedGreen, this.mUnselectedBlue); } @Override public void onMenuItemReset(final IMenuItem pMenuItem) { pMenuItem.setColor(this.mUnselectedRed, this.mUnselectedGreen, this.mUnselectedBlue); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/menu/item/decorator/ColorMenuItemDecorator.java
Java
lgpl
2,893
package org.anddev.andengine.entity.scene; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.modifier.ScaleModifier; import org.anddev.andengine.entity.sprite.Sprite; import org.anddev.andengine.opengl.texture.region.TextureRegion; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 09:45:02 - 03.05.2010 */ public class SplashScene extends Scene { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SplashScene(final Camera pCamera, final TextureRegion pTextureRegion) { this(pCamera, pTextureRegion, -1, 1, 1); } public SplashScene(final Camera pCamera, final TextureRegion pTextureRegion, final float pDuration, final float pScaleFrom, final float pScaleTo) { final Sprite loadingScreenSprite = new Sprite(pCamera.getMinX(), pCamera.getMinY(), pCamera.getWidth(), pCamera.getHeight(), pTextureRegion); if(pScaleFrom != 1 || pScaleTo != 1) { loadingScreenSprite.setScale(pScaleFrom); loadingScreenSprite.registerEntityModifier(new ScaleModifier(pDuration, pScaleFrom, pScaleTo, IEaseFunction.DEFAULT)); } this.attachChild(loadingScreenSprite); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/SplashScene.java
Java
lgpl
2,286
package org.anddev.andengine.entity.scene.background; import static org.anddev.andengine.util.constants.ColorConstants.COLOR_FACTOR_INT_TO_FLOAT; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 13:45:24 - 19.07.2010 */ public class ColorBackground extends BaseBackground { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private float mRed = 0.0f; private float mGreen = 0.0f; private float mBlue = 0.0f; private float mAlpha = 1.0f; private boolean mColorEnabled = true; // =========================================================== // Constructors // =========================================================== protected ColorBackground() { } public ColorBackground(final float pRed, final float pGreen, final float pBlue) { this.mRed = pRed; this.mGreen = pGreen; this.mBlue = pBlue; } public ColorBackground(final float pRed, final float pGreen, final float pBlue, final float pAlpha) { this.mRed = pRed; this.mGreen = pGreen; this.mBlue = pBlue; this.mAlpha = pAlpha; } // =========================================================== // Getter & Setter // =========================================================== /** * Sets the color using the arithmetic scheme (0.0f - 1.0f RGB triple). * @param pRed The red color value. Should be between 0.0 and 1.0, inclusive. * @param pGreen The green color value. Should be between 0.0 and 1.0, inclusive. * @param pBlue The blue color value. Should be between 0.0 and 1.0, inclusive. */ @Override public void setColor(final float pRed, final float pGreen, final float pBlue) { this.mRed = pRed; this.mGreen = pGreen; this.mBlue = pBlue; } /** * Sets the color using the arithmetic scheme (0.0f - 1.0f RGB quadruple). * @param pRed The red color value. Should be between 0.0 and 1.0, inclusive. * @param pGreen The green color value. Should be between 0.0 and 1.0, inclusive. * @param pBlue The blue color value. Should be between 0.0 and 1.0, inclusive. * @param pAlpha The alpha color value. Should be between 0.0 and 1.0, inclusive. */ @Override public void setColor(final float pRed, final float pGreen, final float pBlue, final float pAlpha) { this.setColor(pRed, pGreen, pBlue); this.mAlpha = pAlpha; } /** * Sets the color using the digital 8-bit per channel scheme (0 - 255 RGB triple). * @param pRed The red color value. Should be between 0 and 255, inclusive. * @param pGreen The green color value. Should be between 0 and 255, inclusive. * @param pBlue The blue color value. Should be between 0 and 255, inclusive. */ public void setColor(final int pRed, final int pGreen, final int pBlue) throws IllegalArgumentException { this.setColor(pRed / COLOR_FACTOR_INT_TO_FLOAT, pGreen / COLOR_FACTOR_INT_TO_FLOAT, pBlue / COLOR_FACTOR_INT_TO_FLOAT); } /** * Sets the color using the digital 8-bit per channel scheme (0 - 255 RGB quadruple). * @param pRed The red color value. Should be between 0 and 255, inclusive. * @param pGreen The green color value. Should be between 0 and 255, inclusive. * @param pBlue The blue color value. Should be between 0 and 255, inclusive. */ public void setColor(final int pRed, final int pGreen, final int pBlue, final int pAlpha) throws IllegalArgumentException { this.setColor(pRed / COLOR_FACTOR_INT_TO_FLOAT, pGreen / COLOR_FACTOR_INT_TO_FLOAT, pBlue / COLOR_FACTOR_INT_TO_FLOAT, pAlpha / COLOR_FACTOR_INT_TO_FLOAT); } public void setColorEnabled(final boolean pColorEnabled) { this.mColorEnabled = pColorEnabled; } public boolean isColorEnabled() { return this.mColorEnabled; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onDraw(final GL10 pGL, final Camera pCamera) { if(this.mColorEnabled) { pGL.glClearColor(this.mRed, this.mGreen, this.mBlue, this.mAlpha); pGL.glClear(GL10.GL_COLOR_BUFFER_BIT); } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/ColorBackground.java
Java
lgpl
4,806
package org.anddev.andengine.entity.scene.background; import org.anddev.andengine.engine.handler.IUpdateHandler; import org.anddev.andengine.opengl.IDrawable; import org.anddev.andengine.util.modifier.IModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 13:47:41 - 19.07.2010 */ public interface IBackground extends IDrawable, IUpdateHandler { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public void addBackgroundModifier(final IModifier<IBackground> pBackgroundModifier); public boolean removeBackgroundModifier(final IModifier<IBackground> pBackgroundModifier); public void clearBackgroundModifiers(); public void setColor(final float pRed, final float pGreen, final float pBlue); public void setColor(final float pRed, final float pGreen, final float pBlue, final float pAlpha); }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/IBackground.java
Java
lgpl
1,122
package org.anddev.andengine.entity.scene.background; import org.anddev.andengine.util.modifier.IModifier; import org.anddev.andengine.util.modifier.ModifierList; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:08:17 - 19.07.2010 */ public abstract class BaseBackground implements IBackground { // =========================================================== // Constants // =========================================================== private static final int BACKGROUNDMODIFIERS_CAPACITY_DEFAULT = 4; // =========================================================== // Fields // =========================================================== private final ModifierList<IBackground> mBackgroundModifiers = new ModifierList<IBackground>(this, BACKGROUNDMODIFIERS_CAPACITY_DEFAULT); // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void addBackgroundModifier(final IModifier<IBackground> pBackgroundModifier) { this.mBackgroundModifiers.add(pBackgroundModifier); } @Override public boolean removeBackgroundModifier(final IModifier<IBackground> pBackgroundModifier) { return this.mBackgroundModifiers.remove(pBackgroundModifier); } @Override public void clearBackgroundModifiers() { this.mBackgroundModifiers.clear(); } @Override public void onUpdate(final float pSecondsElapsed) { this.mBackgroundModifiers.onUpdate(pSecondsElapsed); } @Override public void reset() { this.mBackgroundModifiers.reset(); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/BaseBackground.java
Java
lgpl
2,308
package org.anddev.andengine.entity.scene.background; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:44:31 - 19.07.2010 */ public class AutoParallaxBackground extends ParallaxBackground { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private float mParallaxChangePerSecond; // =========================================================== // Constructors // =========================================================== public AutoParallaxBackground(final float pRed, final float pGreen, final float pBlue, final float pParallaxChangePerSecond) { super(pRed, pGreen, pBlue); this.mParallaxChangePerSecond = pParallaxChangePerSecond; } // =========================================================== // Getter & Setter // =========================================================== public void setParallaxChangePerSecond(final float pParallaxChangePerSecond) { this.mParallaxChangePerSecond = pParallaxChangePerSecond; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); this.mParallaxValue += this.mParallaxChangePerSecond * pSecondsElapsed; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/AutoParallaxBackground.java
Java
lgpl
1,944
package org.anddev.andengine.entity.scene.background.modifier; import org.anddev.andengine.entity.scene.background.IBackground; import org.anddev.andengine.util.modifier.BaseTripleValueSpanModifier; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:51:03 - 03.09.2010 */ public class ColorModifier extends BaseTripleValueSpanModifier<IBackground> implements IBackgroundModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue) { this(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, null, IEaseFunction.DEFAULT); } public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IEaseFunction pEaseFunction) { this(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, null, pEaseFunction); } public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IBackgroundModifierListener pBackgroundModifierListener) { super(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pBackgroundModifierListener, IEaseFunction.DEFAULT); } public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IBackgroundModifierListener pBackgroundModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pBackgroundModifierListener, pEaseFunction); } protected ColorModifier(final ColorModifier pColorModifier) { super(pColorModifier); } @Override public ColorModifier deepCopy(){ return new ColorModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValues(final IBackground pBackground, final float pRed, final float pGreen, final float pBlue) { pBackground.setColor(pRed, pGreen, pBlue); } @Override protected void onSetValues(final IBackground pBackground, final float pPerctentageDone, final float pRed, final float pGreen, final float pBlue) { pBackground.setColor(pRed, pGreen, pBlue); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/modifier/ColorModifier.java
Java
lgpl
3,587
package org.anddev.andengine.entity.scene.background.modifier; import org.anddev.andengine.entity.scene.background.IBackground; import org.anddev.andengine.util.modifier.ParallelModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:03:57 - 03.09.2010 */ public class ParallelBackgroundModifier extends ParallelModifier<IBackground> implements IBackgroundModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ParallelBackgroundModifier(final IBackgroundModifier... pBackgroundModifiers) throws IllegalArgumentException { super(pBackgroundModifiers); } public ParallelBackgroundModifier(final IBackgroundModifierListener pBackgroundModifierListener, final IBackgroundModifier... pBackgroundModifiers) throws IllegalArgumentException { super(pBackgroundModifierListener, pBackgroundModifiers); } protected ParallelBackgroundModifier(final ParallelBackgroundModifier pParallelBackgroundModifier) throws DeepCopyNotSupportedException { super(pParallelBackgroundModifier); } @Override public ParallelBackgroundModifier deepCopy() throws DeepCopyNotSupportedException { return new ParallelBackgroundModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/modifier/ParallelBackgroundModifier.java
Java
lgpl
2,267
package org.anddev.andengine.entity.scene.background.modifier; import org.anddev.andengine.entity.scene.background.IBackground; import org.anddev.andengine.util.modifier.IModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:55:54 - 03.09.2010 */ public interface IBackgroundModifier extends IModifier<IBackground> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== @Override public IBackgroundModifier deepCopy() throws DeepCopyNotSupportedException; // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface IBackgroundModifierListener extends IModifierListener<IBackground>{ // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/modifier/IBackgroundModifier.java
Java
lgpl
1,343
package org.anddev.andengine.entity.scene.background.modifier; import org.anddev.andengine.entity.scene.background.IBackground; import org.anddev.andengine.util.modifier.LoopModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:03:53 - 03.09.2010 */ public class LoopBackgroundModifier extends LoopModifier<IBackground> implements IBackgroundModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public LoopBackgroundModifier(final IBackgroundModifier pBackgroundModifier) { super(pBackgroundModifier); } public LoopBackgroundModifier(final IBackgroundModifier pBackgroundModifier, final int pLoopCount) { super(pBackgroundModifier, pLoopCount); } public LoopBackgroundModifier(final IBackgroundModifier pBackgroundModifier, final int pLoopCount, final ILoopBackgroundModifierListener pLoopModifierListener) { super(pBackgroundModifier, pLoopCount, pLoopModifierListener, (IBackgroundModifierListener)null); } public LoopBackgroundModifier(final IBackgroundModifier pBackgroundModifier, final int pLoopCount, final IBackgroundModifierListener pBackgroundModifierListener) { super(pBackgroundModifier, pLoopCount, pBackgroundModifierListener); } public LoopBackgroundModifier(final IBackgroundModifier pBackgroundModifier, final int pLoopCount, final ILoopBackgroundModifierListener pLoopModifierListener, final IBackgroundModifierListener pBackgroundModifierListener) { super(pBackgroundModifier, pLoopCount, pLoopModifierListener, pBackgroundModifierListener); } protected LoopBackgroundModifier(final LoopBackgroundModifier pLoopBackgroundModifier) throws DeepCopyNotSupportedException { super(pLoopBackgroundModifier); } @Override public LoopBackgroundModifier deepCopy() throws DeepCopyNotSupportedException { return new LoopBackgroundModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== public interface ILoopBackgroundModifierListener extends ILoopModifierListener<IBackground> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/modifier/LoopBackgroundModifier.java
Java
lgpl
3,335
package org.anddev.andengine.entity.scene.background.modifier; import org.anddev.andengine.entity.scene.background.IBackground; import org.anddev.andengine.util.modifier.SequenceModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:04:02 - 03.09.2010 */ public class SequenceBackgroundModifier extends SequenceModifier<IBackground> implements IBackgroundModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SequenceBackgroundModifier(final IBackgroundModifier... pBackgroundModifiers) throws IllegalArgumentException { super(pBackgroundModifiers); } public SequenceBackgroundModifier(final ISubSequenceBackgroundModifierListener pSubSequenceBackgroundModifierListener, final IBackgroundModifier... pBackgroundModifiers) throws IllegalArgumentException { super(pSubSequenceBackgroundModifierListener, pBackgroundModifiers); } public SequenceBackgroundModifier(final IBackgroundModifierListener pBackgroundModifierListener, final IBackgroundModifier... pBackgroundModifiers) throws IllegalArgumentException { super(pBackgroundModifierListener, pBackgroundModifiers); } public SequenceBackgroundModifier(final ISubSequenceBackgroundModifierListener pSubSequenceBackgroundModifierListener, final IBackgroundModifierListener pBackgroundModifierListener, final IBackgroundModifier... pBackgroundModifiers) throws IllegalArgumentException { super(pSubSequenceBackgroundModifierListener, pBackgroundModifierListener, pBackgroundModifiers); } protected SequenceBackgroundModifier(final SequenceBackgroundModifier pSequenceBackgroundModifier) throws DeepCopyNotSupportedException { super(pSequenceBackgroundModifier); } @Override public SequenceBackgroundModifier deepCopy() throws DeepCopyNotSupportedException { return new SequenceBackgroundModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== public interface ISubSequenceBackgroundModifierListener extends ISubSequenceModifierListener<IBackground> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/modifier/SequenceBackgroundModifier.java
Java
lgpl
3,343
package org.anddev.andengine.entity.scene.background; import org.anddev.andengine.entity.sprite.Sprite; import org.anddev.andengine.opengl.texture.TextureManager; import org.anddev.andengine.opengl.texture.TextureOptions; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.anddev.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource; import org.anddev.andengine.opengl.texture.bitmap.BitmapTexture.BitmapTextureFormat; import org.anddev.andengine.opengl.texture.region.TextureRegion; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:11:10 - 19.07.2010 */ public class RepeatingSpriteBackground extends SpriteBackground { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private BitmapTextureAtlas mBitmapTextureAtlas; private final float mScale; // =========================================================== // Constructors // =========================================================== /** * @param pCameraWidth * @param pCameraHeight * @param pTextureManager * @param pBitmapTextureAtlasSource needs to be a power of two as otherwise the <code>repeating</code> feature doesn't work. */ public RepeatingSpriteBackground(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource) throws IllegalArgumentException { this(pCameraWidth, pCameraHeight, pTextureManager, pBitmapTextureAtlasSource, 1); } public RepeatingSpriteBackground(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final float pScale) throws IllegalArgumentException { super(null); this.mScale = pScale; this.mEntity = this.loadSprite(pCameraWidth, pCameraHeight, pTextureManager, pBitmapTextureAtlasSource); } // =========================================================== // Getter & Setter // =========================================================== public BitmapTextureAtlas getBitmapTextureAtlas() { return this.mBitmapTextureAtlas; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== private Sprite loadSprite(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource) throws IllegalArgumentException { this.mBitmapTextureAtlas = new BitmapTextureAtlas(pBitmapTextureAtlasSource.getWidth(), pBitmapTextureAtlasSource.getHeight(), BitmapTextureFormat.RGBA_8888, TextureOptions.REPEATING_NEAREST_PREMULTIPLYALPHA); final TextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(this.mBitmapTextureAtlas, pBitmapTextureAtlasSource, 0, 0); final int width = Math.round(pCameraWidth / this.mScale); final int height = Math.round(pCameraHeight / this.mScale); textureRegion.setWidth(width); textureRegion.setHeight(height); pTextureManager.loadTexture(this.mBitmapTextureAtlas); final Sprite sprite = new Sprite(0, 0, width, height, textureRegion); sprite.setScaleCenter(0, 0); sprite.setScale(this.mScale); return sprite; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/RepeatingSpriteBackground.java
Java
lgpl
4,029
package org.anddev.andengine.entity.scene.background; import org.anddev.andengine.entity.sprite.BaseSprite; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:01:43 - 19.07.2010 */ public class SpriteBackground extends EntityBackground { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SpriteBackground(final BaseSprite pBaseSprite) { super(pBaseSprite); } public SpriteBackground(final float pRed, final float pGreen, final float pBlue, final BaseSprite pBaseSprite) { super(pRed, pGreen, pBlue, pBaseSprite); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/SpriteBackground.java
Java
lgpl
1,637
package org.anddev.andengine.entity.scene.background; import java.util.ArrayList; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.shape.Shape; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:36:26 - 19.07.2010 */ public class ParallaxBackground extends ColorBackground { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final ArrayList<ParallaxEntity> mParallaxEntities = new ArrayList<ParallaxEntity>(); private int mParallaxEntityCount; protected float mParallaxValue; // =========================================================== // Constructors // =========================================================== public ParallaxBackground(final float pRed, final float pGreen, final float pBlue) { super(pRed, pGreen, pBlue); } // =========================================================== // Getter & Setter // =========================================================== public void setParallaxValue(final float pParallaxValue) { this.mParallaxValue = pParallaxValue; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onDraw(final GL10 pGL, final Camera pCamera) { super.onDraw(pGL, pCamera); final float parallaxValue = this.mParallaxValue; final ArrayList<ParallaxEntity> parallaxEntities = this.mParallaxEntities; for(int i = 0; i < this.mParallaxEntityCount; i++) { parallaxEntities.get(i).onDraw(pGL, parallaxValue, pCamera); } } // =========================================================== // Methods // =========================================================== public void attachParallaxEntity(final ParallaxEntity pParallaxEntity) { this.mParallaxEntities.add(pParallaxEntity); this.mParallaxEntityCount++; } public boolean detachParallaxEntity(final ParallaxEntity pParallaxEntity) { this.mParallaxEntityCount--; final boolean success = this.mParallaxEntities.remove(pParallaxEntity); if(!success) { this.mParallaxEntityCount++; } return success; } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static class ParallaxEntity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== final float mParallaxFactor; final Shape mShape; // =========================================================== // Constructors // =========================================================== public ParallaxEntity(final float pParallaxFactor, final Shape pShape) { this.mParallaxFactor = pParallaxFactor; this.mShape = pShape; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public void onDraw(final GL10 pGL, final float pParallaxValue, final Camera pCamera) { pGL.glPushMatrix(); { final float cameraWidth = pCamera.getWidth(); final float shapeWidthScaled = this.mShape.getWidthScaled(); float baseOffset = (pParallaxValue * this.mParallaxFactor) % shapeWidthScaled; while(baseOffset > 0) { baseOffset -= shapeWidthScaled; } pGL.glTranslatef(baseOffset, 0, 0); float currentMaxX = baseOffset; do { this.mShape.onDraw(pGL, pCamera); pGL.glTranslatef(shapeWidthScaled, 0, 0); currentMaxX += shapeWidthScaled; } while(currentMaxX < cameraWidth); } pGL.glPopMatrix(); } // =========================================================== // Inner and Anonymous Classes // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/ParallaxBackground.java
Java
lgpl
4,759
package org.anddev.andengine.entity.scene.background; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.IEntity; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:25:10 - 21.07.2010 */ public class EntityBackground extends ColorBackground { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected IEntity mEntity; // =========================================================== // Constructors // =========================================================== public EntityBackground(final IEntity pEntity) { this.mEntity = pEntity; } public EntityBackground(final float pRed, final float pGreen, final float pBlue, final IEntity pEntity) { super(pRed, pGreen, pBlue); this.mEntity = pEntity; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onDraw(final GL10 pGL, final Camera pCamera) { super.onDraw(pGL, pCamera); this.mEntity.onDraw(pGL, pCamera); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/scene/background/EntityBackground.java
Java
lgpl
1,912
package org.anddev.andengine.entity.primitive; import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL11; import org.anddev.andengine.collision.LineCollisionChecker; import org.anddev.andengine.collision.RectangularShapeCollisionChecker; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.shape.IShape; import org.anddev.andengine.entity.shape.RectangularShape; import org.anddev.andengine.entity.shape.Shape; import org.anddev.andengine.opengl.util.GLHelper; import org.anddev.andengine.opengl.vertex.LineVertexBuffer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 09:50:36 - 04.04.2010 */ public class Line extends Shape { // =========================================================== // Constants // =========================================================== private static final float LINEWIDTH_DEFAULT = 1.0f; // =========================================================== // Fields // =========================================================== protected float mX2; protected float mY2; private float mLineWidth; private final LineVertexBuffer mLineVertexBuffer; // =========================================================== // Constructors // =========================================================== public Line(final float pX1, final float pY1, final float pX2, final float pY2) { this(pX1, pY1, pX2, pY2, LINEWIDTH_DEFAULT); } public Line(final float pX1, final float pY1, final float pX2, final float pY2, final float pLineWidth) { super(pX1, pY1); this.mX2 = pX2; this.mY2 = pY2; this.mLineWidth = pLineWidth; this.mLineVertexBuffer = new LineVertexBuffer(GL11.GL_STATIC_DRAW, true); this.updateVertexBuffer(); final float width = this.getWidth(); final float height = this.getHeight(); this.mRotationCenterX = width * 0.5f; this.mRotationCenterY = height * 0.5f; this.mScaleCenterX = this.mRotationCenterX; this.mScaleCenterY = this.mRotationCenterY; } // =========================================================== // Getter & Setter // =========================================================== /** * @deprecated Instead use {@link Line#getX1()} or {@link Line#getX2()}. */ @Deprecated @Override public float getX() { return super.getX(); } /** * @deprecatedInstead use {@link Line#getY1()} or {@link Line#getY2()}. */ @Deprecated @Override public float getY() { return super.getY(); } public float getX1() { return super.getX(); } public float getY1() { return super.getY(); } public float getX2() { return this.mX2; } public float getY2() { return this.mY2; } public float getLineWidth() { return this.mLineWidth; } public void setLineWidth(final float pLineWidth) { this.mLineWidth = pLineWidth; } @Override public float getBaseHeight() { return this.mY2 - this.mY; } @Override public float getBaseWidth() { return this.mX2 - this.mX; } @Override public float getHeight() { return this.mY2 - this.mY; } @Override public float getWidth() { return this.mX2 - this.mX; } /** * @deprecated Instead use {@link Line#setPosition(float, float, float, float)}. */ @Deprecated @Override public void setPosition(final float pX, final float pY) { final float dX = this.mX - pX; final float dY = this.mY - pY; super.setPosition(pX, pY); this.mX2 += dX; this.mY2 += dY; } public void setPosition(final float pX1, final float pY1, final float pX2, final float pY2) { this.mX2 = pX2; this.mY2 = pY2; super.setPosition(pX1, pY1); this.updateVertexBuffer(); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected boolean isCulled(final Camera pCamera) { return pCamera.isLineVisible(this); } @Override protected void onInitDraw(final GL10 pGL) { super.onInitDraw(pGL); GLHelper.disableTextures(pGL); GLHelper.disableTexCoordArray(pGL); GLHelper.lineWidth(pGL, this.mLineWidth); } @Override public LineVertexBuffer getVertexBuffer() { return this.mLineVertexBuffer; } @Override protected void onUpdateVertexBuffer() { this.mLineVertexBuffer.update(0, 0, this.mX2 - this.mX, this.mY2 - this.mY); } @Override protected void drawVertices(final GL10 pGL, final Camera pCamera) { pGL.glDrawArrays(GL10.GL_LINES, 0, LineVertexBuffer.VERTICES_PER_LINE); } @Override public float[] getSceneCenterCoordinates() { return null; // TODO // return convertLocalToSceneCoordinates(this, (this.mX + this.mX2) * 0.5f, (this.mY + this.mY2) * 0.5f); } @Override @Deprecated public boolean contains(final float pX, final float pY) { return false; } @Override @Deprecated public float[] convertSceneToLocalCoordinates(final float pX, final float pY) { return null; } @Override @Deprecated public float[] convertLocalToSceneCoordinates(final float pX, final float pY) { return null; } @Override public boolean collidesWith(final IShape pOtherShape) { if(pOtherShape instanceof Line) { final Line otherLine = (Line) pOtherShape; return LineCollisionChecker.checkLineCollision(this.mX, this.mY, this.mX2, this.mY2, otherLine.mX, otherLine.mY, otherLine.mX2, otherLine.mY2); } else if(pOtherShape instanceof RectangularShape) { final RectangularShape rectangularShape = (RectangularShape) pOtherShape; return RectangularShapeCollisionChecker.checkCollision(rectangularShape, this); } else { return false; } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/primitive/Line.java
Java
lgpl
6,165
package org.anddev.andengine.entity.primitive; import javax.microedition.khronos.opengles.GL11; import org.anddev.andengine.entity.shape.RectangularShape; import org.anddev.andengine.opengl.vertex.RectangleVertexBuffer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:05:49 - 11.04.2010 */ public abstract class BaseRectangle extends RectangularShape { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public BaseRectangle(final float pX, final float pY, final float pWidth, final float pHeight) { super(pX, pY, pWidth, pHeight, new RectangleVertexBuffer(GL11.GL_STATIC_DRAW, true)); this.updateVertexBuffer(); } public BaseRectangle(final float pX, final float pY, final float pWidth, final float pHeight, final RectangleVertexBuffer pRectangleVertexBuffer) { super(pX, pY, pWidth, pHeight, pRectangleVertexBuffer); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public RectangleVertexBuffer getVertexBuffer() { return (RectangleVertexBuffer)this.mVertexBuffer; } @Override protected void onUpdateVertexBuffer(){ this.getVertexBuffer().update(this.mWidth, this.mHeight); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/primitive/BaseRectangle.java
Java
lgpl
2,187
package org.anddev.andengine.entity.primitive; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.opengl.util.GLHelper; import org.anddev.andengine.opengl.vertex.RectangleVertexBuffer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:18:49 - 13.03.2010 */ public class Rectangle extends BaseRectangle { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public Rectangle(final float pX, final float pY, final float pWidth, final float pHeight) { super(pX, pY, pWidth, pHeight); } public Rectangle(final float pX, final float pY, final float pWidth, final float pHeight, final RectangleVertexBuffer pRectangleVertexBuffer) { super(pX, pY, pWidth, pHeight, pRectangleVertexBuffer); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onInitDraw(final GL10 pGL) { super.onInitDraw(pGL); GLHelper.disableTextures(pGL); GLHelper.disableTexCoordArray(pGL); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/primitive/Rectangle.java
Java
lgpl
1,991
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 23:24:26 - 16.07.2011 */ public class QuadraticBezierMoveModifier extends DurationEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mX1; private final float mY1; private final float mX2; private final float mY2; private final float mX3; private final float mY3; private final IEaseFunction mEaseFunction; // =========================================================== // Constructors // =========================================================== public QuadraticBezierMoveModifier(final float pDuration, final float pX1, final float pY1, final float pX2, final float pY2, final float pX3, final float pY3, final IEaseFunction pEaseFunction) { super(pDuration); this.mX1 = pX1; this.mY1 = pY1; this.mX2 = pX2; this.mY2 = pY2; this.mX3 = pX3; this.mY3 = pY3; this.mEaseFunction = pEaseFunction; } @Override public QuadraticBezierMoveModifier deepCopy() { return new QuadraticBezierMoveModifier(this.mDuration, this.mX1, this.mY1, this.mX2, this.mY2, this.mX3, this.mY3, this.mEaseFunction); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedUpdate(final float pSecondsElapsed, final IEntity pEntity) { final float percentageDone = this.mEaseFunction.getPercentage(this.getSecondsElapsed(), this.mDuration); final float u = 1 - percentageDone; final float tt = percentageDone*percentageDone; final float uu = u*u; final float ut2 = 2 * u * percentageDone; /* Formula: * ((1-t)^2 * p1) + (2*(t)*(1-t) * p2) + ((t^2) * p3) */ final float x = (uu * this.mX1) + (ut2 * this.mX2) + (tt * this.mX3); final float y = (uu * this.mY1) + (ut2 * this.mY2) + (tt * this.mY3); pEntity.setPosition(x, y); } @Override protected void onManagedInitialize(final IEntity pEntity) { } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/QuadraticBezierMoveModifier.java
Java
lgpl
2,966
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:04:21 - 30.08.2010 */ public class MoveYModifier extends SingleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public MoveYModifier(final float pDuration, final float pFromY, final float pToY) { this(pDuration, pFromY, pToY, null, IEaseFunction.DEFAULT); } public MoveYModifier(final float pDuration, final float pFromY, final float pToY, final IEaseFunction pEaseFunction) { this(pDuration, pFromY, pToY, null, pEaseFunction); } public MoveYModifier(final float pDuration, final float pFromY, final float pToY, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromY, pToY, pEntityModifierListener, IEaseFunction.DEFAULT); } public MoveYModifier(final float pDuration, final float pFromY, final float pToY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromY, pToY, pEntityModifierListener, pEaseFunction); } protected MoveYModifier(final MoveYModifier pMoveYModifier) { super(pMoveYModifier); } @Override public MoveYModifier deepCopy(){ return new MoveYModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValue(final IEntity pEntity, final float pY) { pEntity.setPosition(pEntity.getX(), pY); } @Override protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pY) { pEntity.setPosition(pEntity.getX(), pY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/MoveYModifier.java
Java
lgpl
2,746
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; /** * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:15:52 - 10.08.2011 */ public class MoveByModifier extends DoubleValueChangeEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public MoveByModifier(final float pDuration, final float pX, final float pY) { super(pDuration, pX, pY); } public MoveByModifier(final float pDuration, final float pX, final float pY, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pX, pY, pEntityModifierListener); } protected MoveByModifier(final DoubleValueChangeEntityModifier pDoubleValueChangeEntityModifier) { super(pDoubleValueChangeEntityModifier); } @Override public MoveByModifier deepCopy(){ return new MoveByModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onChangeValues(final float pSecondsElapsed, final IEntity pEntity, final float pX, final float pY) { pEntity.setPosition(pEntity.getX() + pX, pEntity.getY() + pY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/MoveByModifier.java
Java
lgpl
2,104
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:39:50 - 29.06.2010 */ public class ColorModifier extends TripleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue) { this(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, null, IEaseFunction.DEFAULT); } public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IEaseFunction pEaseFunction) { this(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, null, pEaseFunction); } public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pEntityModifierListener, IEaseFunction.DEFAULT); } public ColorModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pEntityModifierListener, pEaseFunction); } protected ColorModifier(final ColorModifier pColorModifier) { super(pColorModifier); } @Override public ColorModifier deepCopy(){ return new ColorModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValues(final IEntity pEntity, final float pRed, final float pGreen, final float pBlue) { pEntity.setColor(pRed, pGreen, pBlue); } @Override protected void onSetValues(final IEntity pEntity, final float pPerctentageDone, final float pRed, final float pGreen, final float pBlue) { pEntity.setColor(pRed, pGreen, pBlue); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/ColorModifier.java
Java
lgpl
3,387
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.IMatcher; import org.anddev.andengine.util.modifier.IModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:17:50 - 19.03.2010 */ public interface IEntityModifier extends IModifier<IEntity> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== @Override public IEntityModifier deepCopy() throws DeepCopyNotSupportedException; // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface IEntityModifierListener extends IModifierListener<IEntity>{ // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== } public interface IEntityModifierMatcher extends IMatcher<IModifier<IEntity>> { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/IEntityModifier.java
Java
lgpl
1,714
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 23:37:53 - 19.03.2010 */ public class ScaleModifier extends DoubleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale) { this(pDuration, pFromScale, pToScale, null, IEaseFunction.DEFAULT); } public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale, final IEaseFunction pEaseFunction) { this(pDuration, pFromScale, pToScale, null, pEaseFunction); } public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale, final IEntityModifierListener pEntityModifierListener) { this(pDuration, pFromScale, pToScale, pFromScale, pToScale, pEntityModifierListener, IEaseFunction.DEFAULT); } public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { this(pDuration, pFromScale, pToScale, pFromScale, pToScale, pEntityModifierListener, pEaseFunction); } public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY) { this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, null, IEaseFunction.DEFAULT); } public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEaseFunction pEaseFunction) { this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, null, pEaseFunction); } public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pEntityModifierListener, IEaseFunction.DEFAULT); } public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pEntityModifierListener, pEaseFunction); } protected ScaleModifier(final ScaleModifier pScaleModifier) { super(pScaleModifier); } @Override public ScaleModifier deepCopy(){ return new ScaleModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValues(final IEntity pEntity, final float pScaleA, final float pScaleB) { pEntity.setScale(pScaleA, pScaleB); } @Override protected void onSetValues(final IEntity pEntity, final float pPercentageDone, final float pScaleA, final float pScaleB) { pEntity.setScale(pScaleA, pScaleB); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/ScaleModifier.java
Java
lgpl
4,088
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:12:52 - 19.03.2010 */ public class RotationModifier extends SingleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public RotationModifier(final float pDuration, final float pFromRotation, final float pToRotation) { this(pDuration, pFromRotation, pToRotation, null, IEaseFunction.DEFAULT); } public RotationModifier(final float pDuration, final float pFromRotation, final float pToRotation, final IEaseFunction pEaseFunction) { this(pDuration, pFromRotation, pToRotation, null, pEaseFunction); } public RotationModifier(final float pDuration, final float pFromRotation, final float pToRotation, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromRotation, pToRotation, pEntityModifierListener, IEaseFunction.DEFAULT); } public RotationModifier(final float pDuration, final float pFromRotation, final float pToRotation, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromRotation, pToRotation, pEntityModifierListener, pEaseFunction); } protected RotationModifier(final RotationModifier pRotationModifier) { super(pRotationModifier); } @Override public RotationModifier deepCopy(){ return new RotationModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValue(final IEntity pEntity, final float pRotation) { pEntity.setRotation(pRotation); } @Override protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pRotation) { pEntity.setRotation(pRotation); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/RotationModifier.java
Java
lgpl
2,887
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.entity.modifier.CubicBezierMoveModifier; import org.anddev.andengine.util.MathUtils; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * <p>A {@link CubicBezierMoveModifier} that rotates the entity so it faces the direction of travel.</p> * * <p>(c) 2010 Nicolas Gramlich<br> * (c) 2011 Zynga Inc.</p> * * @author Scott Kennedy * @author Pawel Plewa * @author Nicolas Gramlich * @since 12:54:00 - 17.08.2011 */ public class RotateCubicBezierMoveModifier extends CubicBezierMoveModifier { public RotateCubicBezierMoveModifier(final float pDuration, final float pX1, final float pY1, final float pX2, final float pY2, final float pX3, final float pY3, final float pX4, final float pY4, final IEaseFunction pEaseFunction) { super(pDuration, pX1, pY1, pX2, pY2, pX3, pY3, pX4, pY4, pEaseFunction); } @Override protected void onManagedUpdate(final float pSecondsElapsed, final IEntity pEntity) { final float startX = pEntity.getX(); final float startY = pEntity.getY(); super.onManagedUpdate(pSecondsElapsed, pEntity); final float deltaX = pEntity.getX() - startX; final float deltaY = pEntity.getY() - startY; pEntity.setRotation(MathUtils.radToDeg(MathUtils.atan2(deltaY, deltaX)) + 90); } }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/RotateCubicBezierMoveModifier.java
Java
lgpl
1,490
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseDoubleValueSpanModifier; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 23:29:22 - 19.03.2010 */ public abstract class DoubleValueSpanEntityModifier extends BaseDoubleValueSpanModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public DoubleValueSpanEntityModifier(final float pDuration, final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB) { super(pDuration, pFromValueA, pToValueA, pFromValueB, pToValueB); } public DoubleValueSpanEntityModifier(final float pDuration, final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final IEaseFunction pEaseFunction) { super(pDuration, pFromValueA, pToValueA, pFromValueB, pToValueB, pEaseFunction); } public DoubleValueSpanEntityModifier(final float pDuration, final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromValueA, pToValueA, pFromValueB, pToValueB, pEntityModifierListener); } public DoubleValueSpanEntityModifier(final float pDuration, final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromValueA, pToValueA, pFromValueB, pToValueB, pEntityModifierListener, pEaseFunction); } protected DoubleValueSpanEntityModifier(final DoubleValueSpanEntityModifier pDoubleValueSpanEntityModifier) { super(pDoubleValueSpanEntityModifier); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/DoubleValueSpanEntityModifier.java
Java
lgpl
2,931
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.IModifier; import org.anddev.andengine.util.modifier.SequenceModifier; import org.anddev.andengine.util.modifier.SequenceModifier.ISubSequenceModifierListener; import org.anddev.andengine.util.modifier.ease.IEaseFunction; import android.util.FloatMath; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:50:02 - 16.06.2010 */ public class PathModifier extends EntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final SequenceModifier<IEntity> mSequenceModifier; private IPathModifierListener mPathModifierListener; private final Path mPath; // =========================================================== // Constructors // =========================================================== public PathModifier(final float pDuration, final Path pPath) { this(pDuration, pPath, null, null, IEaseFunction.DEFAULT); } public PathModifier(final float pDuration, final Path pPath, final IEaseFunction pEaseFunction) { this(pDuration, pPath, null, null, pEaseFunction); } public PathModifier(final float pDuration, final Path pPath, final IEntityModifierListener pEntityModiferListener) { this(pDuration, pPath, pEntityModiferListener, null, IEaseFunction.DEFAULT); } public PathModifier(final float pDuration, final Path pPath, final IPathModifierListener pPathModifierListener) { this(pDuration, pPath, null, pPathModifierListener, IEaseFunction.DEFAULT); } public PathModifier(final float pDuration, final Path pPath, final IPathModifierListener pPathModifierListener, final IEaseFunction pEaseFunction) { this(pDuration, pPath, null, pPathModifierListener, pEaseFunction); } public PathModifier(final float pDuration, final Path pPath, final IEntityModifierListener pEntityModiferListener, final IEaseFunction pEaseFunction) { this(pDuration, pPath, pEntityModiferListener, null, pEaseFunction); } public PathModifier(final float pDuration, final Path pPath, final IEntityModifierListener pEntityModiferListener, final IPathModifierListener pPathModifierListener) throws IllegalArgumentException { this(pDuration, pPath, pEntityModiferListener, pPathModifierListener, IEaseFunction.DEFAULT); } public PathModifier(final float pDuration, final Path pPath, final IEntityModifierListener pEntityModiferListener, final IPathModifierListener pPathModifierListener, final IEaseFunction pEaseFunction) throws IllegalArgumentException { super(pEntityModiferListener); final int pathSize = pPath.getSize(); if (pathSize < 2) { throw new IllegalArgumentException("Path needs at least 2 waypoints!"); } this.mPath = pPath; this.mPathModifierListener = pPathModifierListener; final MoveModifier[] moveModifiers = new MoveModifier[pathSize - 1]; final float[] coordinatesX = pPath.getCoordinatesX(); final float[] coordinatesY = pPath.getCoordinatesY(); final float velocity = pPath.getLength() / pDuration; final int modifierCount = moveModifiers.length; for(int i = 0; i < modifierCount; i++) { final float duration = pPath.getSegmentLength(i) / velocity; moveModifiers[i] = new MoveModifier(duration, coordinatesX[i], coordinatesX[i + 1], coordinatesY[i], coordinatesY[i + 1], null, pEaseFunction); } /* Create a new SequenceModifier and register the listeners that * call through to mEntityModifierListener and mPathModifierListener. */ this.mSequenceModifier = new SequenceModifier<IEntity>( new ISubSequenceModifierListener<IEntity>() { @Override public void onSubSequenceStarted(final IModifier<IEntity> pModifier, final IEntity pEntity, final int pIndex) { if(PathModifier.this.mPathModifierListener != null) { PathModifier.this.mPathModifierListener.onPathWaypointStarted(PathModifier.this, pEntity, pIndex); } } @Override public void onSubSequenceFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity, final int pIndex) { if(PathModifier.this.mPathModifierListener != null) { PathModifier.this.mPathModifierListener.onPathWaypointFinished(PathModifier.this, pEntity, pIndex); } } }, new IEntityModifierListener() { @Override public void onModifierStarted(final IModifier<IEntity> pModifier, final IEntity pEntity) { PathModifier.this.onModifierStarted(pEntity); if(PathModifier.this.mPathModifierListener != null) { PathModifier.this.mPathModifierListener.onPathStarted(PathModifier.this, pEntity); } } @Override public void onModifierFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity) { PathModifier.this.onModifierFinished(pEntity); if(PathModifier.this.mPathModifierListener != null) { PathModifier.this.mPathModifierListener.onPathFinished(PathModifier.this, pEntity); } } }, moveModifiers ); } protected PathModifier(final PathModifier pPathModifier) throws DeepCopyNotSupportedException { this.mPath = pPathModifier.mPath.deepCopy(); this.mSequenceModifier = pPathModifier.mSequenceModifier.deepCopy(); } @Override public PathModifier deepCopy() throws DeepCopyNotSupportedException { return new PathModifier(this); } // =========================================================== // Getter & Setter // =========================================================== public Path getPath() { return this.mPath; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public boolean isFinished() { return this.mSequenceModifier.isFinished(); } @Override public float getSecondsElapsed() { return this.mSequenceModifier.getSecondsElapsed(); } @Override public float getDuration() { return this.mSequenceModifier.getDuration(); } public IPathModifierListener getPathModifierListener() { return this.mPathModifierListener; } public void setPathModifierListener(final IPathModifierListener pPathModifierListener) { this.mPathModifierListener = pPathModifierListener; } @Override public void reset() { this.mSequenceModifier.reset(); } @Override public float onUpdate(final float pSecondsElapsed, final IEntity pEntity) { return this.mSequenceModifier.onUpdate(pSecondsElapsed, pEntity); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface IPathModifierListener { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== public void onPathStarted(final PathModifier pPathModifier, final IEntity pEntity); public void onPathWaypointStarted(final PathModifier pPathModifier, final IEntity pEntity, final int pWaypointIndex); public void onPathWaypointFinished(final PathModifier pPathModifier, final IEntity pEntity, final int pWaypointIndex); public void onPathFinished(final PathModifier pPathModifier, final IEntity pEntity); } public static class Path { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float[] mCoordinatesX; private final float[] mCoordinatesY; private int mIndex; private boolean mLengthChanged = false; private float mLength; // =========================================================== // Constructors // =========================================================== public Path(final int pLength) { this.mCoordinatesX = new float[pLength]; this.mCoordinatesY = new float[pLength]; this.mIndex = 0; this.mLengthChanged = false; } public Path(final float[] pCoordinatesX, final float[] pCoordinatesY) throws IllegalArgumentException { if (pCoordinatesX.length != pCoordinatesY.length) { throw new IllegalArgumentException("Coordinate-Arrays must have the same length."); } this.mCoordinatesX = pCoordinatesX; this.mCoordinatesY = pCoordinatesY; this.mIndex = pCoordinatesX.length; this.mLengthChanged = true; } public Path(final Path pPath) { final int size = pPath.getSize(); this.mCoordinatesX = new float[size]; this.mCoordinatesY = new float[size]; System.arraycopy(pPath.mCoordinatesX, 0, this.mCoordinatesX, 0, size); System.arraycopy(pPath.mCoordinatesY, 0, this.mCoordinatesY, 0, size); this.mIndex = pPath.mIndex; this.mLengthChanged = pPath.mLengthChanged; this.mLength = pPath.mLength; } public Path deepCopy() { return new Path(this); } // =========================================================== // Getter & Setter // =========================================================== public Path to(final float pX, final float pY) { this.mCoordinatesX[this.mIndex] = pX; this.mCoordinatesY[this.mIndex] = pY; this.mIndex++; this.mLengthChanged = true; return this; } public float[] getCoordinatesX() { return this.mCoordinatesX; } public float[] getCoordinatesY() { return this.mCoordinatesY; } public int getSize() { return this.mCoordinatesX.length; } public float getLength() { if(this.mLengthChanged) { this.updateLength(); } return this.mLength; } public float getSegmentLength(final int pSegmentIndex) { final float[] coordinatesX = this.mCoordinatesX; final float[] coordinatesY = this.mCoordinatesY; final int nextSegmentIndex = pSegmentIndex + 1; final float dx = coordinatesX[pSegmentIndex] - coordinatesX[nextSegmentIndex]; final float dy = coordinatesY[pSegmentIndex] - coordinatesY[nextSegmentIndex]; return FloatMath.sqrt(dx * dx + dy * dy); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== private void updateLength() { float length = 0.0f; for(int i = this.mIndex - 2; i >= 0; i--) { length += this.getSegmentLength(i); } this.mLength = length; } // =========================================================== // Inner and Anonymous Classes // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/PathModifier.java
Java
lgpl
11,591
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.LoopModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:42:13 - 03.09.2010 */ public class LoopEntityModifier extends LoopModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public LoopEntityModifier(final IEntityModifier pEntityModifier) { super(pEntityModifier); } public LoopEntityModifier(final IEntityModifier pEntityModifier, final int pLoopCount) { super(pEntityModifier, pLoopCount); } public LoopEntityModifier(final IEntityModifier pEntityModifier, final int pLoopCount, final ILoopEntityModifierListener pLoopModifierListener) { super(pEntityModifier, pLoopCount, pLoopModifierListener); } public LoopEntityModifier(final IEntityModifier pEntityModifier, final int pLoopCount, final IEntityModifierListener pEntityModifierListener) { super(pEntityModifier, pLoopCount, pEntityModifierListener); } public LoopEntityModifier(final IEntityModifierListener pEntityModifierListener, final int pLoopCount, final ILoopEntityModifierListener pLoopModifierListener, final IEntityModifier pEntityModifier) { super(pEntityModifier, pLoopCount, pLoopModifierListener, pEntityModifierListener); } protected LoopEntityModifier(final LoopEntityModifier pLoopEntityModifier) throws DeepCopyNotSupportedException { super(pLoopEntityModifier); } @Override public LoopEntityModifier deepCopy() throws DeepCopyNotSupportedException { return new LoopEntityModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== public interface ILoopEntityModifierListener extends ILoopModifierListener<IEntity> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/LoopEntityModifier.java
Java
lgpl
3,106
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseTripleValueSpanModifier; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:35:18 - 29.06.2010 */ public abstract class TripleValueSpanEntityModifier extends BaseTripleValueSpanModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public TripleValueSpanEntityModifier(final float pDuration, final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final float pFromValueC, final float pToValueC, final IEaseFunction pEaseFunction) { super(pDuration, pFromValueA, pToValueA, pFromValueB, pToValueB, pFromValueC, pToValueC, pEaseFunction); } public TripleValueSpanEntityModifier(final float pDuration, final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final float pFromValueC, final float pToValueC, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromValueA, pToValueA, pFromValueB, pToValueB, pFromValueC, pToValueC, pEntityModifierListener, pEaseFunction); } protected TripleValueSpanEntityModifier(final TripleValueSpanEntityModifier pTripleValueSpanEntityModifier) { super(pTripleValueSpanEntityModifier); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/TripleValueSpanEntityModifier.java
Java
lgpl
2,525
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseSingleValueChangeModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:34:35 - 17.06.2010 */ public abstract class SingleValueChangeEntityModifier extends BaseSingleValueChangeModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SingleValueChangeEntityModifier(final float pDuration, final float pValueChange) { super(pDuration, pValueChange); } public SingleValueChangeEntityModifier(final float pDuration, final float pValueChange, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pValueChange, pEntityModifierListener); } protected SingleValueChangeEntityModifier(final SingleValueChangeEntityModifier pSingleValueChangeEntityModifier) { super(pSingleValueChangeEntityModifier); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/SingleValueChangeEntityModifier.java
Java
lgpl
2,028
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:03:12 - 08.06.2010 */ public class FadeInModifier extends AlphaModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public FadeInModifier(final float pDuration) { super(pDuration, 0.0f, 1.0f, IEaseFunction.DEFAULT); } public FadeInModifier(final float pDuration, final IEaseFunction pEaseFunction) { super(pDuration, 0.0f, 1.0f, pEaseFunction); } public FadeInModifier(final float pDuration, final IEntityModifierListener pEntityModifierListener) { super(pDuration, 0.0f, 1.0f, pEntityModifierListener, IEaseFunction.DEFAULT); } public FadeInModifier(final float pDuration, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, 0.0f, 1.0f, pEntityModifierListener, pEaseFunction); } protected FadeInModifier(final FadeInModifier pFadeInModifier) { super(pFadeInModifier); } @Override public FadeInModifier deepCopy() { return new FadeInModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/FadeInModifier.java
Java
lgpl
2,231
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Pawel Plewa * @author Nicolas Gramlich * @since 23:24:26 - 16.07.2011 */ public class CubicBezierMoveModifier extends DurationEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mX1; private final float mY1; private final float mX2; private final float mY2; private final float mX3; private final float mY3; private final float mX4; private final float mY4; private final IEaseFunction mEaseFunction; // =========================================================== // Constructors // =========================================================== /** * @param pDuration * @param pX1 x coordinate of the start point. * @param pY1 y coordinate of the start point. * @param pX2 x coordinate of the first control point. * @param pY2 y coordinate of the first control point. * @param pX3 x coordinate of the second control point. * @param pY3 y coordinate of the second control point. * @param pX4 x coordinate of the end point. * @param pY4 y coordinate of the end point. * @param pEaseFunction */ public CubicBezierMoveModifier(final float pDuration, final float pX1, final float pY1, final float pX2, final float pY2, final float pX3, final float pY3, final float pX4, final float pY4, final IEaseFunction pEaseFunction) { super(pDuration); this.mX1 = pX1; this.mY1 = pY1; this.mX2 = pX2; this.mY2 = pY2; this.mX3 = pX3; this.mY3 = pY3; this.mX4 = pX4; this.mY4 = pY4; this.mEaseFunction = pEaseFunction; } @Override public CubicBezierMoveModifier deepCopy() { return new CubicBezierMoveModifier(this.mDuration, this.mX1, this.mY1, this.mX2, this.mY2, this.mX3, this.mY3, this.mX4, this.mY4, this.mEaseFunction); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedUpdate(final float pSecondsElapsed, final IEntity pEntity) { final float percentageDone = this.mEaseFunction.getPercentage(this.getSecondsElapsed(), this.mDuration); final float u = 1 - percentageDone; final float tt = percentageDone * percentageDone; final float uu = u * u; final float uuu = uu * u; final float ttt = tt * percentageDone; final float ut3 = 3 * uu * percentageDone; final float utt3 = 3 * u * tt; /* * Formula: ((1-t)^3 * p1) + (3*(t)*(1-t)^2 * p2) + (3*(t^2)*(1-t) * p3) + (t^3 * p4) */ final float x = (uuu * this.mX1) + (ut3 * this.mX2) + (utt3 * this.mX3) + (ttt * this.mX4); final float y = (uuu * this.mY1) + (ut3 * this.mY2) + (utt3 * this.mY3) + (ttt * this.mY4); pEntity.setPosition(x, y); } @Override protected void onManagedInitialize(final IEntity pEntity) { } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/CubicBezierMoveModifier.java
Java
lgpl
3,782
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:53:30 - 06.07.2010 */ public class ScaleAtModifier extends ScaleModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mScaleCenterX; private final float mScaleCenterY; // =========================================================== // Constructors // =========================================================== public ScaleAtModifier(final float pDuration, final float pFromScale, final float pToScale, final float pScaleCenterX, final float pScaleCenterY) { this(pDuration, pFromScale, pToScale, pScaleCenterX, pScaleCenterY, IEaseFunction.DEFAULT); } public ScaleAtModifier(final float pDuration, final float pFromScale, final float pToScale, final float pScaleCenterX, final float pScaleCenterY, final IEaseFunction pEaseFunction) { this(pDuration, pFromScale, pToScale, pScaleCenterX, pScaleCenterY, null, pEaseFunction); } public ScaleAtModifier(final float pDuration, final float pFromScale, final float pToScale, final float pScaleCenterX, final float pScaleCenterY, final IEntityModifierListener pEntityModifierListener) { this(pDuration, pFromScale, pToScale, pScaleCenterX, pScaleCenterY, pEntityModifierListener, IEaseFunction.DEFAULT); } public ScaleAtModifier(final float pDuration, final float pFromScale, final float pToScale, final float pScaleCenterX, final float pScaleCenterY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { this(pDuration, pFromScale, pToScale, pFromScale, pToScale, pScaleCenterX, pScaleCenterY, pEntityModifierListener, pEaseFunction); } public ScaleAtModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final float pScaleCenterX, final float pScaleCenterY) { this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pScaleCenterX, pScaleCenterY, IEaseFunction.DEFAULT); } public ScaleAtModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final float pScaleCenterX, final float pScaleCenterY, final IEaseFunction pEaseFunction) { this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pScaleCenterX, pScaleCenterY, null, pEaseFunction); } public ScaleAtModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final float pScaleCenterX, final float pScaleCenterY, final IEntityModifierListener pEntityModifierListener) { this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pScaleCenterX, pScaleCenterY, pEntityModifierListener, IEaseFunction.DEFAULT); } public ScaleAtModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final float pScaleCenterX, final float pScaleCenterY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pEntityModifierListener, pEaseFunction); this.mScaleCenterX = pScaleCenterX; this.mScaleCenterY = pScaleCenterY; } protected ScaleAtModifier(final ScaleAtModifier pScaleAtModifier) { super(pScaleAtModifier); this.mScaleCenterX = pScaleAtModifier.mScaleCenterX; this.mScaleCenterY = pScaleAtModifier.mScaleCenterY; } @Override public ScaleAtModifier deepCopy(){ return new ScaleAtModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedInitialize(final IEntity pEntity) { super.onManagedInitialize(pEntity); pEntity.setScaleCenter(this.mScaleCenterX, this.mScaleCenterY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/ScaleAtModifier.java
Java
lgpl
4,821
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ParallelModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:40:31 - 03.09.2010 */ public class ParallelEntityModifier extends ParallelModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ParallelEntityModifier(final IEntityModifier... pEntityModifiers) throws IllegalArgumentException { super(pEntityModifiers); } public ParallelEntityModifier(final IEntityModifierListener pEntityModifierListener, final IEntityModifier... pEntityModifiers) throws IllegalArgumentException { super(pEntityModifierListener, pEntityModifiers); } protected ParallelEntityModifier(final ParallelEntityModifier pParallelShapeModifier) throws DeepCopyNotSupportedException { super(pParallelShapeModifier); } @Override public ParallelEntityModifier deepCopy() throws DeepCopyNotSupportedException { return new ParallelEntityModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/ParallelEntityModifier.java
Java
lgpl
2,147
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseDurationModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:10:42 - 19.03.2010 */ public abstract class DurationEntityModifier extends BaseDurationModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public DurationEntityModifier(final float pDuration) { super(pDuration); } public DurationEntityModifier(final float pDuration, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pEntityModifierListener); } protected DurationEntityModifier(final DurationEntityModifier pDurationEntityModifier) { super(pDurationEntityModifier); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/DurationEntityModifier.java
Java
lgpl
1,867
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:53:16 - 03.09.2010 */ public abstract class EntityModifier extends BaseModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public EntityModifier() { super(); } public EntityModifier(final IEntityModifierListener pEntityModifierListener) { super(pEntityModifierListener); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/EntityModifier.java
Java
lgpl
1,631
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.SequenceModifier; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:41:15 - 03.09.2010 */ public class SequenceEntityModifier extends SequenceModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SequenceEntityModifier(final IEntityModifier... pEntityModifiers) throws IllegalArgumentException { super(pEntityModifiers); } public SequenceEntityModifier(final ISubSequenceShapeModifierListener pSubSequenceShapeModifierListener, final IEntityModifier... pEntityModifiers) throws IllegalArgumentException { super(pSubSequenceShapeModifierListener, pEntityModifiers); } public SequenceEntityModifier(final IEntityModifierListener pEntityModifierListener, final IEntityModifier... pEntityModifiers) throws IllegalArgumentException { super(pEntityModifierListener, pEntityModifiers); } public SequenceEntityModifier(final ISubSequenceShapeModifierListener pSubSequenceShapeModifierListener, final IEntityModifierListener pEntityModifierListener, final IEntityModifier... pEntityModifiers) throws IllegalArgumentException { super(pSubSequenceShapeModifierListener, pEntityModifierListener, pEntityModifiers); } protected SequenceEntityModifier(final SequenceEntityModifier pSequenceShapeModifier) throws DeepCopyNotSupportedException { super(pSequenceShapeModifier); } @Override public SequenceEntityModifier deepCopy() throws DeepCopyNotSupportedException { return new SequenceEntityModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== public interface ISubSequenceShapeModifierListener extends ISubSequenceModifierListener<IEntity> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== } }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/SequenceEntityModifier.java
Java
lgpl
3,139
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:12:52 - 19.03.2010 */ public class MoveModifier extends DoubleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public MoveModifier(final float pDuration, final float pFromX, final float pToX, final float pFromY, final float pToY) { this(pDuration, pFromX, pToX, pFromY, pToY, null, IEaseFunction.DEFAULT); } public MoveModifier(final float pDuration, final float pFromX, final float pToX, final float pFromY, final float pToY, final IEaseFunction pEaseFunction) { this(pDuration, pFromX, pToX, pFromY, pToY, null, pEaseFunction); } public MoveModifier(final float pDuration, final float pFromX, final float pToX, final float pFromY, final float pToY, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromX, pToX, pFromY, pToY, pEntityModifierListener, IEaseFunction.DEFAULT); } public MoveModifier(final float pDuration, final float pFromX, final float pToX, final float pFromY, final float pToY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromX, pToX, pFromY, pToY, pEntityModifierListener, pEaseFunction); } protected MoveModifier(final MoveModifier pMoveModifier) { super(pMoveModifier); } @Override public MoveModifier deepCopy(){ return new MoveModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValues(final IEntity pEntity, final float pX, final float pY) { pEntity.setPosition(pX, pY); } @Override protected void onSetValues(final IEntity pEntity, final float pPercentageDone, final float pX, final float pY) { pEntity.setPosition(pX, pY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/MoveModifier.java
Java
lgpl
2,953
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:03:12 - 08.06.2010 */ public class FadeOutModifier extends AlphaModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public FadeOutModifier(final float pDuration) { super(pDuration, 1.0f, 0.0f, IEaseFunction.DEFAULT); } public FadeOutModifier(final float pDuration, final IEaseFunction pEaseFunction) { super(pDuration, 1.0f, 0.0f, pEaseFunction); } public FadeOutModifier(final float pDuration, final IEntityModifierListener pEntityModifierListener) { super(pDuration, 1.0f, 0.0f, pEntityModifierListener, IEaseFunction.DEFAULT); } public FadeOutModifier(final float pDuration, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, 1.0f, 0.0f, pEntityModifierListener, pEaseFunction); } protected FadeOutModifier(final FadeOutModifier pFadeOutModifier) { super(pFadeOutModifier); } @Override public FadeOutModifier deepCopy() { return new FadeOutModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/FadeOutModifier.java
Java
lgpl
2,242
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ModifierList; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:19:18 - 24.12.2010 */ public class EntityModifierList extends ModifierList<IEntity> { // =========================================================== // Constants // =========================================================== private static final long serialVersionUID = 161652765736600082L; // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public EntityModifierList(final IEntity pTarget) { super(pTarget); } public EntityModifierList(final IEntity pTarget, final int pCapacity) { super(pTarget, pCapacity); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/EntityModifierList.java
Java
lgpl
1,689
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseSingleValueSpanModifier; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 23:29:22 - 19.03.2010 */ public abstract class SingleValueSpanEntityModifier extends BaseSingleValueSpanModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public SingleValueSpanEntityModifier(final float pDuration, final float pFromValue, final float pToValue) { super(pDuration, pFromValue, pToValue); } public SingleValueSpanEntityModifier(final float pDuration, final float pFromValue, final float pToValue, final IEaseFunction pEaseFunction) { super(pDuration, pFromValue, pToValue, pEaseFunction); } public SingleValueSpanEntityModifier(final float pDuration, final float pFromValue, final float pToValue, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromValue, pToValue, pEntityModifierListener); } public SingleValueSpanEntityModifier(final float pDuration, final float pFromValue, final float pToValue, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromValue, pToValue, pEntityModifierListener, pEaseFunction); } protected SingleValueSpanEntityModifier(final SingleValueSpanEntityModifier pSingleValueSpanEntityModifier) { super(pSingleValueSpanEntityModifier); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/SingleValueSpanEntityModifier.java
Java
lgpl
2,627
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.BaseDoubleValueChangeModifier; /** * (c) Zynga 2011 * * @author Nicolas Gramlich <ngramlich@zynga.com> * @since 14:27:48 - 10.08.2011 */ public abstract class DoubleValueChangeEntityModifier extends BaseDoubleValueChangeModifier<IEntity> implements IEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public DoubleValueChangeEntityModifier(float pDuration, float pValueChangeA, float pValueChangeB) { super(pDuration, pValueChangeA, pValueChangeB); } public DoubleValueChangeEntityModifier(float pDuration, float pValueChangeA, float pValueChangeB, IEntityModifierListener pModifierListener) { super(pDuration, pValueChangeA, pValueChangeB, pModifierListener); } public DoubleValueChangeEntityModifier(DoubleValueChangeEntityModifier pDoubleValueChangeEntityModifier) { super(pDoubleValueChangeEntityModifier); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/DoubleValueChangeEntityModifier.java
Java
lgpl
1,986
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 22:55:13 - 19.03.2010 */ public class DelayModifier extends DurationEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public DelayModifier(final float pDuration, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pEntityModifierListener); } public DelayModifier(final float pDuration) { super(pDuration); } protected DelayModifier(final DelayModifier pDelayModifier) { super(pDelayModifier); } @Override public DelayModifier deepCopy(){ return new DelayModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedInitialize(final IEntity pEntity) { } @Override protected void onManagedUpdate(final float pSecondsElapsed, final IEntity pEntity) { } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/DelayModifier.java
Java
lgpl
1,973
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:03:22 - 30.08.2010 */ public class MoveXModifier extends SingleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public MoveXModifier(final float pDuration, final float pFromX, final float pToX) { this(pDuration, pFromX, pToX, null, IEaseFunction.DEFAULT); } public MoveXModifier(final float pDuration, final float pFromX, final float pToX, final IEaseFunction pEaseFunction) { this(pDuration, pFromX, pToX, null, pEaseFunction); } public MoveXModifier(final float pDuration, final float pFromX, final float pToX, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromX, pToX, pEntityModifierListener, IEaseFunction.DEFAULT); } public MoveXModifier(final float pDuration, final float pFromX, final float pToX, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromX, pToX, pEntityModifierListener, pEaseFunction); } protected MoveXModifier(final MoveXModifier pMoveXModifier) { super(pMoveXModifier); } @Override public MoveXModifier deepCopy(){ return new MoveXModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValue(final IEntity pEntity, final float pX) { pEntity.setPosition(pX, pEntity.getY()); } @Override protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pX) { pEntity.setPosition(pX, pEntity.getY()); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/MoveXModifier.java
Java
lgpl
2,746
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:59:38 - 06.07.2010 */ public class RotationAtModifier extends RotationModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mRotationCenterX; private final float mRotationCenterY; // =========================================================== // Constructors // =========================================================== public RotationAtModifier(final float pDuration, final float pFromRotation, final float pToRotation, final float pRotationCenterX, final float pRotationCenterY) { super(pDuration, pFromRotation, pToRotation, IEaseFunction.DEFAULT); this.mRotationCenterX = pRotationCenterX; this.mRotationCenterY = pRotationCenterY; } public RotationAtModifier(final float pDuration, final float pFromRotation, final float pToRotation, final float pRotationCenterX, final float pRotationCenterY, final IEaseFunction pEaseFunction) { super(pDuration, pFromRotation, pToRotation, pEaseFunction); this.mRotationCenterX = pRotationCenterX; this.mRotationCenterY = pRotationCenterY; } public RotationAtModifier(final float pDuration, final float pFromRotation, final float pToRotation, final float pRotationCenterX, final float pRotationCenterY, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromRotation, pToRotation, pEntityModifierListener, IEaseFunction.DEFAULT); this.mRotationCenterX = pRotationCenterX; this.mRotationCenterY = pRotationCenterY; } public RotationAtModifier(final float pDuration, final float pFromRotation, final float pToRotation, final float pRotationCenterX, final float pRotationCenterY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromRotation, pToRotation, pEntityModifierListener, pEaseFunction); this.mRotationCenterX = pRotationCenterX; this.mRotationCenterY = pRotationCenterY; } protected RotationAtModifier(final RotationAtModifier pRotationAtModifier) { super(pRotationAtModifier); this.mRotationCenterX = pRotationAtModifier.mRotationCenterX; this.mRotationCenterY = pRotationAtModifier.mRotationCenterY; } @Override public RotationAtModifier deepCopy(){ return new RotationAtModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedInitialize(final IEntity pEntity) { super.onManagedInitialize(pEntity); pEntity.setRotationCenter(this.mRotationCenterX, this.mRotationCenterY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/RotationAtModifier.java
Java
lgpl
3,601
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:12:52 - 19.03.2010 */ public class RotationByModifier extends SingleValueChangeEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public RotationByModifier(final float pDuration, final float pRotation) { super(pDuration, pRotation); } public RotationByModifier(final float pDuration, final float pRotation, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pRotation, pEntityModifierListener); } protected RotationByModifier(final RotationByModifier pRotationByModifier) { super(pRotationByModifier); } @Override public RotationByModifier deepCopy(){ return new RotationByModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onChangeValue(final float pSecondsElapsed, final IEntity pEntity, final float pRotation) { pEntity.setRotation(pEntity.getRotation() + pRotation); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/RotationByModifier.java
Java
lgpl
2,090
package org.anddev.andengine.entity.modifier; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.util.modifier.ease.IEaseFunction; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 23:13:01 - 19.03.2010 */ public class AlphaModifier extends SingleValueSpanEntityModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha) { this(pDuration, pFromAlpha, pToAlpha, null, IEaseFunction.DEFAULT); } public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha, final IEaseFunction pEaseFunction) { this(pDuration, pFromAlpha, pToAlpha, null, pEaseFunction); } public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromAlpha, pToAlpha, pEntityModifierListener, IEaseFunction.DEFAULT); } public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) { super(pDuration, pFromAlpha, pToAlpha, pEntityModifierListener, pEaseFunction); } protected AlphaModifier(final AlphaModifier pAlphaModifier) { super(pAlphaModifier); } @Override public AlphaModifier deepCopy(){ return new AlphaModifier(this); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValue(final IEntity pEntity, final float pAlpha) { pEntity.setAlpha(pAlpha); } @Override protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pAlpha) { pEntity.setAlpha(pAlpha); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/modifier/AlphaModifier.java
Java
lgpl
2,788
package org.anddev.andengine.entity; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.engine.handler.IUpdateHandler; import org.anddev.andengine.engine.handler.UpdateHandlerList; import org.anddev.andengine.entity.modifier.EntityModifierList; import org.anddev.andengine.entity.modifier.IEntityModifier; import org.anddev.andengine.entity.modifier.IEntityModifier.IEntityModifierMatcher; import org.anddev.andengine.util.ParameterCallable; import org.anddev.andengine.util.SmartList; import org.anddev.andengine.util.Transformation; import org.anddev.andengine.util.constants.Constants; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:00:48 - 08.03.2010 */ public class Entity implements IEntity { // =========================================================== // Constants // =========================================================== private static final int CHILDREN_CAPACITY_DEFAULT = 4; private static final int ENTITYMODIFIERS_CAPACITY_DEFAULT = 4; private static final int UPDATEHANDLERS_CAPACITY_DEFAULT = 4; private static final float[] VERTICES_SCENE_TO_LOCAL_TMP = new float[2]; private static final float[] VERTICES_LOCAL_TO_SCENE_TMP = new float[2]; private static final ParameterCallable<IEntity> PARAMETERCALLABLE_DETACHCHILD = new ParameterCallable<IEntity>() { @Override public void call(final IEntity pEntity) { pEntity.setParent(null); pEntity.onDetached(); } }; // =========================================================== // Fields // =========================================================== protected boolean mVisible = true; protected boolean mIgnoreUpdate = false; protected boolean mChildrenVisible = true; protected boolean mChildrenIgnoreUpdate = false; protected int mZIndex = 0; private IEntity mParent; protected SmartList<IEntity> mChildren; private EntityModifierList mEntityModifiers; private UpdateHandlerList mUpdateHandlers; protected float mRed = 1f; protected float mGreen = 1f; protected float mBlue = 1f; protected float mAlpha = 1f; protected float mX; protected float mY; private final float mInitialX; private final float mInitialY; protected float mRotation = 0; protected float mRotationCenterX = 0; protected float mRotationCenterY = 0; protected float mScaleX = 1f; protected float mScaleY = 1f; protected float mScaleCenterX = 0; protected float mScaleCenterY = 0; private boolean mLocalToParentTransformationDirty = true; private boolean mParentToLocalTransformationDirty = true; private final Transformation mLocalToParentTransformation = new Transformation(); private final Transformation mParentToLocalTransformation = new Transformation(); private final Transformation mLocalToSceneTransformation = new Transformation(); private final Transformation mSceneToLocalTransformation = new Transformation(); private Object mUserData; // =========================================================== // Constructors // =========================================================== public Entity() { this(0, 0); } public Entity(final float pX, final float pY) { this.mInitialX = pX; this.mInitialY = pY; this.mX = pX; this.mY = pY; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public boolean isVisible() { return this.mVisible; } @Override public void setVisible(final boolean pVisible) { this.mVisible = pVisible; } @Override public boolean isChildrenVisible() { return this.mChildrenVisible; } @Override public void setChildrenVisible(final boolean pChildrenVisible) { this.mChildrenVisible = pChildrenVisible; } @Override public boolean isIgnoreUpdate() { return this.mIgnoreUpdate; } @Override public void setIgnoreUpdate(final boolean pIgnoreUpdate) { this.mIgnoreUpdate = pIgnoreUpdate; } @Override public boolean isChildrenIgnoreUpdate() { return this.mChildrenIgnoreUpdate; } @Override public void setChildrenIgnoreUpdate(final boolean pChildrenIgnoreUpdate) { this.mChildrenIgnoreUpdate = pChildrenIgnoreUpdate; } @Override public boolean hasParent() { return this.mParent != null; } @Override public IEntity getParent() { return this.mParent; } @Override public void setParent(final IEntity pEntity) { this.mParent = pEntity; } @Override public int getZIndex() { return this.mZIndex; } @Override public void setZIndex(final int pZIndex) { this.mZIndex = pZIndex; } @Override public float getX() { return this.mX; } @Override public float getY() { return this.mY; } @Override public float getInitialX() { return this.mInitialX; } @Override public float getInitialY() { return this.mInitialY; } @Override public void setPosition(final IEntity pOtherEntity) { this.setPosition(pOtherEntity.getX(), pOtherEntity.getY()); } @Override public void setPosition(final float pX, final float pY) { this.mX = pX; this.mY = pY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setInitialPosition() { this.mX = this.mInitialX; this.mY = this.mInitialY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public float getRotation() { return this.mRotation; } @Override public boolean isRotated() { return this.mRotation != 0; } @Override public void setRotation(final float pRotation) { this.mRotation = pRotation; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public float getRotationCenterX() { return this.mRotationCenterX; } @Override public float getRotationCenterY() { return this.mRotationCenterY; } @Override public void setRotationCenterX(final float pRotationCenterX) { this.mRotationCenterX = pRotationCenterX; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setRotationCenterY(final float pRotationCenterY) { this.mRotationCenterY = pRotationCenterY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setRotationCenter(final float pRotationCenterX, final float pRotationCenterY) { this.mRotationCenterX = pRotationCenterX; this.mRotationCenterY = pRotationCenterY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public boolean isScaled() { return this.mScaleX != 1 || this.mScaleY != 1; } @Override public float getScaleX() { return this.mScaleX; } @Override public float getScaleY() { return this.mScaleY; } @Override public void setScaleX(final float pScaleX) { this.mScaleX = pScaleX; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setScaleY(final float pScaleY) { this.mScaleY = pScaleY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setScale(final float pScale) { this.mScaleX = pScale; this.mScaleY = pScale; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setScale(final float pScaleX, final float pScaleY) { this.mScaleX = pScaleX; this.mScaleY = pScaleY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public float getScaleCenterX() { return this.mScaleCenterX; } @Override public float getScaleCenterY() { return this.mScaleCenterY; } @Override public void setScaleCenterX(final float pScaleCenterX) { this.mScaleCenterX = pScaleCenterX; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setScaleCenterY(final float pScaleCenterY) { this.mScaleCenterY = pScaleCenterY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public void setScaleCenter(final float pScaleCenterX, final float pScaleCenterY) { this.mScaleCenterX = pScaleCenterX; this.mScaleCenterY = pScaleCenterY; this.mLocalToParentTransformationDirty = true; this.mParentToLocalTransformationDirty = true; } @Override public float getRed() { return this.mRed; } @Override public float getGreen() { return this.mGreen; } @Override public float getBlue() { return this.mBlue; } @Override public float getAlpha() { return this.mAlpha; } /** * @param pAlpha from <code>0.0f</code> (transparent) to <code>1.0f</code> (opaque) */ @Override public void setAlpha(final float pAlpha) { this.mAlpha = pAlpha; } /** * @param pRed from <code>0.0f</code> to <code>1.0f</code> * @param pGreen from <code>0.0f</code> to <code>1.0f</code> * @param pBlue from <code>0.0f</code> to <code>1.0f</code> */ @Override public void setColor(final float pRed, final float pGreen, final float pBlue) { this.mRed = pRed; this.mGreen = pGreen; this.mBlue = pBlue; } /** * @param pRed from <code>0.0f</code> to <code>1.0f</code> * @param pGreen from <code>0.0f</code> to <code>1.0f</code> * @param pBlue from <code>0.0f</code> to <code>1.0f</code> * @param pAlpha from <code>0.0f</code> (transparent) to <code>1.0f</code> (opaque) */ @Override public void setColor(final float pRed, final float pGreen, final float pBlue, final float pAlpha) { this.mRed = pRed; this.mGreen = pGreen; this.mBlue = pBlue; this.mAlpha = pAlpha; } @Override public int getChildCount() { if(this.mChildren == null) { return 0; } return this.mChildren.size(); } @Override public IEntity getChild(final int pIndex) { if(this.mChildren == null) { return null; } return this.mChildren.get(pIndex); } @Override public int getChildIndex(final IEntity pEntity) { if (this.mChildren == null || pEntity.getParent() != this) { return -1; } return this.mChildren.indexOf(pEntity); } @Override public boolean setChildIndex(final IEntity pEntity, final int pIndex) { if (this.mChildren == null || pEntity.getParent() != this) { return false; } try { this.mChildren.remove(pEntity); this.mChildren.add(pIndex, pEntity); return true; } catch (final IndexOutOfBoundsException e) { return false; } } @Override public IEntity getFirstChild() { if(this.mChildren == null) { return null; } return this.mChildren.get(0); } @Override public IEntity getLastChild() { if(this.mChildren == null) { return null; } return this.mChildren.get(this.mChildren.size() - 1); } @Override public boolean detachSelf() { final IEntity parent = this.mParent; if(parent != null) { return parent.detachChild(this); } else { return false; } } @Override public void detachChildren() { if(this.mChildren == null) { return; } this.mChildren.clear(PARAMETERCALLABLE_DETACHCHILD); } @Override public void attachChild(final IEntity pEntity) throws IllegalStateException { if(pEntity.hasParent()) { throw new IllegalStateException("pEntity already has a parent!"); } if(this.mChildren == null) { this.allocateChildren(); } this.mChildren.add(pEntity); pEntity.setParent(this); pEntity.onAttached(); } @Override public boolean attachChild(final IEntity pEntity, final int pIndex) throws IllegalStateException { if(pEntity.hasParent()) { throw new IllegalStateException("pEntity already has a parent!"); } if (this.mChildren == null) { this.allocateChildren(); } try { this.mChildren.add(pIndex, pEntity); pEntity.setParent(this); pEntity.onAttached(); return true; } catch (final IndexOutOfBoundsException e) { return false; } } @Override public IEntity findChild(final IEntityMatcher pEntityMatcher) { if(this.mChildren == null) { return null; } return this.mChildren.find(pEntityMatcher); } @Override public boolean swapChildren(final IEntity pEntityA, final IEntity pEntityB) { return this.swapChildren(this.getChildIndex(pEntityA), this.getChildIndex(pEntityB)); } @Override public boolean swapChildren(final int pIndexA, final int pIndexB) { try { Collections.swap(this.mChildren, pIndexA, pIndexB); return true; } catch (final IndexOutOfBoundsException e) { return false; } } @Override public void sortChildren() { if(this.mChildren == null) { return; } ZIndexSorter.getInstance().sort(this.mChildren); } @Override public void sortChildren(final Comparator<IEntity> pEntityComparator) { if(this.mChildren == null) { return; } ZIndexSorter.getInstance().sort(this.mChildren, pEntityComparator); } @Override public boolean detachChild(final IEntity pEntity) { if(this.mChildren == null) { return false; } return this.mChildren.remove(pEntity, PARAMETERCALLABLE_DETACHCHILD); } @Override public IEntity detachChild(final IEntityMatcher pEntityMatcher) { if(this.mChildren == null) { return null; } return this.mChildren.remove(pEntityMatcher, Entity.PARAMETERCALLABLE_DETACHCHILD); } @Override public boolean detachChildren(final IEntityMatcher pEntityMatcher) { if(this.mChildren == null) { return false; } return this.mChildren.removeAll(pEntityMatcher, Entity.PARAMETERCALLABLE_DETACHCHILD); } @Override public void callOnChildren(final IEntityCallable pEntityCallable) { if(this.mChildren == null) { return; } this.mChildren.call(pEntityCallable); } @Override public void callOnChildren(final IEntityMatcher pEntityMatcher, final IEntityCallable pEntityCallable) { if(this.mChildren == null) { return; } this.mChildren.call(pEntityMatcher, pEntityCallable); } @Override public void registerUpdateHandler(final IUpdateHandler pUpdateHandler) { if(this.mUpdateHandlers == null) { this.allocateUpdateHandlers(); } this.mUpdateHandlers.add(pUpdateHandler); } @Override public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler) { if(this.mUpdateHandlers == null) { return false; } return this.mUpdateHandlers.remove(pUpdateHandler); } @Override public boolean unregisterUpdateHandlers(final IUpdateHandlerMatcher pUpdateHandlerMatcher) { if(this.mUpdateHandlers == null) { return false; } return this.mUpdateHandlers.removeAll(pUpdateHandlerMatcher); } @Override public void clearUpdateHandlers() { if(this.mUpdateHandlers == null) { return; } this.mUpdateHandlers.clear(); } @Override public void registerEntityModifier(final IEntityModifier pEntityModifier) { if(this.mEntityModifiers == null) { this.allocateEntityModifiers(); } this.mEntityModifiers.add(pEntityModifier); } @Override public boolean unregisterEntityModifier(final IEntityModifier pEntityModifier) { if(this.mEntityModifiers == null) { return false; } return this.mEntityModifiers.remove(pEntityModifier); } @Override public boolean unregisterEntityModifiers(final IEntityModifierMatcher pEntityModifierMatcher) { if(this.mEntityModifiers == null) { return false; } return this.mEntityModifiers.removeAll(pEntityModifierMatcher); } @Override public void clearEntityModifiers() { if(this.mEntityModifiers == null) { return; } this.mEntityModifiers.clear(); } @Override public float[] getSceneCenterCoordinates() { return this.convertLocalToSceneCoordinates(0, 0); } public Transformation getLocalToParentTransformation() { final Transformation localToParentTransformation = this.mLocalToParentTransformation; if(this.mLocalToParentTransformationDirty) { localToParentTransformation.setToIdentity(); /* Scale. */ final float scaleX = this.mScaleX; final float scaleY = this.mScaleY; if(scaleX != 1 || scaleY != 1) { final float scaleCenterX = this.mScaleCenterX; final float scaleCenterY = this.mScaleCenterY; /* TODO Check if it is worth to check for scaleCenterX == 0 && scaleCenterY == 0 as the two postTranslate can be saved. * The same obviously applies for all similar occurrences of this pattern in this class. */ localToParentTransformation.postTranslate(-scaleCenterX, -scaleCenterY); localToParentTransformation.postScale(scaleX, scaleY); localToParentTransformation.postTranslate(scaleCenterX, scaleCenterY); } /* TODO There is a special, but very likely case when mRotationCenter and mScaleCenter are the same. * In that case the last postTranslate of the scale and the first postTranslate of the rotation is superfluous. */ /* Rotation. */ final float rotation = this.mRotation; if(rotation != 0) { final float rotationCenterX = this.mRotationCenterX; final float rotationCenterY = this.mRotationCenterY; localToParentTransformation.postTranslate(-rotationCenterX, -rotationCenterY); localToParentTransformation.postRotate(rotation); localToParentTransformation.postTranslate(rotationCenterX, rotationCenterY); } /* Translation. */ localToParentTransformation.postTranslate(this.mX, this.mY); this.mLocalToParentTransformationDirty = false; } return localToParentTransformation; } public Transformation getParentToLocalTransformation() { final Transformation parentToLocalTransformation = this.mParentToLocalTransformation; if(this.mParentToLocalTransformationDirty) { parentToLocalTransformation.setToIdentity(); /* Translation. */ parentToLocalTransformation.postTranslate(-this.mX, -this.mY); /* Rotation. */ final float rotation = this.mRotation; if(rotation != 0) { final float rotationCenterX = this.mRotationCenterX; final float rotationCenterY = this.mRotationCenterY; parentToLocalTransformation.postTranslate(-rotationCenterX, -rotationCenterY); parentToLocalTransformation.postRotate(-rotation); parentToLocalTransformation.postTranslate(rotationCenterX, rotationCenterY); } /* TODO There is a special, but very likely case when mRotationCenter and mScaleCenter are the same. * In that case the last postTranslate of the rotation and the first postTranslate of the scale is superfluous. */ /* Scale. */ final float scaleX = this.mScaleX; final float scaleY = this.mScaleY; if(scaleX != 1 || scaleY != 1) { final float scaleCenterX = this.mScaleCenterX; final float scaleCenterY = this.mScaleCenterY; parentToLocalTransformation.postTranslate(-scaleCenterX, -scaleCenterY); parentToLocalTransformation.postScale(1 / scaleX, 1 / scaleY); parentToLocalTransformation.postTranslate(scaleCenterX, scaleCenterY); } this.mParentToLocalTransformationDirty = false; } return parentToLocalTransformation; } @Override public Transformation getLocalToSceneTransformation() { // TODO Cache if parent(recursive) not dirty. final Transformation localToSceneTransformation = this.mLocalToSceneTransformation; localToSceneTransformation.setTo(this.getLocalToParentTransformation()); final IEntity parent = this.mParent; if(parent != null) { localToSceneTransformation.postConcat(parent.getLocalToSceneTransformation()); } return localToSceneTransformation; } @Override public Transformation getSceneToLocalTransformation() { // TODO Cache if parent(recursive) not dirty. final Transformation sceneToLocalTransformation = this.mSceneToLocalTransformation; sceneToLocalTransformation.setTo(this.getParentToLocalTransformation()); final IEntity parent = this.mParent; if(parent != null) { sceneToLocalTransformation.postConcat(parent.getSceneToLocalTransformation()); } return sceneToLocalTransformation; } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertLocalToSceneCoordinates(float, float) */ @Override public float[] convertLocalToSceneCoordinates(final float pX, final float pY) { return this.convertLocalToSceneCoordinates(pX, pY, VERTICES_LOCAL_TO_SCENE_TMP); } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertLocalToSceneCoordinates(float, float, float[]) */ @Override public float[] convertLocalToSceneCoordinates(final float pX, final float pY, final float[] pReuse) { pReuse[Constants.VERTEX_INDEX_X] = pX; pReuse[Constants.VERTEX_INDEX_Y] = pY; this.getLocalToSceneTransformation().transform(pReuse); return pReuse; } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertLocalToSceneCoordinates(float[]) */ @Override public float[] convertLocalToSceneCoordinates(final float[] pCoordinates) { return this.convertSceneToLocalCoordinates(pCoordinates, VERTICES_LOCAL_TO_SCENE_TMP); } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertLocalToSceneCoordinates(float[], float[]) */ @Override public float[] convertLocalToSceneCoordinates(final float[] pCoordinates, final float[] pReuse) { pReuse[Constants.VERTEX_INDEX_X] = pCoordinates[Constants.VERTEX_INDEX_X]; pReuse[Constants.VERTEX_INDEX_Y] = pCoordinates[Constants.VERTEX_INDEX_Y]; this.getLocalToSceneTransformation().transform(pReuse); return pReuse; } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertSceneToLocalCoordinates(float, float) */ @Override public float[] convertSceneToLocalCoordinates(final float pX, final float pY) { return this.convertSceneToLocalCoordinates(pX, pY, VERTICES_SCENE_TO_LOCAL_TMP); } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertSceneToLocalCoordinates(float, float, float[]) */ @Override public float[] convertSceneToLocalCoordinates(final float pX, final float pY, final float[] pReuse) { pReuse[Constants.VERTEX_INDEX_X] = pX; pReuse[Constants.VERTEX_INDEX_Y] = pY; this.getSceneToLocalTransformation().transform(pReuse); return pReuse; } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertSceneToLocalCoordinates(float[]) */ @Override public float[] convertSceneToLocalCoordinates(final float[] pCoordinates) { return this.convertSceneToLocalCoordinates(pCoordinates, VERTICES_SCENE_TO_LOCAL_TMP); } /* (non-Javadoc) * @see org.anddev.andengine.entity.IEntity#convertSceneToLocalCoordinates(float[], float[]) */ @Override public float[] convertSceneToLocalCoordinates(final float[] pCoordinates, final float[] pReuse) { pReuse[Constants.VERTEX_INDEX_X] = pCoordinates[Constants.VERTEX_INDEX_X]; pReuse[Constants.VERTEX_INDEX_Y] = pCoordinates[Constants.VERTEX_INDEX_Y]; this.getSceneToLocalTransformation().transform(pReuse); return pReuse; } @Override public void onAttached() { } @Override public void onDetached() { } @Override public Object getUserData() { return this.mUserData; } @Override public void setUserData(final Object pUserData) { this.mUserData = pUserData; } @Override public final void onDraw(final GL10 pGL, final Camera pCamera) { if(this.mVisible) { this.onManagedDraw(pGL, pCamera); } } @Override public final void onUpdate(final float pSecondsElapsed) { if(!this.mIgnoreUpdate) { this.onManagedUpdate(pSecondsElapsed); } } @Override public void reset() { this.mVisible = true; this.mIgnoreUpdate = false; this.mChildrenVisible = true; this.mChildrenIgnoreUpdate = false; this.mX = this.mInitialX; this.mY = this.mInitialY; this.mRotation = 0; this.mScaleX = 1; this.mScaleY = 1; this.mRed = 1.0f; this.mGreen = 1.0f; this.mBlue = 1.0f; this.mAlpha = 1.0f; if(this.mEntityModifiers != null) { this.mEntityModifiers.reset(); } if(this.mChildren != null) { final ArrayList<IEntity> entities = this.mChildren; for(int i = entities.size() - 1; i >= 0; i--) { entities.get(i).reset(); } } } // =========================================================== // Methods // =========================================================== /** * @param pGL the OpenGL GL1.0 Context (potentially higher than 1.0) to use for drawing. * @param pCamera the currently active {@link Camera} i.e. to be used for culling. */ protected void doDraw(final GL10 pGL, final Camera pCamera) { } private void allocateEntityModifiers() { this.mEntityModifiers = new EntityModifierList(this, Entity.ENTITYMODIFIERS_CAPACITY_DEFAULT); } private void allocateChildren() { this.mChildren = new SmartList<IEntity>(Entity.CHILDREN_CAPACITY_DEFAULT); } private void allocateUpdateHandlers() { this.mUpdateHandlers = new UpdateHandlerList(Entity.UPDATEHANDLERS_CAPACITY_DEFAULT); } protected void onApplyTransformations(final GL10 pGL) { /* Translation. */ this.applyTranslation(pGL); /* Rotation. */ this.applyRotation(pGL); /* Scale. */ this.applyScale(pGL); } protected void applyTranslation(final GL10 pGL) { pGL.glTranslatef(this.mX, this.mY, 0); } protected void applyRotation(final GL10 pGL) { final float rotation = this.mRotation; if(rotation != 0) { final float rotationCenterX = this.mRotationCenterX; final float rotationCenterY = this.mRotationCenterY; pGL.glTranslatef(rotationCenterX, rotationCenterY, 0); pGL.glRotatef(rotation, 0, 0, 1); pGL.glTranslatef(-rotationCenterX, -rotationCenterY, 0); /* TODO There is a special, but very likely case when mRotationCenter and mScaleCenter are the same. * In that case the last glTranslatef of the rotation and the first glTranslatef of the scale is superfluous. * The problem is that applyRotation and applyScale would need to be "merged" in order to efficiently check for that condition. */ } } protected void applyScale(final GL10 pGL) { final float scaleX = this.mScaleX; final float scaleY = this.mScaleY; if(scaleX != 1 || scaleY != 1) { final float scaleCenterX = this.mScaleCenterX; final float scaleCenterY = this.mScaleCenterY; pGL.glTranslatef(scaleCenterX, scaleCenterY, 0); pGL.glScalef(scaleX, scaleY, 1); pGL.glTranslatef(-scaleCenterX, -scaleCenterY, 0); } } protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { pGL.glPushMatrix(); { this.onApplyTransformations(pGL); this.doDraw(pGL, pCamera); this.onDrawChildren(pGL, pCamera); } pGL.glPopMatrix(); } protected void onDrawChildren(final GL10 pGL, final Camera pCamera) { if(this.mChildren != null && this.mChildrenVisible) { this.onManagedDrawChildren(pGL, pCamera); } } public void onManagedDrawChildren(final GL10 pGL, final Camera pCamera) { final ArrayList<IEntity> children = this.mChildren; final int childCount = children.size(); for(int i = 0; i < childCount; i++) { children.get(i).onDraw(pGL, pCamera); } } protected void onManagedUpdate(final float pSecondsElapsed) { if(this.mEntityModifiers != null) { this.mEntityModifiers.onUpdate(pSecondsElapsed); } if(this.mUpdateHandlers != null) { this.mUpdateHandlers.onUpdate(pSecondsElapsed); } if(this.mChildren != null && !this.mChildrenIgnoreUpdate) { final ArrayList<IEntity> entities = this.mChildren; final int entityCount = entities.size(); for(int i = 0; i < entityCount; i++) { entities.get(i).onUpdate(pSecondsElapsed); } } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/Entity.java
Java
lgpl
28,839
package org.anddev.andengine.entity.text; import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL11; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.shape.RectangularShape; import org.anddev.andengine.opengl.font.Font; import org.anddev.andengine.opengl.texture.buffer.TextTextureBuffer; import org.anddev.andengine.opengl.util.GLHelper; import org.anddev.andengine.opengl.vertex.TextVertexBuffer; import org.anddev.andengine.util.HorizontalAlign; import org.anddev.andengine.util.StringUtils; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:54:59 - 03.04.2010 */ public class Text extends RectangularShape { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final TextTextureBuffer mTextTextureBuffer; private String mText; private String[] mLines; private int[] mWidths; private final Font mFont; private int mMaximumLineWidth; protected final int mCharactersMaximum; protected final int mVertexCount; // =========================================================== // Constructors // =========================================================== public Text(final float pX, final float pY, final Font pFont, final String pText) { this(pX, pY, pFont, pText, HorizontalAlign.LEFT); } public Text(final float pX, final float pY, final Font pFont, final String pText, final HorizontalAlign pHorizontalAlign) { this(pX, pY, pFont, pText, pHorizontalAlign, pText.length() - StringUtils.countOccurrences(pText, '\n')); } protected Text(final float pX, final float pY, final Font pFont, final String pText, final HorizontalAlign pHorizontalAlign, final int pCharactersMaximum) { super(pX, pY, 0, 0, new TextVertexBuffer(pCharactersMaximum, pHorizontalAlign, GL11.GL_STATIC_DRAW, true)); this.mCharactersMaximum = pCharactersMaximum; this.mVertexCount = TextVertexBuffer.VERTICES_PER_CHARACTER * this.mCharactersMaximum; this.mTextTextureBuffer = new TextTextureBuffer(2 * this.mVertexCount, GL11.GL_STATIC_DRAW, true); this.mFont = pFont; this.updateText(pText); this.initBlendFunction(); } protected void updateText(final String pText) { this.mText = pText; final Font font = this.mFont; this.mLines = StringUtils.split(this.mText, '\n', this.mLines); final String[] lines = this.mLines; final int lineCount = lines.length; final boolean widthsReusable = this.mWidths != null && this.mWidths.length == lineCount; if(!widthsReusable) { this.mWidths = new int[lineCount]; } final int[] widths = this.mWidths; int maximumLineWidth = 0; for (int i = lineCount - 1; i >= 0; i--) { widths[i] = font.getStringWidth(lines[i]); maximumLineWidth = Math.max(maximumLineWidth, widths[i]); } this.mMaximumLineWidth = maximumLineWidth; super.mWidth = this.mMaximumLineWidth; final float width = super.mWidth; super.mBaseWidth = width; super.mHeight = lineCount * font.getLineHeight() + (lineCount - 1) * font.getLineGap(); final float height = super.mHeight; super.mBaseHeight = height; this.mRotationCenterX = width * 0.5f; this.mRotationCenterY = height * 0.5f; this.mScaleCenterX = this.mRotationCenterX; this.mScaleCenterY = this.mRotationCenterY; this.mTextTextureBuffer.update(font, lines); this.updateVertexBuffer(); } // =========================================================== // Getter & Setter // =========================================================== public String getText() { return this.mText; } public int getCharactersMaximum() { return this.mCharactersMaximum; } @Override public TextVertexBuffer getVertexBuffer() { return (TextVertexBuffer)this.mVertexBuffer; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onInitDraw(final GL10 pGL) { super.onInitDraw(pGL); GLHelper.enableTextures(pGL); GLHelper.enableTexCoordArray(pGL); } @Override protected void drawVertices(final GL10 pGL, final Camera pCamera) { pGL.glDrawArrays(GL10.GL_TRIANGLES, 0, this.mVertexCount); } @Override protected void onUpdateVertexBuffer() { final Font font = this.mFont; if(font != null) { this.getVertexBuffer().update(font, this.mMaximumLineWidth, this.mWidths, this.mLines); } } @Override protected void onApplyTransformations(final GL10 pGL) { super.onApplyTransformations(pGL); this.applyTexture(pGL); } @Override protected void finalize() throws Throwable { super.finalize(); if(this.mTextTextureBuffer.isManaged()) { this.mTextTextureBuffer.unloadFromActiveBufferObjectManager(); } } // =========================================================== // Methods // =========================================================== private void initBlendFunction() { if(this.mFont.getTexture().getTextureOptions().mPreMultipyAlpha) { this.setBlendFunction(BLENDFUNCTION_SOURCE_PREMULTIPLYALPHA_DEFAULT, BLENDFUNCTION_DESTINATION_PREMULTIPLYALPHA_DEFAULT); } } private void applyTexture(final GL10 pGL) { if(GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS) { final GL11 gl11 = (GL11)pGL; this.mTextTextureBuffer.selectOnHardware(gl11); this.mFont.getTexture().bind(pGL); GLHelper.texCoordZeroPointer(gl11); } else { this.mFont.getTexture().bind(pGL); GLHelper.texCoordPointer(pGL, this.mTextTextureBuffer.getFloatBuffer()); } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/text/Text.java
Java
lgpl
6,106
package org.anddev.andengine.entity.text; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.opengl.font.Font; import org.anddev.andengine.opengl.vertex.TextVertexBuffer; import org.anddev.andengine.util.HorizontalAlign; import org.anddev.andengine.util.StringUtils; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:07:06 - 08.07.2010 */ public class ChangeableText extends Text { // =========================================================== // Constants // =========================================================== private static final String ELLIPSIS = "..."; private static final int ELLIPSIS_CHARACTER_COUNT = ELLIPSIS.length(); // =========================================================== // Fields // =========================================================== private int mCharacterCountCurrentText; // =========================================================== // Constructors // =========================================================== public ChangeableText(final float pX, final float pY, final Font pFont, final String pText) { this(pX, pY, pFont, pText, pText.length() - StringUtils.countOccurrences(pText, '\n')); } public ChangeableText(final float pX, final float pY, final Font pFont, final String pText, final int pCharactersMaximum) { this(pX, pY, pFont, pText, HorizontalAlign.LEFT, pCharactersMaximum); } public ChangeableText(final float pX, final float pY, final Font pFont, final String pText, final HorizontalAlign pHorizontalAlign, final int pCharactersMaximum) { super(pX, pY, pFont, pText, pHorizontalAlign, pCharactersMaximum); this.mCharacterCountCurrentText = pText.length() - StringUtils.countOccurrences(pText, '\n'); } // =========================================================== // Getter & Setter // =========================================================== public void setText(final String pText) { this.setText(pText, false); } /** * @param pText * @param pAllowEllipsis in the case pText is longer than <code>pCharactersMaximum</code>, * which was passed to the constructor, the displayed text will end with an ellipsis ("..."). */ public void setText(final String pText, final boolean pAllowEllipsis) { final int textCharacterCount = pText.length() - StringUtils.countOccurrences(pText, '\n'); if(textCharacterCount > this.mCharactersMaximum) { if(pAllowEllipsis && this.mCharactersMaximum > ELLIPSIS_CHARACTER_COUNT) { this.updateText(pText.substring(0, this.mCharactersMaximum - ELLIPSIS_CHARACTER_COUNT).concat(ELLIPSIS)); // TODO This allocation could maybe be avoided... } else { this.updateText(pText.substring(0, this.mCharactersMaximum)); // TODO This allocation could be avoided... } this.mCharacterCountCurrentText = this.mCharactersMaximum; } else { this.updateText(pText); this.mCharacterCountCurrentText = textCharacterCount; } } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void drawVertices(final GL10 pGL, final Camera pCamera) { pGL.glDrawArrays(GL10.GL_TRIANGLES, 0, this.mCharacterCountCurrentText * TextVertexBuffer.VERTICES_PER_CHARACTER); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/text/ChangeableText.java
Java
lgpl
3,787
package org.anddev.andengine.entity.text; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.opengl.font.Font; import org.anddev.andengine.opengl.vertex.TextVertexBuffer; import org.anddev.andengine.util.HorizontalAlign; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:02:04 - 05.05.2010 */ public class TickerText extends Text { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private float mCharactersPerSecond; private int mCharactersVisible = 0; private float mSecondsElapsed = 0; private boolean mReverse = false; private float mDuration; // =========================================================== // Constructors // =========================================================== public TickerText(final float pX, final float pY, final Font pFont, final String pText, final HorizontalAlign pHorizontalAlign, final float pCharactersPerSecond) { super(pX, pY, pFont, pText, pHorizontalAlign); this.setCharactersPerSecond(pCharactersPerSecond); } // =========================================================== // Getter & Setter // =========================================================== public boolean isReverse() { return this.mReverse; } public void setReverse(final boolean pReverse) { this.mReverse = pReverse; } public float getCharactersPerSecond() { return this.mCharactersPerSecond; } public void setCharactersPerSecond(final float pCharactersPerSecond) { this.mCharactersPerSecond = pCharactersPerSecond; this.mDuration = this.mCharactersMaximum * this.mCharactersPerSecond; } public int getCharactersVisible() { return this.mCharactersVisible; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedUpdate(final float pSecondsElapsed) { super.onManagedUpdate(pSecondsElapsed); if(this.mReverse){ if(this.mCharactersVisible < this.mCharactersMaximum){ this.mSecondsElapsed = Math.max(0, this.mSecondsElapsed - pSecondsElapsed); this.mCharactersVisible = (int)(this.mSecondsElapsed * this.mCharactersPerSecond); } } else { if(this.mCharactersVisible < this.mCharactersMaximum){ this.mSecondsElapsed = Math.min(this.mDuration, this.mSecondsElapsed + pSecondsElapsed); this.mCharactersVisible = (int)(this.mSecondsElapsed * this.mCharactersPerSecond); } } } @Override protected void drawVertices(final GL10 pGL, final Camera pCamera) { pGL.glDrawArrays(GL10.GL_TRIANGLES, 0, this.mCharactersVisible * TextVertexBuffer.VERTICES_PER_CHARACTER); } @Override public void reset() { super.reset(); this.mCharactersVisible = 0; this.mSecondsElapsed = 0; this.mReverse = false; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/text/TickerText.java
Java
lgpl
3,531
package org.anddev.andengine.entity; import java.util.Comparator; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.engine.handler.IUpdateHandler; import org.anddev.andengine.engine.handler.runnable.RunnableHandler; import org.anddev.andengine.entity.modifier.IEntityModifier; import org.anddev.andengine.entity.modifier.IEntityModifier.IEntityModifierMatcher; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.opengl.IDrawable; import org.anddev.andengine.util.IMatcher; import org.anddev.andengine.util.ParameterCallable; import org.anddev.andengine.util.Transformation; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:20:25 - 08.03.2010 */ public interface IEntity extends IDrawable, IUpdateHandler { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public boolean isVisible(); public void setVisible(final boolean pVisible); public boolean isIgnoreUpdate(); public void setIgnoreUpdate(boolean pIgnoreUpdate); public boolean isChildrenVisible(); public void setChildrenVisible(final boolean pChildrenVisible); public boolean isChildrenIgnoreUpdate(); public void setChildrenIgnoreUpdate(boolean pChildrenIgnoreUpdate); public int getZIndex(); public void setZIndex(final int pZIndex); public boolean hasParent(); public IEntity getParent(); public void setParent(final IEntity pEntity); public float getX(); public float getY(); public float getInitialX(); public float getInitialY(); public void setInitialPosition(); public void setPosition(final IEntity pOtherEntity); public void setPosition(final float pX, final float pY); public boolean isRotated(); public float getRotation(); public void setRotation(final float pRotation); public float getRotationCenterX(); public float getRotationCenterY(); public void setRotationCenterX(final float pRotationCenterX); public void setRotationCenterY(final float pRotationCenterY); public void setRotationCenter(final float pRotationCenterX, final float pRotationCenterY); public boolean isScaled(); public float getScaleX(); public float getScaleY(); public void setScaleX(final float pScaleX); public void setScaleY(final float pScaleY); public void setScale(final float pScale); public void setScale(final float pScaleX, final float pScaleY); public float getScaleCenterX(); public float getScaleCenterY(); public void setScaleCenterX(final float pScaleCenterX); public void setScaleCenterY(final float pScaleCenterY); public void setScaleCenter(final float pScaleCenterX, final float pScaleCenterY); public float getRed(); public float getGreen(); public float getBlue(); public float getAlpha(); public void setAlpha(final float pAlpha); public void setColor(final float pRed, final float pGreen, final float pBlue); public void setColor(final float pRed, final float pGreen, final float pBlue, final float pAlpha); /** * @return a shared(!) float[] of length 2. */ public float[] getSceneCenterCoordinates(); /** * @param pX * @param pY * @return a shared(!) float[] of length 2. */ public float[] convertLocalToSceneCoordinates(final float pX, final float pY); /** * @param pX * @param pY * @param pReuse must be of length 2. * @return <code>pReuse</code> as a convenience. */ public float[] convertLocalToSceneCoordinates(final float pX, final float pY, final float[] pReuse); /** * @param pCoordinates must be of length 2. * @return a shared(!) float[] of length 2. */ public float[] convertLocalToSceneCoordinates(final float[] pCoordinates); /** * @param pCoordinates must be of length 2. * @param pReuse must be of length 2. * @return <code>pReuse</code> as a convenience. */ public float[] convertLocalToSceneCoordinates(final float[] pCoordinates, final float[] pReuse); /** * @param pX * @param pY * @return a shared(!) float[] of length 2. */ public float[] convertSceneToLocalCoordinates(final float pX, final float pY); /** * @param pX * @param pY * @param pReuse must be of length 2. * @return <code>pReuse</code> as a convenience. */ public float[] convertSceneToLocalCoordinates(final float pX, final float pY, final float[] pReuse); /** * @param pCoordinates must be of length 2. * @return a shared(!) float[] of length 2. */ public float[] convertSceneToLocalCoordinates(final float[] pCoordinates); /** * @param pCoordinates must be of length 2. * @param pReuse must be of length 2. * @return <code>pReuse</code> as a convenience. */ public float[] convertSceneToLocalCoordinates(final float[] pCoordinates, final float[] pReuse); public Transformation getLocalToSceneTransformation(); public Transformation getSceneToLocalTransformation(); // public Transformation getLocalToParentTransformation(); // TODO Add this method. // public Transformation getParentToLocalTransformation(); // TODO Add this method. public int getChildCount(); public void onAttached(); public void onDetached(); public void attachChild(final IEntity pEntity); public boolean attachChild(final IEntity pEntity, final int pIndex); public IEntity getChild(final int pIndex); public IEntity getFirstChild(); public IEntity getLastChild(); public int getChildIndex(final IEntity pEntity); public boolean setChildIndex(final IEntity pEntity, final int pIndex); public IEntity findChild(final IEntityMatcher pEntityMatcher); public boolean swapChildren(final int pIndexA, final int pIndexB); public boolean swapChildren(final IEntity pEntityA, final IEntity pEntityB); /** * Sorts the {@link IEntity}s based on their ZIndex. Sort is stable. */ public void sortChildren(); /** * Sorts the {@link IEntity}s based on the {@link Comparator} supplied. Sort is stable. * @param pEntityComparator */ public void sortChildren(final Comparator<IEntity> pEntityComparator); public boolean detachSelf(); /** * <b><i>WARNING:</i> This function should be called from within * {@link RunnableHandler#postRunnable(Runnable)} which is registered * to a {@link Scene} or the {@link Engine} itself, because otherwise * it may throw an {@link IndexOutOfBoundsException} in the * Update-Thread or the GL-Thread!</b> */ public boolean detachChild(final IEntity pEntity); /** * <b><i>WARNING:</i> This function should be called from within * {@link RunnableHandler#postRunnable(Runnable)} which is registered * to a {@link Scene} or the {@link Engine} itself, because otherwise * it may throw an {@link IndexOutOfBoundsException} in the * Update-Thread or the GL-Thread!</b> */ public IEntity detachChild(final IEntityMatcher pEntityMatcher); /** * <b><i>WARNING:</i> This function should be called from within * {@link RunnableHandler#postRunnable(Runnable)} which is registered * to a {@link Scene} or the {@link Engine} itself, because otherwise * it may throw an {@link IndexOutOfBoundsException} in the * Update-Thread or the GL-Thread!</b> */ public boolean detachChildren(final IEntityMatcher pEntityMatcher); public void detachChildren(); public void callOnChildren(final IEntityCallable pEntityCallable); public void callOnChildren(final IEntityMatcher pEntityMatcher, final IEntityCallable pEntityCallable); public void registerUpdateHandler(final IUpdateHandler pUpdateHandler); public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler); public boolean unregisterUpdateHandlers(final IUpdateHandlerMatcher pUpdateHandlerMatcher); public void clearUpdateHandlers(); public void registerEntityModifier(final IEntityModifier pEntityModifier); public boolean unregisterEntityModifier(final IEntityModifier pEntityModifier); public boolean unregisterEntityModifiers(final IEntityModifierMatcher pEntityModifierMatcher); public void clearEntityModifiers(); public void setUserData(Object pUserData); public Object getUserData(); // =========================================================== // Inner and Anonymous Classes // =========================================================== public interface IEntityMatcher extends IMatcher<IEntity> { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== @Override public boolean matches(final IEntity pEntity); } public interface IEntityCallable extends ParameterCallable<IEntity> { // =========================================================== // Constants // =========================================================== // =========================================================== // Methods // =========================================================== @Override public void call(final IEntity pEntity); } }
zzy421-andengine
src/org/anddev/andengine/entity/IEntity.java
Java
lgpl
9,430
package org.anddev.andengine.entity.particle.emitter; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_X; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_Y; import org.anddev.andengine.util.MathUtils; import org.anddev.andengine.util.constants.MathConstants; import android.util.FloatMath; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:18:41 - 01.10.2010 */ public class CircleOutlineParticleEmitter extends BaseCircleParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public CircleOutlineParticleEmitter(final float pCenterX, final float pCenterY, final float pRadius) { super(pCenterX, pCenterY, pRadius); } public CircleOutlineParticleEmitter(final float pCenterX, final float pCenterY, final float pRadiusX, final float pRadiusY) { super(pCenterX, pCenterY, pRadiusX, pRadiusY); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void getPositionOffset(final float[] pOffset) { final float random = MathUtils.RANDOM.nextFloat() * MathConstants.PI * 2; pOffset[VERTEX_INDEX_X] = this.mCenterX + FloatMath.cos(random) * this.mRadiusX; pOffset[VERTEX_INDEX_Y] = this.mCenterY + FloatMath.sin(random) * this.mRadiusY; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/CircleOutlineParticleEmitter.java
Java
lgpl
2,299
package org.anddev.andengine.entity.particle.emitter; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_X; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_Y; import org.anddev.andengine.util.MathUtils; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:48:00 - 01.10.2010 */ public class RectangleOutlineParticleEmitter extends BaseRectangleParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public RectangleOutlineParticleEmitter(final float pCenterX, final float pCenterY, final float pWidth, final float pHeight) { super(pCenterX, pCenterY, pWidth, pHeight); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void getPositionOffset(final float[] pOffset) { pOffset[VERTEX_INDEX_X] = this.mCenterX + MathUtils.randomSign() * this.mWidthHalf; pOffset[VERTEX_INDEX_Y] = this.mCenterY + MathUtils.randomSign() * this.mHeightHalf; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/RectangleOutlineParticleEmitter.java
Java
lgpl
1,989
package org.anddev.andengine.entity.particle.emitter; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_X; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_Y; import org.anddev.andengine.util.MathUtils; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:48:00 - 01.10.2010 */ public class RectangleParticleEmitter extends BaseRectangleParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public RectangleParticleEmitter(final float pCenterX, final float pCenterY, final float pWidth, final float pHeight) { super(pCenterX, pCenterY, pWidth, pHeight); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void getPositionOffset(final float[] pOffset) { pOffset[VERTEX_INDEX_X] = this.mCenterX - this.mWidthHalf + MathUtils.RANDOM.nextFloat() * this.mWidth; pOffset[VERTEX_INDEX_Y] = this.mCenterY - this.mHeightHalf + MathUtils.RANDOM.nextFloat() * this.mHeight; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/RectangleParticleEmitter.java
Java
lgpl
2,016
package org.anddev.andengine.entity.particle.emitter; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:53:18 - 01.10.2010 */ public abstract class BaseRectangleParticleEmitter extends BaseParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mWidth; protected float mHeight; protected float mWidthHalf; protected float mHeightHalf; // =========================================================== // Constructors // =========================================================== public BaseRectangleParticleEmitter(final float pCenterX, final float pCenterY, final float pSize) { this(pCenterX, pCenterY, pSize, pSize); } public BaseRectangleParticleEmitter(final float pCenterX, final float pCenterY, final float pWidth, final float pHeight) { super(pCenterX, pCenterY); this.setWidth(pWidth); this.setHeight(pHeight); } // =========================================================== // Getter & Setter // =========================================================== public float getWidth() { return this.mWidth; } public void setWidth(final float pWidth) { this.mWidth = pWidth; this.mWidthHalf = pWidth * 0.5f; } public float getHeight() { return this.mHeight; } public void setHeight(final float pHeight) { this.mHeight = pHeight; this.mHeightHalf = pHeight * 0.5f; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/BaseRectangleParticleEmitter.java
Java
lgpl
2,183
package org.anddev.andengine.entity.particle.emitter; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_X; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_Y; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 23:14:42 - 01.10.2010 */ public class PointParticleEmitter extends BaseParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public PointParticleEmitter(final float pCenterX, final float pCenterY) { super(pCenterX, pCenterY); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void getPositionOffset(final float[] pOffset) { pOffset[VERTEX_INDEX_X] = this.mCenterX; pOffset[VERTEX_INDEX_Y] = this.mCenterY; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/PointParticleEmitter.java
Java
lgpl
1,766
package org.anddev.andengine.entity.particle.emitter; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:58:12 - 01.10.2010 */ public abstract class BaseParticleEmitter implements IParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mCenterX; protected float mCenterY; // =========================================================== // Constructors // =========================================================== public BaseParticleEmitter(final float pCenterX, final float pCenterY) { this.mCenterX = pCenterX; this.mCenterY = pCenterY; } // =========================================================== // Getter & Setter // =========================================================== public float getCenterX() { return this.mCenterX; } public float getCenterY() { return this.mCenterY; } public void setCenterX(final float pCenterX) { this.mCenterX = pCenterX; } public void setCenterY(final float pCenterY) { this.mCenterY = pCenterY; } public void setCenter(final float pCenterX, final float pCenterY) { this.mCenterX = pCenterX; this.mCenterY = pCenterY; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onUpdate(final float pSecondsElapsed) { } @Override public void reset() { } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/BaseParticleEmitter.java
Java
lgpl
2,082
package org.anddev.andengine.entity.particle.emitter; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:14:43 - 01.10.2010 */ public abstract class BaseCircleParticleEmitter extends BaseParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mRadiusX; protected float mRadiusY; // =========================================================== // Constructors // =========================================================== public BaseCircleParticleEmitter(final float pCenterX, final float pCenterY, final float pRadius) { this(pCenterX, pCenterY, pRadius, pRadius); } public BaseCircleParticleEmitter(final float pCenterX, final float pCenterY, final float pRadiusX, final float pRadiusY) { super(pCenterX, pCenterY); this.setRadiusX(pRadiusX); this.setRadiusY(pRadiusY); } // =========================================================== // Getter & Setter // =========================================================== public float getRadiusX() { return this.mRadiusX; } public void setRadiusX(final float pRadiusX) { this.mRadiusX = pRadiusX; } public float getRadiusY() { return this.mRadiusY; } public void setRadiusY(final float pRadiusY) { this.mRadiusY = pRadiusY; } public void setRadius(final float pRadius) { this.mRadiusX = pRadius; this.mRadiusY = pRadius; } public void setRadius(final float pRadiusX, final float pRadiusY) { this.mRadiusX = pRadiusX; this.mRadiusY = pRadiusY; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/BaseCircleParticleEmitter.java
Java
lgpl
2,318
package org.anddev.andengine.entity.particle.emitter; import org.anddev.andengine.engine.handler.IUpdateHandler; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:48:09 - 01.10.2010 */ public interface IParticleEmitter extends IUpdateHandler { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public void getPositionOffset(final float[] pOffset); }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/IParticleEmitter.java
Java
lgpl
665
package org.anddev.andengine.entity.particle.emitter; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_X; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_Y; import org.anddev.andengine.util.MathUtils; import org.anddev.andengine.util.constants.MathConstants; import android.util.FloatMath; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:18:41 - 01.10.2010 */ public class CircleParticleEmitter extends BaseCircleParticleEmitter { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public CircleParticleEmitter(final float pCenterX, final float pCenterY, final float pRadius) { super(pCenterX, pCenterY, pRadius); } public CircleParticleEmitter(final float pCenterX, final float pCenterY, final float pRadiusX, final float pRadiusY) { super(pCenterX, pCenterY, pRadiusX, pRadiusY); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void getPositionOffset(final float[] pOffset) { final float random = MathUtils.RANDOM.nextFloat() * MathConstants.PI * 2; pOffset[VERTEX_INDEX_X] = this.mCenterX + FloatMath.cos(random) * this.mRadiusX * MathUtils.RANDOM.nextFloat(); pOffset[VERTEX_INDEX_Y] = this.mCenterY + FloatMath.sin(random) * this.mRadiusY * MathUtils.RANDOM.nextFloat(); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/emitter/CircleParticleEmitter.java
Java
lgpl
2,340
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:17:42 - 29.06.2010 */ public class RotationInitializer extends BaseSingleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public RotationInitializer(final float pRotation) { this(pRotation, pRotation); } public RotationInitializer(final float pMinRotation, final float pMaxRotation) { super(pMinRotation, pMaxRotation); } // =========================================================== // Getter & Setter // =========================================================== public float getMinRotation() { return this.mMinValue; } public float getMaxRotation() { return this.mMaxValue; } public void setRotation(final float pRotation) { this.mMinValue = pRotation; this.mMaxValue = pRotation; } public void setRotation(final float pMinRotation, final float pMaxRotation) { this.mMinValue = pMinRotation; this.mMaxValue = pMaxRotation; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onInitializeParticle(final Particle pParticle, final float pRotation) { pParticle.setRotation(pRotation); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/RotationInitializer.java
Java
lgpl
2,166
package org.anddev.andengine.entity.particle.initializer; import android.hardware.SensorManager; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:04:00 - 15.03.2010 */ public class GravityInitializer extends AccelerationInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public GravityInitializer() { super(0, SensorManager.GRAVITY_EARTH); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/GravityInitializer.java
Java
lgpl
1,463
package org.anddev.andengine.entity.particle.initializer; import static org.anddev.andengine.util.MathUtils.RANDOM; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:58:29 - 04.05.2010 */ public abstract class BaseDoubleValueInitializer extends BaseSingleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mMinValueB; protected float mMaxValueB; // =========================================================== // Constructors // =========================================================== public BaseDoubleValueInitializer(final float pMinValueA, final float pMaxValueA, final float pMinValueB, final float pMaxValueB) { super(pMinValueA, pMaxValueA); this.mMinValueB = pMinValueB; this.mMaxValueB = pMaxValueB; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onInitializeParticle(final Particle pParticle, final float pValueA, final float pValueB); @Override protected final void onInitializeParticle(final Particle pParticle, final float pValueA) { this.onInitializeParticle(pParticle, pValueA, this.getRandomValueB()); } // =========================================================== // Methods // =========================================================== private final float getRandomValueB() { if(this.mMinValueB == this.mMaxValueB) { return this.mMaxValueB; } else { return RANDOM.nextFloat() * (this.mMaxValueB - this.mMinValueB) + this.mMinValueB; } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/BaseDoubleValueInitializer.java
Java
lgpl
2,308
package org.anddev.andengine.entity.particle.initializer; import static org.anddev.andengine.util.MathUtils.RANDOM; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:18:06 - 29.06.2010 */ public abstract class BaseSingleValueInitializer implements IParticleInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mMinValue; protected float mMaxValue; // =========================================================== // Constructors // =========================================================== public BaseSingleValueInitializer(final float pMinValue, final float pMaxValue) { this.mMinValue = pMinValue; this.mMaxValue = pMaxValue; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onInitializeParticle(final Particle pParticle, final float pValue); @Override public final void onInitializeParticle(final Particle pParticle) { this.onInitializeParticle(pParticle, this.getRandomValue()); } // =========================================================== // Methods // =========================================================== private final float getRandomValue() { if(this.mMinValue == this.mMaxValue) { return this.mMaxValue; } else { return RANDOM.nextFloat() * (this.mMaxValue - this.mMinValue) + this.mMinValue; } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/BaseSingleValueInitializer.java
Java
lgpl
2,152
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:53:41 - 02.10.2010 */ public class AlphaInitializer extends BaseSingleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public AlphaInitializer(final float pAlpha) { super(pAlpha, pAlpha); } public AlphaInitializer(final float pMinAlpha, final float pMaxAlpha) { super(pMinAlpha, pMaxAlpha); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onInitializeParticle(final Particle pParticle, final float pAlpha) { pParticle.setAlpha(pAlpha); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/AlphaInitializer.java
Java
lgpl
1,728
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:21:10 - 14.03.2010 */ public class AccelerationInitializer extends BaseDoubleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public AccelerationInitializer(final float pAcceleration) { this(pAcceleration, pAcceleration); } public AccelerationInitializer(final float pAccelerationX, final float pAccelerationY) { this(pAccelerationX, pAccelerationX, pAccelerationY, pAccelerationY); } public AccelerationInitializer(final float pMinAccelerationX, final float pMaxAccelerationX, final float pMinAccelerationY, final float pMaxAccelerationY) { super(pMinAccelerationX, pMaxAccelerationX, pMinAccelerationY, pMaxAccelerationY); } // =========================================================== // Getter & Setter // =========================================================== public float getMinAccelerationX() { return this.mMinValue; } public float getMaxAccelerationX() { return this.mMaxValue; } public float getMinAccelerationY() { return this.mMinValueB; } public float getMaxAccelerationY() { return this.mMaxValueB; } public void setAccelerationX(final float pAccelerationX) { this.mMinValue = pAccelerationX; this.mMaxValue = pAccelerationX; } public void setAccelerationY(final float pAccelerationY) { this.mMinValueB = pAccelerationY; this.mMaxValueB = pAccelerationY; } public void setAccelerationX(final float pMinAccelerationX, final float pMaxAccelerationX) { this.mMinValue = pMinAccelerationX; this.mMaxValue = pMaxAccelerationX; } public void setAccelerationY(final float pMinAccelerationY, final float pMaxAccelerationY) { this.mMinValueB = pMinAccelerationY; this.mMaxValueB = pMaxAccelerationY; } public void setAcceleration(final float pMinAccelerationX, final float pMaxAccelerationX, final float pMinAccelerationY, final float pMaxAccelerationY) { this.mMinValue = pMinAccelerationX; this.mMaxValue = pMaxAccelerationX; this.mMinValueB = pMinAccelerationY; this.mMaxValueB = pMaxAccelerationY; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onInitializeParticle(final Particle pParticle, final float pAccelerationX, final float pAccelerationY) { pParticle.getPhysicsHandler().accelerate(pAccelerationX, pAccelerationY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/AccelerationInitializer.java
Java
lgpl
3,394
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:17:42 - 29.06.2010 */ public class ColorInitializer extends BaseTripleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ColorInitializer(final float pRed, final float pGreen, final float pBlue) { super(pRed, pRed, pGreen, pGreen, pBlue, pBlue); } public ColorInitializer(final float pMinRed, final float pMaxRed, final float pMinGreen, final float pMaxGreen, final float pMinBlue, final float pMaxBlue) { super(pMinRed, pMaxRed, pMinGreen, pMaxGreen, pMinBlue, pMaxBlue); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onInitializeParticle(final Particle pParticle, final float pRed, final float pGreen, final float pBlue) { pParticle.setColor(pRed, pGreen, pBlue); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/ColorInitializer.java
Java
lgpl
1,965
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; import org.anddev.andengine.entity.particle.initializer.BaseSingleValueInitializer; /** * (c) 2011 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Scott Kennedy * @since 15:14:00 - 08.08.2011 */ public class ScaleInitializer extends BaseSingleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ScaleInitializer(final float pScale) { this(pScale, pScale); } public ScaleInitializer(final float pMinScale, final float pMaxScale) { super(pMinScale, pMaxScale); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onInitializeParticle(final Particle pParticle, final float pScale) { pParticle.setScale(pScale); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/ScaleInitializer.java
Java
lgpl
1,867
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:21:10 - 14.03.2010 */ public class VelocityInitializer extends BaseDoubleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public VelocityInitializer(final float pVelocity) { this(pVelocity, pVelocity, pVelocity, pVelocity); } public VelocityInitializer(final float pVelocityX, final float pVelocityY) { this(pVelocityX, pVelocityX, pVelocityY, pVelocityY); } public VelocityInitializer(final float pMinVelocityX, final float pMaxVelocityX, final float pMinVelocityY, final float pMaxVelocityY) { super(pMinVelocityX, pMaxVelocityX, pMinVelocityY, pMaxVelocityY); } // =========================================================== // Getter & Setter // =========================================================== public float getMinVelocityX() { return this.mMinValue; } public float getMaxVelocityX() { return this.mMaxValue; } public float getMinVelocityY() { return this.mMinValueB; } public float getMaxVelocityY() { return this.mMaxValueB; } public void setVelocityX(final float pVelocityX) { this.mMinValue = pVelocityX; this.mMaxValue = pVelocityX; } public void setVelocityY(final float pVelocityY) { this.mMinValueB = pVelocityY; this.mMaxValueB = pVelocityY; } public void setVelocityX(final float pMinVelocityX, final float pMaxVelocityX) { this.mMinValue = pMinVelocityX; this.mMaxValue = pMaxVelocityX; } public void setVelocityY(final float pMinVelocityY, final float pMaxVelocityY) { this.mMinValueB = pMinVelocityY; this.mMaxValueB = pMaxVelocityY; } public void setVelocity(final float pMinVelocityX, final float pMaxVelocityX, final float pMinVelocityY, final float pMaxVelocityY) { this.mMinValue = pMinVelocityX; this.mMaxValue = pMaxVelocityX; this.mMinValueB = pMinVelocityY; this.mMaxValueB = pMaxVelocityY; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onInitializeParticle(final Particle pParticle, final float pVelocityX, final float pVelocityY) { pParticle.getPhysicsHandler().setVelocity(pVelocityX, pVelocityY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/VelocityInitializer.java
Java
lgpl
3,193
package org.anddev.andengine.entity.particle.initializer; import static org.anddev.andengine.util.MathUtils.RANDOM; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:58:29 - 04.05.2010 */ public abstract class BaseTripleValueInitializer extends BaseDoubleValueInitializer { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mMinValueC; protected float mMaxValueC; // =========================================================== // Constructors // =========================================================== public BaseTripleValueInitializer(final float pMinValueA, final float pMaxValueA, final float pMinValueB, final float pMaxValueB, final float pMinValueC, final float pMaxValueC) { super(pMinValueA, pMaxValueA, pMinValueB, pMaxValueB); this.mMinValueC = pMinValueC; this.mMaxValueC = pMaxValueC; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onInitializeParticle(final Particle pParticle, final float pValueA, final float pValueB, final float pValueC); @Override protected final void onInitializeParticle(final Particle pParticle, final float pValueA, final float pValueB) { this.onInitializeParticle(pParticle, pValueA, pValueB, this.getRandomValueC()); } // =========================================================== // Methods // =========================================================== private final float getRandomValueC() { if(this.mMinValueC == this.mMaxValueC) { return this.mMaxValueC; } else { return RANDOM.nextFloat() * (this.mMaxValueC - this.mMinValueC) + this.mMinValueC; } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/BaseTripleValueInitializer.java
Java
lgpl
2,431
package org.anddev.andengine.entity.particle.initializer; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:12:09 - 29.06.2010 */ public interface IParticleInitializer { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public void onInitializeParticle(final Particle pParticle); }
zzy421-andengine
src/org/anddev/andengine/entity/particle/initializer/IParticleInitializer.java
Java
lgpl
651
package org.anddev.andengine.entity.particle; import static org.anddev.andengine.util.MathUtils.RANDOM; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_X; import static org.anddev.andengine.util.constants.Constants.VERTEX_INDEX_Y; import java.util.ArrayList; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.Entity; import org.anddev.andengine.entity.particle.emitter.IParticleEmitter; import org.anddev.andengine.entity.particle.emitter.RectangleParticleEmitter; import org.anddev.andengine.entity.particle.initializer.IParticleInitializer; import org.anddev.andengine.entity.particle.modifier.IParticleModifier; import org.anddev.andengine.opengl.texture.region.TextureRegion; import org.anddev.andengine.opengl.vertex.RectangleVertexBuffer; import android.util.FloatMath; /** * TODO Check if SpriteBatch can be used here to improve performance. * * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:42:27 - 14.03.2010 */ public class ParticleSystem extends Entity { // =========================================================== // Constants // =========================================================== private static final int BLENDFUNCTION_SOURCE_DEFAULT = GL10.GL_ONE; private static final int BLENDFUNCTION_DESTINATION_DEFAULT = GL10.GL_ONE_MINUS_SRC_ALPHA; private final float[] POSITION_OFFSET = new float[2]; // =========================================================== // Fields // =========================================================== private final IParticleEmitter mParticleEmitter; private final Particle[] mParticles; private int mSourceBlendFunction = BLENDFUNCTION_SOURCE_DEFAULT; private int mDestinationBlendFunction = BLENDFUNCTION_DESTINATION_DEFAULT; private final ArrayList<IParticleInitializer> mParticleInitializers = new ArrayList<IParticleInitializer>(); private final ArrayList<IParticleModifier> mParticleModifiers = new ArrayList<IParticleModifier>(); private final float mRateMinimum; private final float mRateMaximum; private final TextureRegion mTextureRegion; private boolean mParticlesSpawnEnabled = true; private final int mParticlesMaximum; private int mParticlesAlive; private float mParticlesDueToSpawn; private int mParticleModifierCount; private int mParticleInitializerCount; private RectangleVertexBuffer mSharedParticleVertexBuffer; // =========================================================== // Constructors // =========================================================== /** * Creates a ParticleSystem with a {@link RectangleParticleEmitter}. * @deprecated Instead use {@link ParticleSystem#ParticleSystem(IParticleEmitter, float, float, int, TextureRegion)}. */ @Deprecated public ParticleSystem(final float pX, final float pY, final float pWidth, final float pHeight, final float pRateMinimum, final float pRateMaximum, final int pParticlesMaximum, final TextureRegion pTextureRegion) { this(new RectangleParticleEmitter(pX + pWidth * 0.5f, pY + pHeight * 0.5f, pWidth, pHeight), pRateMinimum, pRateMaximum, pParticlesMaximum, pTextureRegion); } public ParticleSystem(final IParticleEmitter pParticleEmitter, final float pRateMinimum, final float pRateMaximum, final int pParticlesMaximum, final TextureRegion pTextureRegion) { super(0, 0); this.mParticleEmitter = pParticleEmitter; this.mParticles = new Particle[pParticlesMaximum]; this.mRateMinimum = pRateMinimum; this.mRateMaximum = pRateMaximum; this.mParticlesMaximum = pParticlesMaximum; this.mTextureRegion = pTextureRegion; this.registerUpdateHandler(this.mParticleEmitter); } // =========================================================== // Getter & Setter // =========================================================== public boolean isParticlesSpawnEnabled() { return this.mParticlesSpawnEnabled; } public void setParticlesSpawnEnabled(final boolean pParticlesSpawnEnabled) { this.mParticlesSpawnEnabled = pParticlesSpawnEnabled; } public void setBlendFunction(final int pSourceBlendFunction, final int pDestinationBlendFunction) { this.mSourceBlendFunction = pSourceBlendFunction; this.mDestinationBlendFunction = pDestinationBlendFunction; } public IParticleEmitter getParticleEmitter() { return this.mParticleEmitter; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void reset() { super.reset(); this.mParticlesDueToSpawn = 0; this.mParticlesAlive = 0; } @Override protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { final Particle[] particles = this.mParticles; for(int i = this.mParticlesAlive - 1; i >= 0; i--) { particles[i].onDraw(pGL, pCamera); } } @Override protected void onManagedUpdate(final float pSecondsElapsed) { super.onManagedUpdate(pSecondsElapsed); if(this.mParticlesSpawnEnabled) { this.spawnParticles(pSecondsElapsed); } final Particle[] particles = this.mParticles; final ArrayList<IParticleModifier> particleModifiers = this.mParticleModifiers; final int particleModifierCountMinusOne = this.mParticleModifierCount - 1; for(int i = this.mParticlesAlive - 1; i >= 0; i--) { final Particle particle = particles[i]; /* Apply all particleModifiers */ for(int j = particleModifierCountMinusOne; j >= 0; j--) { particleModifiers.get(j).onUpdateParticle(particle); } particle.onUpdate(pSecondsElapsed); if(particle.mDead){ this.mParticlesAlive--; final int particlesAlive = this.mParticlesAlive; particles[i] = particles[particlesAlive]; particles[particlesAlive] = particle; } } } // =========================================================== // Methods // =========================================================== public void addParticleModifier(final IParticleModifier pParticleModifier) { this.mParticleModifiers.add(pParticleModifier); this.mParticleModifierCount++; } public void removeParticleModifier(final IParticleModifier pParticleModifier) { this.mParticleModifierCount--; this.mParticleModifiers.remove(pParticleModifier); } public void addParticleInitializer(final IParticleInitializer pParticleInitializer) { this.mParticleInitializers.add(pParticleInitializer); this.mParticleInitializerCount++; } public void removeParticleInitializer(final IParticleInitializer pParticleInitializer) { this.mParticleInitializerCount--; this.mParticleInitializers.remove(pParticleInitializer); } private void spawnParticles(final float pSecondsElapsed) { final float currentRate = this.determineCurrentRate(); final float newParticlesThisFrame = currentRate * pSecondsElapsed; this.mParticlesDueToSpawn += newParticlesThisFrame; final int particlesToSpawnThisFrame = Math.min(this.mParticlesMaximum - this.mParticlesAlive, (int)FloatMath.floor(this.mParticlesDueToSpawn)); this.mParticlesDueToSpawn -= particlesToSpawnThisFrame; for(int i = 0; i < particlesToSpawnThisFrame; i++){ this.spawnParticle(); } } private void spawnParticle() { final Particle[] particles = this.mParticles; final int particlesAlive = this.mParticlesAlive; if(particlesAlive < this.mParticlesMaximum){ Particle particle = particles[particlesAlive]; /* New particle needs to be created. */ this.mParticleEmitter.getPositionOffset(this.POSITION_OFFSET); final float x = this.POSITION_OFFSET[VERTEX_INDEX_X]; final float y = this.POSITION_OFFSET[VERTEX_INDEX_Y]; if(particle != null) { particle.reset(); particle.setPosition(x, y); } else { if(particlesAlive == 0) { /* This is the very first particle. */ particle = new Particle(x, y, this.mTextureRegion); this.mSharedParticleVertexBuffer = particle.getVertexBuffer(); } else { particle = new Particle(x, y, this.mTextureRegion, this.mSharedParticleVertexBuffer); } particles[particlesAlive] = particle; } particle.setBlendFunction(this.mSourceBlendFunction, this.mDestinationBlendFunction); /* Apply particle initializers. */ { final ArrayList<IParticleInitializer> particleInitializers = this.mParticleInitializers; for(int i = this.mParticleInitializerCount - 1; i >= 0; i--) { particleInitializers.get(i).onInitializeParticle(particle); } final ArrayList<IParticleModifier> particleModifiers = this.mParticleModifiers; for(int i = this.mParticleModifierCount - 1; i >= 0; i--) { particleModifiers.get(i).onInitializeParticle(particle); } } this.mParticlesAlive++; } } private float determineCurrentRate() { if(this.mRateMinimum == this.mRateMaximum){ return this.mRateMinimum; } else { return (RANDOM.nextFloat() * (this.mRateMaximum - this.mRateMinimum)) + this.mRateMinimum; } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/ParticleSystem.java
Java
lgpl
9,411
package org.anddev.andengine.entity.particle; import org.anddev.andengine.engine.handler.physics.PhysicsHandler; import org.anddev.andengine.entity.sprite.Sprite; import org.anddev.andengine.opengl.texture.region.TextureRegion; import org.anddev.andengine.opengl.vertex.RectangleVertexBuffer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 19:37:13 - 14.03.2010 */ public class Particle extends Sprite { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private float mLifeTime; private float mDeathTime = -1; boolean mDead = false; private final PhysicsHandler mPhysicsHandler = new PhysicsHandler(this); // =========================================================== // Constructors // ===========================================================; public Particle(final float pX, final float pY, final TextureRegion pTextureRegion) { super(pX, pY, pTextureRegion); this.mLifeTime = 0; } public Particle(final float pX, final float pY, final TextureRegion pTextureRegion, final RectangleVertexBuffer pRectangleVertexBuffer) { super(pX, pY, pTextureRegion, pRectangleVertexBuffer); this.mLifeTime = 0; } // =========================================================== // Getter & Setter // =========================================================== public float getLifeTime() { return this.mLifeTime; } public float getDeathTime() { return this.mDeathTime; } public void setDeathTime(final float pDeathTime) { this.mDeathTime = pDeathTime; } public boolean isDead() { return this.mDead ; } public void setDead(final boolean pDead) { this.mDead = pDead; } public PhysicsHandler getPhysicsHandler() { return this.mPhysicsHandler; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onManagedUpdate(final float pSecondsElapsed) { if(!this.mDead){ this.mLifeTime += pSecondsElapsed; this.mPhysicsHandler.onUpdate(pSecondsElapsed); super.onManagedUpdate(pSecondsElapsed); final float deathTime = this.mDeathTime; if(deathTime != -1 && this.mLifeTime > deathTime) { this.setDead(true); } } } // =========================================================== // Methods // =========================================================== @Override public void reset() { super.reset(); this.mPhysicsHandler.reset(); this.mDead = false; this.mDeathTime = -1; this.mLifeTime = 0; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/Particle.java
Java
lgpl
3,069
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:22:26 - 29.06.2010 */ public class ColorModifier extends BaseTripleValueSpanModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ColorModifier(final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final float pFromTime, final float pToTime) { super(pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pFromTime, pToTime); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValues(final Particle pParticle, final float pRed, final float pGreen, final float pBlue) { pParticle.setColor(pRed, pGreen, pBlue); } @Override protected void onSetValues(final Particle pParticle, final float pRed, final float pGreen, final float pBlue) { pParticle.setColor(pRed, pGreen, pBlue); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/ColorModifier.java
Java
lgpl
2,050
package org.anddev.andengine.entity.particle.modifier; import static org.anddev.andengine.util.MathUtils.RANDOM; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:21:10 - 14.03.2010 */ public class ExpireModifier implements IParticleModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private float mMinLifeTime; private float mMaxLifeTime; // =========================================================== // Constructors // =========================================================== public ExpireModifier(final float pLifeTime) { this(pLifeTime, pLifeTime); } public ExpireModifier(final float pMinLifeTime, final float pMaxLifeTime) { this.mMinLifeTime = pMinLifeTime; this.mMaxLifeTime = pMaxLifeTime; } // =========================================================== // Getter & Setter // =========================================================== public float getMinLifeTime() { return this.mMinLifeTime; } public float getMaxLifeTime() { return this.mMaxLifeTime; } public void setLifeTime(final float pLifeTime) { this.mMinLifeTime = pLifeTime; this.mMaxLifeTime = pLifeTime; } public void setLifeTime(final float pMinLifeTime, final float pMaxLifeTime) { this.mMinLifeTime = pMinLifeTime; this.mMaxLifeTime = pMaxLifeTime; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onInitializeParticle(final Particle pParticle) { pParticle.setDeathTime((RANDOM.nextFloat() * (this.mMaxLifeTime - this.mMinLifeTime) + this.mMinLifeTime)); } @Override public void onUpdateParticle(final Particle pParticle) { } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/ExpireModifier.java
Java
lgpl
2,449
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:37:27 - 04.05.2010 */ public class ScaleModifier extends BaseDoubleValueSpanModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public ScaleModifier(final float pFromScale, final float pToScale, final float pFromTime, final float pToTime) { this(pFromScale, pToScale, pFromScale, pToScale, pFromTime, pToTime); } public ScaleModifier(final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final float pFromTime, final float pToTime) { super(pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pFromTime, pToTime); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValues(final Particle pParticle, final float pScaleX, final float pScaleY) { pParticle.setScale(pScaleX, pScaleY); } @Override protected void onSetValues(final Particle pParticle, final float pScaleX, final float pScaleY) { pParticle.setScale(pScaleX, pScaleY); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/ScaleModifier.java
Java
lgpl
2,160
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:36:18 - 29.06.2010 */ public class RotationModifier extends BaseSingleValueSpanModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public RotationModifier(final float pFromRotation, final float pToRotation, final float pFromTime, final float pToTime) { super(pFromRotation, pToRotation, pFromTime, pToTime); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValue(final Particle pParticle, final float pRotation) { pParticle.setRotation(pRotation); } @Override protected void onSetValue(final Particle pParticle, final float pRotation) { pParticle.setRotation(pRotation); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/RotationModifier.java
Java
lgpl
1,860