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

0 favourites
  • 8 posts
  • 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:

    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.

  • DOne with only one event

    http://www12.zippyshare.com/v/KDvjBvHF/file.html

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

  • Just saw your reply ,Ok I will fix it give me a minute.

  • Try Construct 3

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

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

  • 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

  • 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

    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!!

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