Khawar
Khawar

Reputation: 5227

How to apply scaleModifier to Animated Sprite when it is touched (AndEngine)

I want to apply scaleModifier on a Sprite when it is touched. I apply the scaleModifier like below:

mMySprite.registerEntityModifier(new ScaleModifier(2f, 1f, 0.5f));

There is also a Dynamic body attached to this. I read that the body will not be changed but atleast the sprite should be scaled. But nothing happens. Can any one tell me how can I do this and whats missing?

Upvotes: 0

Views: 1772

Answers (1)

Jong
Jong

Reputation: 9115

I have this code:

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
     ....
     (Some AnimatedSprite object).registerEntityModifier(new ScaleModifier(2, 1, 0.5f));
     ....
}

And it works fine. Make sure that if you use IOnSceneTouchListener you also register it:

scene.setOnSceneTouchListener(...);

Or, if you decided to override onAreaTouch method, make sure you register your animated sprite as a touch area:

scene.registerTouchArea(yourAnimatedSprite);

Upvotes: 1

Related Questions