How to check Overlay 2 image for event

Hi,

How to check Overlay 2 image for event

image 1 overlay image 2
print (" overlay ")

Thanks, [import]uid: 169163 topic_id: 30313 reply_id: 330313[/import]

If you have physics bodies related with this images then collision event will be raised. (set isSensor=true, to allow overlaping) If not, then you can check it like this (but you have to check it in enterFrame event

img1:setReferencePoint(display.centerReferencePoint) img2:setReferencePoint(display.centerReferencePoint) -- TIP: logic fromula returns true or false for not rotated rectangular objects, -- if you wanna have rotation its require just a little bit more math ;) print ("overlaping: " .. tostring( math.abs(img1.x - img1.x) \< (img1.width + img2.width)/2 and math.abs(img1.y - img2.y)
[import]uid: 145499 topic_id: 30313 reply_id: 121449[/import]

if i don’t use physics how i can do it? [import]uid: 169163 topic_id: 30313 reply_id: 121470[/import]

this time if i use physic

addBody it collision not overlay
how i can fix?

thanks [import]uid: 169163 topic_id: 30313 reply_id: 121475[/import]

2 rep .>,< [import]uid: 169163 topic_id: 30313 reply_id: 121476[/import]

See this blog post:

http://omnigeek.robmiracle.com/2011/12/14/collision-detection-without-physics/
[import]uid: 19626 topic_id: 30313 reply_id: 121497[/import]

Thanks,

i can do it but i can’t Fix it

has error i check
if hasCollided(shadows1, player)
print (“mmmm”)

but
i drag player to shadows4 it can print too … O_o
[import]uid: 169163 topic_id: 30313 reply_id: 121630[/import]

Can you post your code? [import]uid: 19626 topic_id: 30313 reply_id: 121665[/import]

If you have physics bodies related with this images then collision event will be raised. (set isSensor=true, to allow overlaping) If not, then you can check it like this (but you have to check it in enterFrame event

img1:setReferencePoint(display.centerReferencePoint) img2:setReferencePoint(display.centerReferencePoint) -- TIP: logic fromula returns true or false for not rotated rectangular objects, -- if you wanna have rotation its require just a little bit more math ;) print ("overlaping: " .. tostring( math.abs(img1.x - img1.x) \< (img1.width + img2.width)/2 and math.abs(img1.y - img2.y)
[import]uid: 145499 topic_id: 30313 reply_id: 121449[/import]

if i don’t use physics how i can do it? [import]uid: 169163 topic_id: 30313 reply_id: 121470[/import]

this time if i use physic

addBody it collision not overlay
how i can fix?

thanks [import]uid: 169163 topic_id: 30313 reply_id: 121475[/import]

2 rep .>,< [import]uid: 169163 topic_id: 30313 reply_id: 121476[/import]

See this blog post:

http://omnigeek.robmiracle.com/2011/12/14/collision-detection-without-physics/
[import]uid: 19626 topic_id: 30313 reply_id: 121497[/import]

Thanks,

i can do it but i can’t Fix it

has error i check
if hasCollided(shadows1, player)
print (“mmmm”)

but
i drag player to shadows4 it can print too … O_o
[import]uid: 169163 topic_id: 30313 reply_id: 121630[/import]

Can you post your code? [import]uid: 19626 topic_id: 30313 reply_id: 121665[/import]