libgdx actors and instant actions

Posted by vaati on Game Development See other posts from Game Development or by vaati
Published on 2013-09-11T17:18:41Z Indexed on 2013/11/11 22:18 UTC
Read the original article Hit count: 302

Filed under:
|

I'm having trouble with actors and actions. I have a list of actors, they all have either no action, or 1 sequence action

This sequence action has either :

  • a couple of actions (some are instant, some have duration > 0)
  • a couple of actions followed by a parallel action.

My problem is the following:

some of the instant actions are used to set the position and the alpha of the actor. So when one of the action is "move to x,y and set alpha to 0" the actor is visible for one frame at position 0,0 , move instantly to x,y for the next frame, and then disappears.

Though this behaviours is to be expected, I want to avoid it. How can I achieve that?

I tried to intercept the actions before I put actors in the stage but I need the stage width/height for some actions. So something like :

Action actionSequence = actor.getActions().get(0);
Array<Action> actions = ((SequenceAction) actionSequence).getActions();
for(Action act : actions){
    if(act.act(0))
        System.out.println("action " + act.toString() + " successfully run");
    else
        System.out.println("action " + act.toString() + " wasn't instant");
}

won't work.

It gets even more complicated when an actor can also have a repeat action in stead of the sequence action (because you have to only run the actions that have duration 0 once without repeat, and then start the repeat).

Any help is appreciated.

© Game Development or respective owner

Related posts about java

Related posts about libgdx