omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Scene: detect when an action has finished processing

    Pythonista
    action scene module
    4
    5
    3653
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JBell
      JBell last edited by

      I am creating a turn based game and would like to run action sequences on SpriteNodes then once finished run some code then another action sequence.

      Is it possible to detect when an action or action sequence has finished? In the documentation there seems to be a paused attribute for nodes. However, I didn’t seem to be able to get anything other than false before and after actions. Any help would be appreciated.

      Thanks

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        If you want an Action to directly follow another Action, you use an Action.sequence to chain together two actions. But, if you don't know what the next action will be when you create it, you could use an Action.call in the sequence.

        For instance, suppose you have an enemy which moves 10 steps, then when it is done moving, turns towards the player and moves again. you could set a .moving flag, then have a sequence that consists of

        Action.sequence(Action.move_by(...), Action.call(done_moving) )

        The second action could be an Action.call, which, for instance, simply sets a flag.

        1 Reply Last reply Reply Quote 1
        • adrius42
          adrius42 last edited by

          I launched an action to spin all the cards off the screen and then I wanted to put up a new start menu, but that wasn’t apparently a callable Object, so the menu pops up and the cards all get stuck half way through spinning off the screen.

          Thanks for the other pointer tho’ I will explore the implications of that hint...

          1 Reply Last reply Reply Quote 0
          • ellie_ff1493
            ellie_ff1493 last edited by

            try looking at Action.call(yourfunction)

            1 Reply Last reply Reply Quote 1
            • JBell
              JBell last edited by

              Thank you for suggesting Action.call. This is exactly what I needed. I had overlooked this in the documentation.

              In the end, I created a sub class of the SpriteNode and modified the run_action method to add an action.call at the beginning and end of the action sequence. So every card that gets animated adds it’s name to stack of actions that are currently animating.

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              Powered by NodeBB Forums | Contributors