Hello everyone. This is a modified continuation of my last post, except I cut out everything extra and made everything much simpler.
Here is my code.
display.setStatusBar( display.HiddenStatusBar ) --Create button local button = display.newCircle(320,900, 150) button:setFillColor(255,0,0 ) --Do this when button is clicked local function buttonClick() button:setFillColor(55,10,0 ) transition.to( button, { time=1500, x=x, y=button.y - 700} ) end --Do this when button is released local function buttonRelease() button:setFillColor(255,0,0 ) end --Run this when button is clicked local function buttonPressed(e) if e.phase == "began" then buttonClick() elseif e.phase == "moved" then --If your finger's coordinates are outside of the buttons, trigger release --Content bounds DONT change... fix needed --print(e.target.contentBounds.xMin) if e.x \< e.target.contentBounds.xMin or e.x \> e.target.contentBounds.xMax or e.y \< e.target.contentBounds.yMin or e.y \> e.target.contentBounds.yMax then print("Its out") e.phase = "offTarget" e.target:dispatchEvent(e) end elseif e.phase == "offTarget" then buttonRelease() print("It ran off the button") elseif e.phase == "ended" then buttonRelease() print("It ended") elseif e.phase == "cancelled" then buttonRelease() print("It canceled") end end button:addEventListener("touch",buttonPressed)
What I want to happen–
When the user presses the button, buttonClick is executed. Then when the user either lets go of the object or moves off of the object, then buttonRelease is executed.
What is actually happening–
Everything works, except for finger moved off of code (courtesy of jstrahan). In concept everything should work, however it doesn’t.
Can anyone help me with this?
–On a side note when the object is moving the contentBounds stay the same. I need help with this too.
Thanks!
Summit Tech