How do I select a random sprite from a family

  • Hello,

    I would like to select a random sprite from a family and then would like to duplicate that sprite 2-3 times, I found spawn new object and can select the family but as or right now it just selects them at random.

    Also on the other side of things, I would like to use an event on touch to count the numbers of sprites that were generated for that family.

    Any push in the right direction would be great.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's difficult, maybe impossible, to identify and pick an object type in a family like this, you don't really use families in this way. It is better to just pick a random number i.e. choose(0,1,2,3) and then the number will apply to the spawning of an object, families will not help here.

    When you pick the object to spawn you then put the create object action through a for loop with the choose(2,3) in place as the number of times to loop.

    Not sure what the touch event is but you can count the number of objects that were spawned with the result of choose(2,3). If you want the total number of objects in a family it is family.count.

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