Ok I’m here again. I need help to accomplish this. I have been since yesterday night and I could not. I am blocked. In my second game the controls are zoom in zoom out to move objects. There will only be three zoom in and three zoom out positions to play. The problem I have is with the count of the zoom taps and the positions of the objects. I want them to only open and close at specific positions. I can’t make this happen.
Here the code:
--zoom out/in
local function zoomButtonsTouch( event )
if ( event.phase == "began" ) then
zoomOutTap = zoomOutTap
zoomInTap = zoomInTap
if ( event.target.id == "1" ) and ( canZoomOut == true) then
print( "Zoom out taps", zoomOutTap )
if (zoomOutTap > 1) then
zoomOutTap = zoomOutTap - 1
controls.objectZoomOut()
else
canZoomOut = false; canZoomIn = true; zoomOutTap = 4
print( "No more zoom out!" )
end
elseif ( event.target.id == "2" ) and ( canZoomIn == true) then
print( "Zoom out taps", zoomInTap )
if (zoomInTap > 1) then
zoomInTap = zoomInTap - 1
controls.objectZoomIn()
else
canZoomIn = false; canZoomOut = true; zoomInTap = 4
print( "No more zoom! in" )
end
end
end
return true
end
You’re basically resetting the taps every time it’s touched. You would need to keep track of the taps outside, so something like this can work:
if ( event.phase == "began" ) then
if ( event.target.id == "1" ) and ( canZoomOut == true) then
print( "Zoom out taps", event.target.zoomOutTap )
if (event.target.zoomOutTap > 1) then
event.target.zoomOutTap = event.target.zoomOutTap - 1
controls.objectZoomOut()
else
canZoomOut = false; canZoomIn = true; event.target.zoomOutTap = 4
print( "No more zoom out!" )
end
elseif ( event.target.id == "2" ) and ( canZoomIn == true) then
print( "Zoom out taps", zoomInTap )
if (event.target.zoomInTap > 1) then
event.target.zoomInTap = event.target.zoomInTap - 1
controls.objectZoomIn()
else
canZoomIn = false; canZoomOut = true; event.target.zoomInTap = 4
print( "No more zoom! in" )
end
end
end
return true
I understand that I did not know how to explain, sorry. Those variables are there because it is the only way I have to capture the value in which the player left the respective taps.
Objects are going to have three positions, imagine it like this, big, medium and small. What I want is that if I am in the medium pressing zoom in, I can zoom out from the same position without truncating the values, causing them to go to another x or y value changing the default positions