[Resolved] collision type

I can test if 2 objects collide easy enough like below.

can I get information about type of collision like x/y point where hit is or side of object hit etc?
peachpic:addEventListener(“collision”, peachpic)

function peachpic:collision (event)

if event.other.myName == “peachpic2” then
print “Peach2 hit me!”
end

end [import]uid: 138547 topic_id: 25363 reply_id: 325363[/import]

Hahahaha, I recognize some of this code :wink:

You could check the x and y of event.other to see if it is above, below, left or right of the object being hit.

Eg;
if event.other.x < event.x then
print “Hit on left”

Something like that.

Peach :slight_smile: [import]uid: 52491 topic_id: 25363 reply_id: 102510[/import]

Hi ok thanks for that.

The other issue I have is image collisions with alpha values.

For example ff I test 2 images (circles) then the corona collisions will treat the circles like squares.

How can I get around this? My images have alpha values

UPDATE: I can define the boundary of the shape to collide with http://developer.anscamobile.com/reference/index/physicsaddbody

what do I do with rotated sprites like a missile sprite rotated that shoots an enemy? [import]uid: 138547 topic_id: 25363 reply_id: 102528[/import]

Hey again,

You can do a custom shape but if it’s a circle just assign a radius when creating the physics body.

RE rotation there is a thread on rotation using Graham Ranson’s Rum which can be found in the code exchange. He talks about it here; http://developer.anscamobile.com/forum/2011/04/20/how-rotate-turret-dragging

(That thread relates more to touch and drag but is still very useful in understanding the basics of how Rum works.)

Peach :slight_smile: [import]uid: 52491 topic_id: 25363 reply_id: 102547[/import]