Using Modifiers -- Rokon Game Engine
public class ColorModifier extends Modifier { private float color; @Override public void onStart(Sprite sprite) { color = 0; } @Override public void onUpdate(Sprite sprite) { // Here you can do anything to the sprite, like move it or whatever. // But we will just do a simple color modification. sprite.setRGB(1, color, color); color += 0.1; // When the sprite's original colors has been restored, end it. if (color >= 1) end(); } @Override public void onEnd(Sprite sprite) { sprite.setRGB(1, 1, 1); } }
private ColorModifier modifier; public GameScene() { super(1, 1); setBackground(background = new FixedBackground(Textures.background)); // Create the Bob sprite bob = new Sprite(100, 220, Textures.bob.getWidth(), Textures.bob.getHeight()); bob.setTexture(Textures.bob); // Add the Bob sprite to the first layer. add(0, bob); // And create the modifier. modifier = new ColorModifier(); } @Override public void onGameLoop() { } @Override public void onTouchUp(float x, float y, MotionEvent event, int pointerCount, int pointerId) { // Add your modifier to the sprite. bob.addModifier(modifier); }
'0.일반개발' 카테고리의 다른 글
JSConf.eu 2010 (0) | 2010.09.30 |
---|---|
Android Course Archive /* by 구글 Google Code University */ (0) | 2010.09.29 |
Using Touch Input -- Rokon Game Engine (0) | 2010.09.29 |
Using Sprites -- Rokon Game Engine (0) | 2010.09.29 |
HelloWorld -- Rokon Game Engine (0) | 2010.09.29 |