I’m working on a game and… let me preface this with “I am NOT using physics. I do not intend to use physics!”.
So I have a screen object that rotates (via an enterFrame handler). It is a long thin graphic and it’s trimmed to minimize transparent pixels.
I’m using this to detect my collisions (stolen from the forums)
local function hasCollided(obj1, obj2)
if obj1 == nil then
return false
end
if obj2 == nil then
return false
end
local left = obj1.contentBounds.xMin \<= obj2.contentBounds.xMin and obj1.contentBounds.xMax \>= obj2.contentBounds.xMin
local right = obj1.contentBounds.xMin \>= obj2.contentBounds.xMin and obj1.contentBounds.xMin \<= obj2.contentBounds.xMax
local up = obj1.contentBounds.yMin \<= obj2.contentBounds.yMin and obj1.contentBounds.yMax \>= obj2.contentBounds.yMin
local down = obj1.contentBounds.yMin \>= obj2.contentBounds.yMin and obj1.contentBounds.yMin \<= obj2.contentBounds.yMax
return (left or right) and (up or down)
end
So if the object is on it’s 0, 80, 180 or 270 degree angles, this works perfectly. But if the object is rotated to another angle like say 45, the boundingBox creates a huge area of collision that isn’t part of the graphic:
+------+
|\\ |
| \\ |
| \\ |
| \\ |
| \\|
+------+
So I need to be able to call a function that will check the physical bounds not the ones based on extending the box.
I so would love a doesPolygonIntersectPolygon() API call.
Any thoughts?
(and please don’t respond with “use physics!”)
Rob
[import]uid: 19626 topic_id: 21240 reply_id: 321240[/import]

[import]uid: 12482 topic_id: 21240 reply_id: 84166[/import]
[import]uid: 12482 topic_id: 21240 reply_id: 84344[/import]