How do I rondomly select an animation for an object?

Get help using Construct 2

Post » Sat Jul 23, 2016 6:37 pm

Hey there, so I have 3 enemy variations for this game where the player is stationary in the middle of the screen and enemies are spawned around him in a random position.

I was wondering if it was possible to make it so that when they spawn, they are a random 1 of the 3 enemy sprites I have.
Basically, have a line of code that makes it so when the enemy is spawned, they are a random 1 of 3 sprite animations (Each animation is just a variation of the enemy).

Thanks again guys! :D
B
6
Posts: 4
Reputation: 260

Post » Sat Jul 23, 2016 7:18 pm

@bigmonongo sorry my mistake ...
Last edited by BillAlex on Sat Jul 23, 2016 8:14 pm, edited 1 time in total.
B
5
S
1
Posts: 24
Reputation: 423

Post » Sat Jul 23, 2016 7:51 pm

Message: Programmer25 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@bigmonongo

Ok, this is something I made very quick, you should tweak it to work for 3 animations and to work better

Trigger a random animation when an enemy is spawned:
http://i.imgur.com/UI4OPuf.jpg
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Sat Jul 23, 2016 7:59 pm

Name all your animations with growing numbers. Example: Ani1, Ani2, Ani3, Ani4.
Then, in the field to select animation (if you have 10 animations), put this text:
"Ani" & rand(1,10)
Last edited by DaniellMesquito on Sun Jul 24, 2016 8:58 pm, edited 1 time in total.
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
28
S
9
G
4
Posts: 359
Reputation: 4,246

Post » Sat Jul 23, 2016 8:06 pm

@DaniellMesquita nice work, I havent thought of doing it that way
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Sat Jul 23, 2016 8:11 pm

Sorry @Programmer25
@DaniellMesquita My english is not the best and I have read his questien like -> a have solve my problem by self
Sorry :| :oops:
B
5
S
1
Posts: 24
Reputation: 423

Post » Sun Jul 24, 2016 5:16 am

@BillAlex Oh, no problem. Who need ask sorry is me, I encounter people here that ironize beginner users, but now I know that isn't your case, then sorry :oops:
My english too is not very good, I'm from Brazil.
Last edited by DaniellMesquito on Sun Jul 24, 2016 6:09 am, edited 2 times in total.
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
28
S
9
G
4
Posts: 359
Reputation: 4,246

Post » Sun Jul 24, 2016 5:19 am

@Programmer25, thanks, you're welcome too, nice know that I can help you. Any other question, please ask or send me a private message.
Last edited by DaniellMesquito on Sun Jul 24, 2016 6:05 am, edited 2 times in total.
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
28
S
9
G
4
Posts: 359
Reputation: 4,246

Post » Sun Jul 24, 2016 5:29 am

Hi ,
you can use the expression "choose".
For example if you have the animations "default", "fly", and "run" ; you can use : SET ANIMATION TO - Choose("default","fly","run")...
B
17
S
10
G
19
Posts: 140
Reputation: 11,457

Post » Sun Jul 24, 2016 6:07 am

@Saad-Swad, very good, more simple and direct than my idea. \o/
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
28
S
9
G
4
Posts: 359
Reputation: 4,246

Next

Return to How do I....?

Who is online

Users browsing this forum: irina and 11 guests