How to randomly create a sprite?

Show us your completed creations made in Construct 2

Post » Tue Sep 04, 2012 10:12 pm

I wish I could do the following:

Every time the system generate a sprite, I want to generate a random sprite, for example, I have 3 sprites, I add an event, every 4 seconds, the system need to randomly spawn one of those 3 sprites, any way to do it??
Posts: 2
Reputation: 429

Post » Tue Sep 04, 2012 10:53 pm

Well first of all, this should be in the "How do I...?" forums, the place for asking questions like this.

Second, the easiest way to do it is to make all 3 sprites separate frames of an animation. If you set the animation speed to 0, it won't change frame unless you change it yourself. So then you can make an event that says:

Every 4 seconds
-- System: Create Sprite at x,y
-- Sprite: Set animation frame to random(0,3)

"random(0,3)" will pick a random number out of 0, 1, or 2; 3 isn't included. Another way to say it is "choose(0,1,2)", which will randomly pick one of those three numbers.SullyTheStrange2012-09-04 22:54:16
Posts: 607
Reputation: 6,112

Return to Completed Creations

Who is online

Users browsing this forum: R0J0hound and 1 guest