0
\$\begingroup\$

I'm trying to get the delay action in scene2d working correctly. I have multiple image objects which I store in an array and I have managed to get them all displaying, scaling and moving correctly. I can't however seem to get them moving independently using the delay action.

I have tried using the sequence action and that isn’t working either…

I’m trying to create transition effects using little squares that move off the screen.

I have included a sample of the code im using below:

for (i = 0; i < scaleActions.length; i++) {
    ScaleByAction scaleAction = new ScaleByAction();
    scaleAction.setAmount(-0.1f);
    scaleAction.setDuration(0.5f);

    scaleActions[i] = scaleAction;
}

float increase = 0;
for (i = 0; i < delayActions.length; i++) {
    DelayAction delayAction = new DelayAction();
    delayAction.setDuration(0.05f+increase);
    increase += 0.1;
    delayActions[i] = delayAction;

}

for (i = 0; i < boxArray.length; i++) {
    SequenceAction sequence = new SequenceAction(scaleActions[i],moveActions[i],delayActions[i]);
    boxArray[i].setOrigin(boxW / 2, boxH / 2);
    boxArray[i].addAction(sequence);

    //boxArray[i].addAction(sequenceActions[i]);
    //boxArray[i].addAction(scaleActions[i]);
    //boxArray[i].addAction(moveActions[i]);
    //boxArray[i].addAction(delayActions[i]);
}

public void addToStage() {

    for (i = 0; i < boxArray.length; i++) {

        stage.addActor(boxArray[i]);
    }
}

Everything seems to be moving and scaling at the same time, the delay doesn’t look like it is even working.

Hope you guys can help point out what I'm doing wrong.

\$\endgroup\$
0
\$\begingroup\$

When creating a SequenceAction, the order of parameters matters. Your code is telling it to scale, then move, then delay. Since delay is the last action, it doesn't really do anything.

\$\endgroup\$
  • \$\begingroup\$ Thanks John...that was the one thing i didnt do! thanks for pointing me in the right direction. \$\endgroup\$ – Amar_H Nov 18 '16 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.