Hi I made this function,
function zoomIN (event, touch)
-- print(event.name.." occurred")
local xAmount = 1.6
local yAmount = 1.6
print("zoomIN ")
images[imgNum]:scale(xAmount, yAmount)
end
function zoomOut (event, touch)
-- print(event.name.." occurred")
local xAmount = 0.625
local yAmount = 0.625
print("zoomOut ")
images[imgNum]:scale(xAmount, yAmount)
end
buttonZoomIn:addEventListener( "tap", zoomIN )
buttonZoomOut:addEventListener( "tap", zoomOut )
Now I have this problem,
function touchListener (self, touch)
--local xAmount = 1.6
-- local yAmount = 1.6
--print("callPhone---")
-- images[imgNum]:scale(xAmount, yAmount)
buttonZoomIn:removeEventListener( "tap", zoomIN )
buttonZoomOut:removeEventListener( "tap", zoomOut )
local phase = touch.phase
print("slides", phase)
if ( phase == "began" ) then
-- Subsequent touch events will target button even if they are outside the contentBounds of button
display.getCurrentStage():setFocus( self )
self.isFocus = true
startPos = touch.x
prevPos = touch.x
transition.to( navBar, { time=200, alpha=math.abs(navBar.alpha-1) } )
-- transition.to( navBar, xScale = 2, yScale = 2, { time=200, alpha=math.abs(navBar.alpha-1) } )
elseif( self.isFocus ) then
if ( phase == "moved" ) then
-- background:removeEventListener("touch", touchListener)
buttonZoomIn:removeEventListener( "tap", zoomIN )
transition.to(navBar, { time=400, alpha=0 } )
if tween then transition.cancel(tween) end
print(imgNum)
local delta = touch.x - prevPos
prevPos = touch.x
images[imgNum].x = images[imgNum].x + delta
if (images[imgNum-1]) then
images[imgNum-1].x = images[imgNum-1].x + delta
end
if (images[imgNum+1]) then
images[imgNum+1].x = images[imgNum+1].x + delta
end
elseif ( phase == "ended" or phase == "cancelled" ) then
dragDistance = touch.x - startPos
print("dragDistance: " .. dragDistance)
if (dragDistance \< -40 and imgNum \< #images) then
nextImage()
elseif (dragDistance \> 40 and imgNum \> 1) then
prevImage()
else
cancelMove()
end
if ( phase == "cancelled" ) then
cancelMove()
end
-- Allow touch events to be sent normally to the objects they "hit"
display.getCurrentStage():setFocus( nil )
self.isFocus = false
end
end
return true
end
When I call this function (touchListener) I’d like the reset of this variable
xAmount
yAmount
I though of to run this code
buttonZoomIn:removeEventListener( "tap", zoomIN )
buttonZoomOut:removeEventListener( "tap", zoomOut )
but I have not the reset the variable xAmount yAmount.
How I can do this?
[import]uid: 100428 topic_id: 22251 reply_id: 322251[/import]