Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top