How do I choose a random sprite?

Get help using Construct 2

Post » Wed Nov 26, 2014 6:10 am

I have 10 sprites off-layout: 5 good guys and 5 bad guys
What is the best way to randomly choose one of the 10, then spawn a duplicate?
B
29
S
14
G
9
Posts: 80
Reputation: 5,998

Post » Wed Nov 26, 2014 6:32 am

This gets asked a lot :) Have a search around you'll find ideas.

viewtopic.php?f=147&t=117498&p=851769&hilit=choose+random+sprite#p851769
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Nov 26, 2014 7:00 am

I'm hoping to generate a random sprite, and if they correctly identify it as good or bad the sprite will animate.

If I use the choose command to randomly select a still animation frame (from within the same sprite), how will I know which animation to play if they identify it correctly?

Basically, I'm trying to have one random sprite on the screen at a time. The user decides if it is good or bad (collision detection with another object). The sprite animates, then destroys itself, and a new random good/bad guy is generated.
B
29
S
14
G
9
Posts: 80
Reputation: 5,998

Post » Wed Nov 26, 2014 8:13 am

ok so stick with the different sprites.
Put the sprites in a family
Spawn an instance of the family (which spawns a random sprite from the family)
Do what you want with it..
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot], zenox98 and 6 guests