Tap priority

Hi!

Just started a new project, and I encounter a small problem rather annoying!

In my game, the player need to Tap on the left part of the screen or the right to send “laser”.
That work pretty fine, I used at first a Runtime event but the problem is that I generate
ennemy on each side of the screen, and the ennemy walk to the middle.

I create my ennemy like this:

local fan = display.newImageRect(ennemyGroup, "ennemy/pieton\_01.png", 38, 88 ) fan.x = xMax-20; fan.y = player.y; fan.side = "left" fan.name = "fans"

(They are created with a timer in-game)

And until that, everything work but… that fact is that when a tap of on ennemy unintentionally, my Tap event won’t trigger, as the ennemy was infront of my Runtime Event!! (cause the entire screen is split in half, so the player can Tap anywhere)

So then, I create an invisible display object that cover the entire screen to replace the Runtime, put it infront of everything. Now, it work exactly like before…but the problem with the ennemy is not resolve! Event if they are behind my invisble display object, they still do not let me complete my tap event!

So, I just wanted to know how can I make my newly created ennemy do not interfere with something in front of them?

Thank you in advance!

Can you post your tap event functions?

Sure!

 

function tapAttack (event) if(gameIsActive == true) then if(player.energy\>= 5 and event.x \<= \_W\*0.5-15 or player.energy\>= 5 and event.x \>= \_W\*0.5+15) then player.energy= player.energy-5 local wave = display.newImageRect(uiGroup, "fx/wave.png", 32, 150 ) physics.addBody( wave, 'dynamic') wave.name = "wave" if(event.x \<= \_W\*0.5-15)then wave.x = player.x; wave.y = player.y; wave.side = "left" wave:scale(0.2,0.2) waveGroup:insert( wave ) elseif(event.x \>= \_W\*0.5+15) then wave.x = player.x; wave.y = player.y; wave.side = "right" wave:scale(-0.2,0.2) waveGroup:insert( wave ) end end end end clickZone:addEventListener("tap", tapAttack)

Hope this can help!!

Sorry to bump the topic, but I hope someone will find a way to fix it!!

Hi @terabites,

Please check out this tutorial on touch and tap events, and how to handle “special cases”. This may help you resolve it:

http://www.coronalabs.com/blog/2013/10/01/tutorial-taptouch-anatomy/

Sincerely,

Brent Sorrentino

Can you post your tap event functions?

Sure!

 

function tapAttack (event) if(gameIsActive == true) then if(player.energy\>= 5 and event.x \<= \_W\*0.5-15 or player.energy\>= 5 and event.x \>= \_W\*0.5+15) then player.energy= player.energy-5 local wave = display.newImageRect(uiGroup, "fx/wave.png", 32, 150 ) physics.addBody( wave, 'dynamic') wave.name = "wave" if(event.x \<= \_W\*0.5-15)then wave.x = player.x; wave.y = player.y; wave.side = "left" wave:scale(0.2,0.2) waveGroup:insert( wave ) elseif(event.x \>= \_W\*0.5+15) then wave.x = player.x; wave.y = player.y; wave.side = "right" wave:scale(-0.2,0.2) waveGroup:insert( wave ) end end end end clickZone:addEventListener("tap", tapAttack)

Hope this can help!!

Sorry to bump the topic, but I hope someone will find a way to fix it!!

Hi @terabites,

Please check out this tutorial on touch and tap events, and how to handle “special cases”. This may help you resolve it:

http://www.coronalabs.com/blog/2013/10/01/tutorial-taptouch-anatomy/

Sincerely,

Brent Sorrentino