I'm trying to have a sprite ("pointer" below) along two paths, one after the other. Here is my code:
scene.attachChild(pointer);
pointer.clearEntityModifiers();
pointer.registerEntityModifier(new MoveModifier(
1.0f, 540, 960, 1000, 1000,
new IEntityModifierListener() {
public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {}
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
clickSound.play();
pointer.clearEntityModifiers();
pointer.registerEntityModifier(new MoveModifier(
1.0f, pointer.getX(), pointer.getY(), 500, 2500,
new IEntityModifierListener() {
public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {}
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
pointer.clearEntityModifiers();
pointer.detachSelf();
}
},
EaseCubicInOut.getInstance()
));
}
},
EaseCubicInOut.getInstance()
));
The pointer moves along the first path as expected, and then the clickSound plays, and then nothing happens. The second MoveModifier doesn't have any effect. What am I doing wrong here?
I'm not sure why your code is not working, but I think you can achieve the same thing using the SequenceEntityModifier:
scene.attachChild(pointer);
pointer.clearEntityModifiers();
pointer.registerEntityModifier(new SequenceEntityModifier(
new MoveModifier#1(...),
new MoveModifier#2(...)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With