0 Favourites

Compare variables between select instances

  • Here's what I need to do:

    dropbox.com/s/8yisl6w294ebsu0/locked.jpg

    If you look at the image, you'll see I have a bunch of instances of a tile. Each tile has 3 variables. What I'm having trouble figuring out, is how to compare the variables of two neighboring tiles, and if they match add a point to the score of my game.

    So, what I want is: if v1yellow = v1blue, or if v2yellow = v2blue, add a point. But NOT if v1yellow = v1purple, because they are too far away from each other. It would be nice to say "if a tile is x distance away from another tile, and the V1's or V2's match, add a point" but I'm not sure how to do that in construct2...

    Any ideas?

  • I have personally found that comparing same family/instance objects takes a little more work.

    Every object has a UID(Unique ID related to all objects in the game) and an IID(instance ID related to those of the same object).

    You will need either of those values(not both). At this point however I don't know how your game works. So I am only going to give you a relation as if your hex game was similar to a memory match style game.

    Memory match is about choosing 2 "cards". So let's go with that.

    var selected = 0

    var iidHex = -1

    var compare = ""

    ------------

    cnd: Touch on touched Hex

    ->sub event-cnd: selcted = 0

    ->action: iid = Hex.iid

    ->action:selected = 1

    ->sub event-cnd: selcted = 1

    ->action: compare = hex.variable

    ->sub event pick Nth instance of Hex

    ->action: compare two values(compare, Hex.variable)

    Now I'm sure a master can do this better, but this is the idea your going for.

  • jayderyu presented an example, but not the easiest nor the quickest at that.

    If you haven't already, and would like me to, I can create an example.

  • if you have an easier way, I'd love an example. I'm new to Construct, so I'd like multiple options to try in case I fail at one :P

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I would like to see this sample too please :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[Plugin] instance bank2
85 18,369
rexrainbow's avatar
rexrainbow
Unread hot topic
64 12,941
trollface's avatar
trollface
Unread hot topic
0 Favourites
[PLUGIN] Instance Group
50 17,109
sagispin's avatar
sagispin