Referencing a Specific Instance of an Object

This forum is currently in read-only mode.
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • 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

  • Try Construct 3

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

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

  • 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

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

    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!

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