Hi! I’ve just ran unto a simple problem that actually ruin a lot of gameplay in my game recently.
To make it short, in my game, we control a rocket. When you touch the screen it fly up and when we release, it go down.
There is obstacles like planes that fly through the screen and you must avoid them.
Until now, everything work, by the problem is, we add a Dynamite object that can destroy the plane when you touch it (or tap it. I tried it too). But, when you touch the plane, of tap it, it seem that send a “ended” phase to my function that control the rocket.
[lua]–Function that control the rocket
function boost( event )
if(gameActive == true and gameEnded ~= true and player.hit ~=true) then
if(event.phase == “began”) then
fall = false
player:prepare(“engine”)
player:play()
display.getCurrentStage():setFocus(event.target)
end
if event.phase ==“ended” then
fall = true
display.getCurrentStage():setFocus(nil)
end
end
end
–Function that control the dynamite
function dynaPlane(event)
if(event.target.isAlive == true and dynamite == true and gameActive == true and player.hit ~= true and event.xStart > 100) then
if(otherCondition == 2)then
player.objectif = player.objectif+1
end
alertSign.alpha = 0
explosion.x = event.target.x-10
explosion.y = event.target.y-25
explosion.isAlive = true
explosion:prepare(“boom”)
explosion:play()
audio.stop( 3 )
transition.to(boomFlash, { time=50, alpha = 1, onComplete = function()
transition.to(boomFlash, { time=50, alpha = 0 })
end
} )
event.target.y = -1000
event.target.x = 1500
event.target.isAlive = false
boomChannel_2 = audio.play( boom ,{channel= 1})
dynamite = false
tntIcon.alpha = 0
end
end
plane:addEventListener(“touch”, dynaPlane)
Runtime:addEventListener(“touch”, boost)[/lua]
So when I touch the plane, that actually cancel the boost function.
Then, I though it was because of the fact that the boost touch function was on Runtime.
So we try a completly different approach, where you control the rocket the same way, by touching anywhere on the screen EXCEPTLY in a little zone that we use like an inventory, where the player can touch the dynamite icon to use it, instead of touching on the plane.
But there again, even when my inventory is empty (so there is no touch event in the inventory zone), it cancel my boost function! I join a picture to illustrate my problem.
In the picture, for example, the red zone is everywhere you can touch to make your rocket fly and the yellow square show where I touch. And for example, the orange square is the object I want to use in my inventory. So I keep my finger press on yellow square, than with a other finger I press on the orange square… and that cancel my boost function! But why? I did not move my first finger!
So do somebody know a way to resolve my problem? I would prefer to keep my game like my first example, but if somebody is able to make my second version work, that fine for me!
P.S. Multi-Touch IS activated, I’ve got the message in the simulator.
P.S.2. I tested the multi-touch on my devices, not on the simulator, don’t worry!