Select UID on click

Discussion and feedback on Construct 2

Post » Mon Oct 28, 2013 5:22 am

Is it possible to get an objects UID when on click? For example, I have many instances of a sprite Object "weapon." I would like to be able to click on a weapon in the game, and on click have it set it UID to an instance variable.

I am using an array to store all the weapon stats, eg, attack, rate of fire etc. I would like to be able to click on the weapon and then find the array by comparing the instance variable UID to the array and finding the appropriate stats.

Is this possible or am I going about it all wrong?



B
9
Posts: 12
Reputation: 351

Post » Mon Oct 28, 2013 10:20 pm

You should be able to do that using the "on object clicked" event in the mouse object. It allows you to select the sprite/object clicked on. You should then be able to get the UID through object.UID expressions.

example:
Event: On gun(sprite) clicked
action: -> add gun.uid to myArray
"In truth we live, In Truth we die"
B
11
S
3
G
4
Posts: 22
Reputation: 3,177

Post » Mon Oct 28, 2013 11:41 pm

Thank you! I did not know that clicking an object selected it, thank you very much!
B
9
Posts: 12
Reputation: 351


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests