Need to add up two object's instance variables on overlapping Drop - Families?

  • Been scratching my head at this one, I feel like I'm right on the cusp of solving.

    I have several Drag&Drop objects in the scene. They all start at pointValue=1.

    If I drag one object onto another, I need to destroy the other object and add that object's value to the initial object I dropped. (and in turn changing it's visuals) So if I drop a 1 on a 1 - I get one combined object with 2 value. If I drop that 2 value object on a 1 - I get a single 3 object. But then I can take a 1 value and drop it back onto that 3 object and get a single 4. Needs to be versatile.

    Trying to use Families, making duplicate families, trying Pick Nth (I don't have a ton of Families experience, but maybe I'm overthinking - I'm on the brink of just brute forcing the code. Any help is appreciated - thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • WELL - I "solved" it for now. Seems to work but I have a strong feeling this is not the best way to go about it.

  • If papersA family is a 'clone' of Paper sprite, then you did it almost right! Simply define the pointValue variable on the family (remove it from the sprite). Then you'll be able to do Paper add (PapersA.PointValue) to PointValue

    Otherwise your approach is correct.

    .

    If you already have lots of other events where you reference PointValue variable, see this tutorial on how to move it easily to the family level:

    scirra.com/tutorials/535/how-to-upgrade-an-object-to-a-family

  • dop2000 Awesome, thank you!

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