Animate basic sprite frames on request?

  • I have a really basic sprite (called Player) that has 4 frames of animation and sits on a FloorLayer with solid behaviour enabled.

    Frames 0 and 1 are the basic legs up/down running states. Frame 2 is the jump state and frame 3 is the downwards state (the state between jumping and falling back down to start running again in frames 1 & 2).

    I currently have the following:

    Mouse > On any click > Player > Simulate Platform pressing Jump.

    This moves the sprite up in a jump motion. But the sprite continually runs through frames 1 > 3 including the jump & downwards states.

    How do I edit the event sheet to run just frames 0 and 1 for running and frame 2 when in the jump state and frame 3 after the jump state and returning to the FloorLayer?

    Thanks all :)

  • Set the animation speed to 0, and just set the frame with events depending on if it's jumping or falling. For the running you can come up with a nice expression that changes between 0 and 1 over time.

    is jumping
    -- set frame to 2
    else
    is falling
    -- set frame to 3
    else
    -- set frame to int(10*time)%2

    The 10 in the last expression is the frames per second.

    But you can make it in another way too. No need for fancy expressions.

    global number runframe=0
    
    every 0.1 seconds
    -- set runframe to 1-runframe
    
    every tick
    -- set frame to runframe
    
    is jumping
    -- set frame to 2
    
    is falling
    -- set frame to 3
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Smashing thanks.

    There's so many sub-events with each behaviour that I didn't know Plaform is Jumping, Platform is Falling are even things. I suppose you don't know they're there until you need to use them.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)