hi there,
i have gone through Corona demo and it’s using following code to hold an object
local function onStackObjectDrag( event )
local t = event.target
local phase = event.phase
if "began" == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
-- Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
elseif t.isFocus then
if "moved" == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
-- Stop further propagation of touch event!
return true
end
it’s not hard to understand for and it work perfectly for physic object which is in RECTANGLE shape.
But when i tested with a more complex shape (image below)
http://imageshack.us/photo/my-images/80/screenshot20120125atam1.png/
it doesn’t select correctly when i drag on the star shape. Sooner i realized it’s because the umbrella is actually ‘cover’ on top of the star. So even though i am dragging on the star, the program actually thinking i am touching on the umbrella.
In such case, how can i enhance my code?
[import]uid: 10373 topic_id: 20897 reply_id: 320897[/import]
[import]uid: 52491 topic_id: 20897 reply_id: 82422[/import]