Is it possible to have random death animations?

For questions about using Classic.

Post » Sat Jun 05, 2010 4:44 pm

I have a top down shooter, and I want to make multiple death poses for each character. Is it possible for the game to pick one at random and select it to use it? Thanks.
B
1
G
2
Posts: 8
Reputation: 641

Post » Sat Jun 05, 2010 5:05 pm

Yes, off the top of my head I'd say have 4 animations named 0,1,2,3 then:
sprite.privatevariable less than 0
-> set another.privatevariable to random(3)
-->another.privatevariable = 0 play animation 0
->another.privatevariable = 1 play animation 1
-->another.privatevariable = 2 play animation 2
-->another.privatevariable = 3 play animation 3

Edit might want to put an int() in there for the random
int(random(3))
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat Jun 05, 2010 5:18 pm

You can also do it in one line of code using string concatenation, which has the added benefit of letting you use properly named animations:

Death animations

Press the "space" key to trigger a random animation.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Sat Jun 05, 2010 5:58 pm

You can also use unique names for each animation and select one randomly like so:
[code:3dr39l0j]-> Sprite: Set animation to {"die","brutal","ahhh","rip"} @ (random(4)+1)[/code:3dr39l0j]
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Sat Jun 05, 2010 6:38 pm

Thank you so much, Linkman2004, I got it.
B
1
G
2
Posts: 8
Reputation: 641


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests