masking touch events

Howdy. Just getting started with Corona (another Flash refugee).

I am making a plate spinning game and its coming along pretty well but I am having a problem.

When the player touches a plate sprite to “give it a spin” that touch gets sent to all the sprites whose rect intersects with the touch region. That makes the game way to easy and boring.

I would like to “mask” the event so it is only triggered when the player touches the opaque region of the sprite. Is there a way to do this?

Here is the game in its current version:

http://dl.dropbox.com/u/11235/spinner.zip

Any help is greatly appreciated.
[import]uid: 6310 topic_id: 14996 reply_id: 314996[/import]

Before you do… are you doing something similar to this :

[code]

local function onTouch(event)
–Whatever code

return true --Stops images below the touched image being “pressed”
end
[/code] [import]uid: 84637 topic_id: 14996 reply_id: 55362[/import]

Awesome! That helps a lot. Now the problem is that if the user keeps the touch down it keeps re-broadcasting so you can basically keep the finger pressed a swipe over to a plate to spin it.

Maybe I can do something with the event properties to keep it from triggering other objects.

Thanks for your super fast help! [import]uid: 6310 topic_id: 14996 reply_id: 55364[/import]

Allright! By enabling multitouch support now I have access to the event ID. Using the event ID and a conditional now I am able to filter it out:

function spinUp( event )
if lastId ~= event.id then
local keepIt = event.target.state
event.target.spinSpeed = maxSpin
event.target.state = “fast”
event.target:prepare(event.target.state)
event.target:play()
event.target.rod:setFillColor( rodBright, rodBright, rodBright )
if keepIt ~= “fast” then
lastId = event.id
return true
end
end
end

Thanks again for your help! [import]uid: 6310 topic_id: 14996 reply_id: 55366[/import]

Glad to help :slight_smile: [import]uid: 84637 topic_id: 14996 reply_id: 55372[/import]