Compare variables between select instances

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • 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)