How do I spawn a random sprite out of a set of sprites?

0 favourites
  • 5 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hi, I've recently been trying families in C2 and I found out you can't edit them during runtime which is bad considering what I'm trying to achieve.

    Basically, I've 16 sprites (4 shapes, 4 colors) and I want to determine which ones to pick on spawn Family.

    The 1st shape in its 4 colors is unlocked so the player can play the levels, the other 3 shapes will probably be an IAP.

    The level itself determines which colors to spawn according to the colors of the exits.

    So for example in level 1 I want Yellow and Blue to spawn so that becomes 8 sprites but if the player hadn't bought the rest of the shapes it'll only be 2 sprites.

    Sorry if I make it look confusing if it's not already is.

  • You can create several families with different combinations of sprites and use them for spawning.

    E.g.: SpritesFree, SpritesFreePlusPaid1, SpritesFreePlusPaid2, SpritesAll

    Then when you need to spawn a new object, select one of the families depending on which one the player has bought.

    Or since you only have 16 sprites, you can write a simple event like this:

    If r=0 Spawn sprite0
    If r=1 Spawn sprite1
    If r=7 & <player purchased this sprite type> Spawn sprite7
    If r=8 & <player purchased this sprite type> Spawn sprite8
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 but that'd still spawn different colors than the ones needed for the levels or it would not spawn anything in case of r={7,8,etc.}

    This is what I've reached so far for color Blue (They're currently 3 shapes only)

    Would this even work? Should I continue for the rest of the colors or is there a better way of doing this?

  • Ok, here is the modified code:

  • dop2000 Thanks, never used return values before but seems pretty less confusing than what I have.

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