How to randomly create a sprite?

0 favourites
  • 2 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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??

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well first of all, this should be in the "How do I...?" forums, the place for asking questions like this. <img src="smileys/smiley2.gif" border="0" align="middle" />

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)