Referencing a Specific Instance of an Object

For questions about using Classic.

Post » Mon Mar 30, 2009 9:41 pm

The game I'm working on now has a little square walking to a random image point on a node when you click on the area.

The character object holds a private variable with the assigned ID number of the node that it walked to last. The nodes have an array of twelve numbers that represent the image points of the node. When the character walks to a node, I set the corresponding item in the array to a 1.

My question is how can I set the item in the array of the node that the character is leaving to a zero before it leaves for the target node? Do I need to loop through all the nodes and check to see if the node id is equal to the node ID stored in the character? It seems like there should be a better way...

Download The Cap Here

P.S. further down the line, I'd like to have multiple characters that take turns moving when you click. If you have any helpful hints for that, please let me gnow.

Thanks everybody for any suggestions
B
4
G
3
Posts: 21
Reputation: 942

Post » Tue Mar 31, 2009 5:44 pm

to pick your current node, you could use the 'Pick by evaluate' condition and use the expression "node('nodeID') == character('nodeID')". i don't know if there is a better way than using a single condition for this :P
you might need to invoke the condition through a function set to forget your picked objects if you plan on doing this in the scope of the 'node clicked' event (to gain access to the non-clicked nodes).
B
2
S
2
G
4
Posts: 171
Reputation: 1,792

Post » Tue Mar 31, 2009 7:06 pm

[quote="dkdoom":151yojts]to pick your current node, you could use the 'Pick by evaluate' condition and use the expression "node('nodeID') == character('nodeID')". i don't know if there is a better way than using a single condition for this :P
you might need to invoke the condition through a function set to forget your picked objects if you plan on doing this in the scope of the 'node clicked' event (to gain access to the non-clicked nodes).[/quote:151yojts]


Thank you so much for your help, dkdoom. That really pointed me in the right direction. It turns out that each object automatically gets a unique ID that you can reference it by. Excuse me, I meant "by which you can reference it."

Here is the new improved cap. When the character moves to a node, the node array gets a 1 in the location that the character moved to and the old node's array gets a zero in the position where the character used to be.
Download The Cap Here

Next up, I will try to put in multiple characters and have them take turns moving.

Thanks again!
B
4
G
3
Posts: 21
Reputation: 942


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests