Swing a sprite in Andengine

211 views Asked by At

I am developing an app using andengine in which there is an ornament hanging with string. I need to swing it like a pendulum in a loop. I tried to make this happen with rotation modifier inside loop modifier making the center of rotation at the top center point of sprite but it only swing in on direction and then jump straight to the starting point and so on. Following is the code i used.

Is there a ready made modifier for swinging action? of yes, which one, if no, how can i achieve this.

It would be great if you can provide a sample code snippet.

ornament.registerEntityModifier(new LoopEntityModifier(new RotationModifier(2, 0, 20, EaseLinear.getInstance())));

1

There are 1 answers

0
Rama On BEST ANSWER

you can implement in this way

SequenceEntityModifier seq = new SequenceEntityModifier(new RotationModifier(2, 0, 20, EaseLinear.getInstance()), new RotationModifier(2, 20, 0, EaseLinear.getInstance()));
        ornament.registerEntityModifier(new LoopEntityModifier(seq));

Try this