How do I choose the right 'touch'?

0 favourites
  • 11 posts
From the Asset Store
Awesome drifts on auto generate way,tap to steer right.
  • Hi there,

    I've got a bit of a problem here which I can't seem to be able to solve on my own...

    I'm working on a project/game for a smartphone so I'm using the touch object: if the player touches the screen (is in touch), a bullet is fired.

    If a player isn't able to finish a level, a text called 'restart' appears. The player will have to touch this text so the level starts again.

    Both 'touches', firing the bullet and restarting the level, work.

    The problem is that when the player touches the 'restart' text, a bullet is also fired because of the 'is in touch'...

    I hope the issue is clear enough?

    I've looked through the tutorials, the manual and the forums, but couldn't find anything...

    Can anyone help me solve this issue?

    Again many thanks in advance!

  • Put the bullet behavior inside a group. Deactivate this group when the restart popup shows up and reactivate it on the start of the layout.

    Or you may add a variable, like isActive, add a condition to the bullet touch that the variable equals 1 and set it to 0 when the restart popup is showing and back to one at the start of the layout.

    Both approaches will work the same way.

  • Hi BrunoPalermo,

    many thanks for your fast reply!

    I tried both methods and got the first one working!

    Although I did have to put a 'system wait for 0.1 seconds' at the (new) start of the layout...

    Doesn't matter: it works now!

    Thanks a whole bunch!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • or just destroy bullets when restart text is touched

  • All the solutions don't seem to work after all...

    The problem is that I also use a 'on any touch end'; I think the problem might be caused by this one...

    I'll post my capx, maybe things are more clear then.

    Aim of the game is to destroy the yellow blocks by shooting them.

    To make things easier, if you click somewhere on the screen a line is drawn from the player to this point so you can see where the bullet will hit for the first time.

    This way it's easier to 'calculate' where the ball should hit a wall or a blue block...

    I'm really stuck here...

  • wait a second!...

  • Yeah korbaach,

    that works!

    Although I don't really get the logic behind it....

    Thanks a lot!

  • I don't really get the logic behind it....

    your actions ..restart layout..spawn bullet..and a few more(set global variable..).. all took place in one tick...

    simple delay between action stop spawning bullets.. but your code have more logical errors..

  • Ok, that makes sense...

    Well, to be honest, I would be surprised if my code DIDN'T have logical errors in it

    Maybe, given the fact that I still have a lot to learn, you would be so kind to point out some errors?

    You don't need to give me the right code or whatsoever but if I know what's wrong, I can try to figure it out myself.

    So far the game does what I want it to do, but I'm sure there are many things to improve!

    Thanks so much again!

  • Sorry man!

    ..I did not want to be rude (stupid google translate )

    there is no good or bad code.. only effective or not effective ...

    ,we all still learning...and we will learn all our life...

  • korbaach now this answer deserve good mark Welldone korbaach not like before

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