How do I select 1 unit at a time?

Get help using Construct 2

Post » Tue May 05, 2015 10:33 am

I'm talking about cloned versions of the same unit.

I want it so that if I click on a unit it becomes selected (Instance variable "selected" = 1)

Then if I click a cloned version of that same unit, I want the currently selected unit to be deselected (Variable "selected" = 0) and the new unit to become selected.

The way I tried it didn't work, and I can't think of any other way to do it.

Can anybody help me out?

Thanks
B
8
S
3
Posts: 49
Reputation: 698

Post » Tue May 05, 2015 10:56 am

variable selectedUID
event
on clicked objectX
action
set selectedUID = objectX.UID
set objectX.selected = 1
sub event
pick all objectX
pick objectX by evaluate where objectX.UID <> selectedUID
action
set objectX.selected = 0
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Tue May 05, 2015 5:07 pm

Hey thanks for the response. I typed in the code and it isn't working. It might be because I'm not exactly sure what it is I'm looking at though and just typed it in wrong, I'm pretty new to this sort of thing.

Image

Anyone know if I did something wrong?

Sorry I also should have mentioned that I wanted to make it so that if I clicked on nothing that it would deselect my current target.

Thanks again
B
8
S
3
Posts: 49
Reputation: 698

Post » Tue May 05, 2015 5:15 pm

SelectedUID should be a global or local variable, not instance variable of sprite, then it would work.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Tue May 05, 2015 6:04 pm

mindfaQ wrote:SelectedUID should be a global or local variable, not instance variable of sprite, then it would work.



This :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu May 07, 2015 6:48 pm

Ok now I understand whats happening :D

Thanks for the responses!
B
8
S
3
Posts: 49
Reputation: 698


Return to How do I....?

Who is online

Users browsing this forum: davidbox, Mayfly, Yahoo [Bot] and 4 guests