How do I random sprite animation frame

Get help using Construct 2

Post » Mon Mar 06, 2017 2:39 pm

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
B
4
Posts: 2
Reputation: 204

Post » Mon Mar 06, 2017 5:14 pm

You're probably either forgetting For Each or forgetting to pick by specific instance.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Mon Mar 06, 2017 5:23 pm

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.
Banned User
B
28
S
7
G
58
Posts: 1,229
Reputation: 34,830

Post » Mon Mar 06, 2017 5:45 pm

Forget picking by instance variable. Just pick by UID.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Thu Mar 09, 2017 12:41 am

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.
B
4
Posts: 2
Reputation: 204


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests