[Solved] Touch Control Help?


#1

Hi, i’m new to Gdevelop and have made a simple game. Basically when I touch an enemy I want it to be deleted. I did mange to achieve this with the “The cursor/touch is on” and “delete object”.
However I want a touch to last only for a second and only be able to kill one enemy at a time. At the moment I can cheat the game by holding down and deleting multiple enemies with one swipe of my finger when i hold the touch down (which i DONT want). Its hard to explain in words but i hope someone can help.

Okay I realise i’m not explaining it very well, so here is a 40 sec youtube clip showing what is wrong.


#2

Hi,
Try adding that condition: Conditions/advanced/Trigger once
Then, if you want to set a time limit, you’ll need to use a timer. See the documentation or the examples.


#3

ahh i,m so stuck. its hard to explain, but maybe this analogy may help. For example when playing a game like flappy bird when you tap/touch the screen and hold it down he would only fly once and fall and die, but with the touch controls i have if i was the hold tap/touch he would keep flying rather than the touch only lasting once :frowning:


#4

Okay I realise i’m not explaining it very well, so here is a 40 sec youtube clip showing what is wrong.


#5

Sorry, Trigger once was not the right one. Add “left mouse button has been released” as condition :slightly_smiling_face:
(works with touch as well)


#6

Another thing that might possibly do the trick - in addition to the other suggestions from Gruk - is using “for each enemy object” - similar to how coins are set up in the tutorials, especially if your enemies are overlapping or very close together.

http://wiki.compilgames.net/doku.php/gdevelop5/events/foreach#for_each_events

http://wiki.compilgames.net/doku.php/gdevelop5/tutorials/platform-game/5-add-coins-and-number-of-collected-coins#bonusmaking_sure_that_collecting_two_coins_at_the_same_time_works


#7

Thank you both of you. I used Gruk’s method before I saw Phenomena’s post. It worked first time, so simple lol i didn’t think that would work for touch but yay it does. I will look into Phenomena’s method on my next project. Thanks guys !!