Compare variables between select instances

Get help using Construct 2

Post » Tue Dec 04, 2012 10:03 pm

Here's what I need to do:

https://www.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?
B
4
Posts: 15
Reputation: 330

Post » Tue Dec 04, 2012 11:27 pm

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.




B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Tue Dec 04, 2012 11:31 pm

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.
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Wed Dec 05, 2012 1:01 am

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
B
4
Posts: 15
Reputation: 330

Post » Wed Dec 05, 2012 1:59 am

I would like to see this sample too please :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834


Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, farfetchd83, mjj1990, Yahoo [Bot] and 3 guests