(shakes fist at Jayant’s superior answer! Anyway, my answer is just a retread of other, better ones, I’m sure…I’m pretty sure somebody told me how to do this, anyway…)
You would need to detect where the touch is.
This is a really simple example, but if your button is 100x100 at x:200, y:200, you could make a basic test like
[code]
local isWithinBounds =
– Check if inside the button along X
event.x > button.contentBounds.xMin and
event.x < button.contentBounds.xMax and
– Check if inside the button along Y
event.y > button.contentBounds.yMin and
event.y < button.contentBounds.yMax[/code]
Okay, I’m not sure linebreaks are allowed but you get the idea. From there you can use easy arguments like this:
if not isWithinBounds then -- literally, "if isWithinBounds == false, AKA you're outside the button"
dothis()
else
dothat()
end [import]uid: 41884 topic_id: 16283 reply_id: 60631[/import]