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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | -- 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 |
Interesting, on further debugging. The second time i press the button it never goes into a "release" state. The event is on "press"...