davemikesell: Sounds a bit like you’re confusing a touch with an event.
Typically when writing touch code you do this:
[code]if event.phase == “began” then
– set focus (ensures no other hijinks)
event.target.isFocus = true – prevents being able to “slide over” object and trigger move code
elseif event.target.isFocus then
if event.phase == “moved” then
– do whatever movement stuff you want here
elseif event.phase == “ended” then
– at this point, the user has lifted their finger.
– check to see if the finger was still on the object/icon!
local isWithinBounds = event.x > event.target.contentBounds.xMin and event.x < event.target.contentBounds.xMax and event.y > event.target.contentBounds.yMin and event.y < event.target.contentBounds.yMax
if isWithinBounds then
– execute whatever the icon/button/object should do
end
end
end [/code]
The iOS main screen works very similarly.
- When you press down, focus is set to prevent you from affecting other buttons (notice how you can’t slide your finger over to another button and release to target that instead)
- When you move, it triggers scrolling code. Your focus is still “set” but you can no longer trigger the button. (So basically like saying isFocus = false)
- When you release, it checks to see if isFocus = true and decides to execute based on that. [import]uid: 41884 topic_id: 27006 reply_id: 109689[/import]