Hey Brent,
Thanks for the reply. I ended up following your advice and instead of using a tap listener I am now using a touch listener with an if statement checking for the “began” phase. However, I still cannot seem to solve my previous problem with the conflicting listeners. Now, the player shoots a projectile every time the user starts pressing a movement button instead of firing on the end of the touch.
Here are the snippets of my code regarding the issue, (sorry for disorganization)
--move right local moveRightBtn = display.newImage("rightArrow.png") moveRightBtn:setReferencePoint(display.BottomRightReferencePoint) moveRightBtn.x = display.contentWidth moveRightBtn.y = display.contentHeight function moveRightBtn:touch(event) if event.phase == "began" then motionX = walkingSpeed elseif event.phase == "ended" or event.phase == "cancelled" then motionX = 0 return true end end moveRightBtn:addEventListener("touch", moveRightBtn) --move left local moveLeftBtn = display.newImage("leftArrow.png") moveLeftBtn:setReferencePoint(display.BottomRightReferencePoint) moveLeftBtn.x = display.contentWidth - 100 moveLeftBtn.y = display.contentHeight function moveLeftBtn:touch(event) if event.phase == "began" then --display.getCurrentStage():setFocus(event.target) motionX = -walkingSpeed elseif event.phase == "ended" or event.phase == "cancelled" then motionX = 0 return true end end moveLeftBtn:addEventListener("touch", moveLeftBtn) --motion formula local function movePlayer(event) player.x = player.x + motionX end Runtime:addEventListener("enterFrame", movePlayer) --function that shoots projectiles from the player local function shoot(event) if gameState == 1 then if event.phase == "began" then local bullet = display.newCircle(0, 0, 5) bullet:setFillColor(0,100,200) bullet.x = player.x bullet.y = player.y physics.addBody(bullet) bullet.name = 'bullet' bullet.collision = onCollision bullet:addEventListener("collision", bullet) audio.play(soundBlast) transition.to(bullet, {time=1000, x=display.contentWidth+500}) return true end end return true --to stop conflicting with other taps end --Function to process screen tapping local function onScreenTap(event) if event.phase == "began" shoot(event) return true end end Runtime:addEventListener("touch", onScreenTap) --shoot function called on tap