How do I prevent "touch" from touching a newly spawned objct

Just started using Construct 2? Post your questions here

Post » Fri Sep 23, 2016 10:36 am

Hello All,

I have two sprites (red and blue).
I start with 3 red sprites on the layout. When I click on a red sprite, I want it destroyed and a blue sprite to be spawned in its place and vice versa. I tried the following:
Image

But I end up with all blue sprites. Once they are blue, they never go back to red. If I change the order of events, the opposite happens.

I am assuming that the "touch" event is being triggered for the newly spawned object. I am right? Is there a way to prevent that?

Many thanks for the help.
B
14
S
3
Posts: 29
Reputation: 870

Post » Fri Sep 23, 2016 10:54 am

Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 681
Reputation: 16,613

Post » Fri Sep 23, 2016 11:02 am

Hi PixelPower,

Thanks for the reply.
What I wanted was:
When I click on RED, it turns Blue and when I click on BLUE it goes back to RED, etc.

Your CAPX file changes BLACK to BLUE but it doesn't allow the change back to BLACK

I amnot sure if you were able to see the image I posted (it doesn't seem to show on my browser!!)
Have a look here:
https://justpaste.it/yme4

Regards.
B
14
S
3
Posts: 29
Reputation: 870

Post » Fri Sep 23, 2016 11:21 am

Just saw your reply ,Ok I will fix it give me a minute.
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 681
Reputation: 16,613

Post » Fri Sep 23, 2016 11:25 am

Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 681
Reputation: 16,613

Post » Fri Sep 23, 2016 11:30 am

I could do it another way with variables but wouldn't have time to explain it. There seems to be a nasty little bug on the touch event, causes both sprites to receive the touch event. I located the bug and put the wait command . You can change the wait command to .5 so it will be faster.
I could bypass the bug with a variable but wouldn't have time to explain it. I am working on something now, Let me know if it works for you.
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 681
Reputation: 16,613

Post » Fri Sep 23, 2016 8:00 pm

Thank you very much PixelPower,

I changed the wait to zero seconds and it still worked fine and fast.

I also tried the same with a "mouse" object instead of the "touch" object and it was the same.

Is this a bug or is it the way the system works? I am new at this so I don't want to report something unless I know for sure it is a bug rather than a misunderstanding of the way the system works.

Thanks again :D
B
14
S
3
Posts: 29
Reputation: 870

Post » Sat Sep 24, 2016 12:43 pm

Taweel wrote:Thank you very much PixelPower,

I changed the wait to zero seconds and it still worked fine and fast.

I also tried the same with a "mouse" object instead of the "touch" object and it was the same.

Is this a bug or is it the way the system works? I am new at this so I don't want to report something unless I know for sure it is a bug rather than a misunderstanding of the way the system works.

Thanks again :D


No need to report something this small, plus you got a fix . I am glad you where able to get the effect you wanted in your game. I f have any other trouble's try to solve and if you can't post here so someone can help you. Good luck on your game!!
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 681
Reputation: 16,613


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests