------

[ AD ] Port Monitor ( Try to use a Best WebSite Monitoring Tool )

------

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);
	}


+ Recent posts