How do I random sprite animation frame

0 favourites
  • 5 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • A. Default display is sprite_all, I create it , make 4 copy of that, and I want to set a random change to Red animation, I set sprite_all animation set to int(random(4)), another action is animation "Red" . However, 4 sprite_all change to Red animation at the same time. I also try to use choose(0,1,2,3) , but it is same result.

    sprite_all:

    Frame number Animation

    0 1 2 3 Black

    0 1 2 3 Red

    0 1 2 3 Yellow

    B. Should split 4 sprite, like the below, is it easy to have the effect?

    sprite_0

    Frame number Animation

    0 Black

    0 Red

    0 Yellow

    sprite_1

    Frame number Animation

    0 Black

    0 Red

    0 Yellow

    sprite_2

    Frame number Animation

    0 Black

    0 Red

    0 Yellow

    sprite_3

    Frame number Animation

    0 Black

    0 Red

    0 Yellow

  • You're probably either forgetting For Each or forgetting to pick by specific instance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you copy sprites and then make a change to animation frames it affects all those sprites unless you pick a specific sprite by instance variable.

    That doesn't apply when you create a sprite which can be set differently but does if those sprites are all in existence on the layout.

    So you need to assign each sprite an instance and use that to pick which sprites change their animation frame.

  • Forget picking by instance variable. Just pick by UID.

  • Thanks for all reply, but I need to set this situation, so maybe not to use UID.

    1. random display one : sprite 1/2/3/4 (one only)

    2. after a keyboard press a Key a then sprite 1 will destroy.

    3. another random display one : sprite 1/2/3/4 (one only)

    ......

    loop

    I search many post of that, but really don't know how to setup the script, please help me.

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