PSA: Families and specific objects

0 favourites
  • 1 posts
From the Asset Store
I-Spy (Hidden objects)
$34.30 USD
30% off
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Short version: You can assign instance variables to objects themselves before they are created as an instance, which remain true when they are created. I used this to narrow down the random Family object creation.

    Long version: I was struggling with a need to create random object instances while also needing to limit what could be created from them. Specifically I wanted to create sprite people who could be either male or female but they were lumped into the same Family for easy spawning but I had no way to know which were male and which were was female (from event perspective) so I couldn't further more specific characteristics to them such as random female names, and random female names which corresponded to their appearance.

    It finally dawned on me that you can set the instance variable directly to the object and it holds that value on creation, thus I can create objects using the family, then check when they are created if it holds a male or female variable and assign further attributes accordingly.

    I hope this helps someone else out there, though it may be obvious looking back.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)