What is wrong with this event!?

Get help using Construct 2

Post » Thu Oct 03, 2013 11:43 pm

I am trying to make it so you select the base by pressing it and then the arrow pops up when its selected, and goes away when you de-select it by pressing it again. I made an instance variable called selected to make it work, please tell me what im doing wrong! Below is a capture of the event.

https://dl.dropboxusercontent.com/u/68458825/Capture1.PNG
B
7
S
1
Posts: 97
Reputation: 1,167

Post » Thu Oct 03, 2013 11:47 pm

Spawning on layer 0 which is the bottom layer. Might be behind another object.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Thu Oct 03, 2013 11:52 pm

No idea what you are doing wrong, but here is a workaround.

Pin the Checkmark to the objects you want selectable, when you spawn them.

At spawn turn the checks invisible.

On mouse over set it to Visible 50%

On mouseover and left click, set to visible 100%

Invert a mouse over the checkmark, and set to invisible.

TL;DR, Use visibility, and toggle it on and off with clicks rather than trying to spawn one every time you need it.

If you add the Checkmark to a container, it will automatically destroy with the object it is parented to.

Hope that helps, my english is not so good.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Thu Oct 03, 2013 11:52 pm

Your second Touch event is triggering after your first on the same touch - so you touch it, the variable changes to 1, then the next event in the line triggers and since Selected is now 1 it fires and destroys the other sprite immediately.

Try only having one touch event and have sub events to check the instance variable, like so:

http://storage.wertle.com/construct2/touchIssue1.PNG

Edit: the Move to Top of Layer thing isn't necessary, I just had it in to make sure it wasn't spawning behind the first sprite (it wasn't)Wertle2013-10-03 23:54:54
B
11
S
2
Posts: 87
Reputation: 1,112

Post » Fri Oct 04, 2013 12:26 am

Wertle I tried that and now the arrow will pop up, but wont go away when i click it again :/
B
7
S
1
Posts: 97
Reputation: 1,167

Post » Fri Oct 04, 2013 12:44 am

and the main thing I need working is the selecting, the arrow is just for visuals. Only a selected base sends troops so it is huge that I get it working properly!
B
7
S
1
Posts: 97
Reputation: 1,167

Post » Fri Oct 04, 2013 12:50 am

something was wrong with the touch, I made it wait 1/8 of a second before doing anything after the touch and it fixed it. thanks for your help everyone
B
7
S
1
Posts: 97
Reputation: 1,167

Post » Fri Oct 04, 2013 10:25 am

yeah in future you can debug check variables with text objects so that you know for sure they are being set correctly.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Buddhika, R0J0hound and 13 guests