How do I create object family no duplicates

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • i want to create all the objects in a family at start of layout but without any duplicates.

    i have read this can be done with arrays, but im not sure how to do it

    please help

  • Creating a Family object will give you a random object in that family anyway, so you want to create each object individually.

  • Yes but if I create each individual object I will have to have about 10 events multiplied by 30

    I will end up with 300 events just for this small bit of the game

  • Then you can look at the Nickname plugin by RexRainbow to help.

  • I have tried that plugin but you can't assign any actions to the the nickname of an object

  • I have seen this but don't know how to do it

    https://www.scirra.com/forum/viewtopic.php?f=147&t=110419

  • You give each object a nickname. Then depending on the name (if you use a number there's one less step), you can fill an array with the names and pull names out of the array, using a random number generator.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • why do you create objects? why not use the hats body and pants objects and have multiple frames, and every 3 seconds or when u need it just change the frame....

    and then add a condition of each curent item and check for it if its already existing then reselect another 1... creating objects is a bit cpu intensive... changing frames and using the same object is faster and easier.

    youl need a local variable though... to save the curent frame of each item.

    now depends on how many hats and pants and items you have on screen... i see you using for each familly ... that means you have quite some objets at 1 time in screen...

    edited: here is the capx i was saying proving my knowledge for multiple items, i created instead 1 familly holding the entire sprites, and keeping the 2 variables the curent frame and picked frame.

    there are hats/belts/and feet

    every 3 seconds for each famillymember we change the pickedframe variable to random 0 , selfanimationframecount

    then we check the curentframe variable and picked frame if their not equal then we set curentframe to the pickedframe value and set animation to curentframe

    else we pick again a new frame.

    however my aproach is only applying to items that are not randomly generated, for that better to use the plugin above i guess... or create the obejcts hats/etc separated from their famillies... and then apply the code in my capx.

  • Thanks

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