I’m not sure what is going on here. The core code on this page is generated by Kwik (which I love btw). The problem is that when I click on the “zoom” button, it does its action, i’m able to get the multitouch working, and then when i click back on the background, it resets the image back to its orginal location. However, the problem arises that the zoom button is no longer active (sensing the touch)
Would love some suggestions. I’ve moved code around, etc, but not able to figure it out.
[code]
– Code created by Kwik - Copyright: kwiksher.com
module(…, package.seeall)
function new()
local numPages = 15
local menuGroup = display.newGroup()
local curPage = 1
local showSlider = require(“displaySlider”)
local showNav = require(“displayNav”)
local multiTouch = require(“multitouch”)
showNavigationFlag = false
local disposeAudios
local disposeTweens
local ch1p1zoom
local ch1p1MTImage
local ch1p1Text
local ch1Title
local ch1Icon
local ch1photoCap
local chbkgd
local drawScreen = function()
chbkgd = display.newImageRect( “images/p3_chbkgd.png”, 1024, 768 );
chbkgd.x = 512; chbkgd.y = 384; chbkgd.alpha = 1
menuGroup:insert(chbkgd)
menuGroup.chbkgd = chbkgd
ch1photoCap = display.newImageRect( “images/p3_ch1photoCap.png”, 276, 31 );
ch1photoCap.x = 830; ch1photoCap.y = 488; ch1photoCap.alpha = 1
menuGroup:insert(ch1photoCap)
menuGroup.ch1photoCap = ch1photoCap
ch1Icon = display.newImageRect( “images/p3_ch1Icon.png”, 119, 135 );
ch1Icon.x = 73; ch1Icon.y = 83; ch1Icon.alpha = 1
menuGroup:insert(ch1Icon)
menuGroup.ch1Icon = ch1Icon
ch1Title = display.newImageRect( “images/p3_ch1Title.png”, 798, 49 );
ch1Title.x = 538; ch1Title.y = 83; ch1Title.alpha = 1
menuGroup:insert(ch1Title)
menuGroup.ch1Title = ch1Title
ch1p1Text = display.newImageRect( “images/p3_ch1p1Text.png”, 610, 578 );
ch1p1Text.x = 330; ch1p1Text.y = 470; ch1p1Text.alpha = 1
menuGroup:insert(ch1p1Text)
menuGroup.ch1p1Text = ch1p1Text
ch1p1MTImage = display.newImageRect( “images/p3_ch1p1MTImage.png”, 276, 308 );
ch1p1MTImage.x = 819; ch1p1MTImage.y = 290; ch1p1MTImage.alpha = 1
menuGroup:insert(ch1p1MTImage)
menuGroup.ch1p1MTImage = ch1p1MTImage
local function onch1p1zoomTouch (event)
if event.phase==“release” and ch1p1zoom.isActive then
gt_ch1p1MTImage= gtween.new( ch1p1MTImage, 2, { x = 516, y = 372, rotation = 0, xScale = 2, yScale = 2, alpha=1}, {ease = gtween.easing.outExponential, repeatCount = 1, reflect = false, delay=0 })
function ch1p1MTImage:touch( event )
if (event.phase == “began”) then
multiTouch.addTouch( ch1p1MTImage, event ) – adds a multitouch tracking object to maintain start, previous and pinchzoom data
end
end
function ch1p1MTImage:tap( event )
if (event.numTaps == 2) then
multiTouch.addTouch( ch1p1MTImage, event )
end
end
multiTouch.makePinchZoom( ch1p1MTImage )
ch1p1MTImage:addEventListener( “touch”, ch1p1MTImage )
ch1p1MTImage:addEventListener( “tap”, ch1p1MTImage )
zoomedImage = true
end
end
ch1p1zoom = ui.newButton{
defaultSrc=“images/p3_ch1p1zoom.png”,
defaultX = 67,
defaultY = 62,
overSrc=“images/p3_ch1p1zoom.png”,
overX = 67,
overY = 62,
onEvent=onch1p1zoomTouch,
id=“ch1p1zoomButton”
}
ch1p1zoom.x = 914; ch1p1zoom.y = 407; ch1p1zoom.alpha = 1
menuGroup:insert(ch1p1zoom)
menuGroup.ch1p1zoom = ch1p1zoom
gt_ch1p1zoom= gtween.new( ch1p1zoom, 1, { x = 914, y = 407, rotation = 0, xScale = 1.15, yScale = 1.15, alpha=1}, {ease = gtween.easing.inOutExponential, repeatCount = 1, reflect = false, delay=2})
local function flip (event)
if event.phase ==“ended” then
if event.xStart < event.x and (event.x - event.xStart) >= 30 then
if (curPage > 1) then
showSlider:removeSlider()
showNav:removeNav()
disposeTweens()
director:changeScene( “page_”…curPage-1, “moveFromLeft” )
end
elseif event.xStart > event.x and (event.xStart-event.x) >= 30 then
if (curPage < numPages) then
showSlider:removeSlider()
showNav:removeNav()
disposeTweens()
director:changeScene(“page_”…curPage+1, “moveFromRight”)
end
elseif event.xStart == event.x then
– on touch show the stuff, but then need to set a flag in order verify if its already shown if they touch again.
if zoomedImage == true then
zoomedImage = false
ch1p1MTImage.isVisible = false;
ch1p1MTImage.x = 819; ch1p1MTImage.y = 290;
ch1p1MTImage.xScale = 1;ch1p1MTImage.yScale = 1;
ch1p1MTImage.alpha = 1; ch1p1MTImage.rotation = 0
ch1p1MTImage.isVisible = true;
elseif showNavigationFlag == false then
showNav:showNav()
showSlider:displaySlider()
showNavigationFlag = true
elseif showNavigationFlag == true then
showSlider:removeSlider()
showNav:removeNav()
showNavigationFlag = false
end
end
end
end
chbkgd:addEventListener(“touch”, flip)
ch1p1zoom:addEventListener(“touch”, onch1p1zoomTouch)
end
drawScreen()
disposeAudios = function (event)
end
disposeTweens = function (event)
gt_ch1p1zoom:pause();
cancelAllTimers();
cancelAllTransitions();
end
return menuGroup
end
[/code] [import]uid: 16420 topic_id: 12566 reply_id: 312566[/import]