Hi there
On my way to learn how to do the SAT way (separating axis theorem way), I created a function like this:
function cDetect (ob1:MovieClip,ob2:MovieClip) {
var xOverlap:Boolean
var yOverlap:Boolean
var b1:Object = ob1.getBounds(_root)
var b2:Object = ob2.getBounds(_root)
if (b1.xMin > b2.xMax or b1.xMax < b2.xMin) {
xOverlap = false
} else {
xOverlap = true
}
if (b1.yMin > b2.yMax or b1.yMax < b2.yMin) {
yOverlap = false
} else {
yOverlap = true
}
if (xOverlap and yOverlap) {
_root.cPhrase._visible = true//There is collision between the 2 objects
} else {
_root.cPhrase._visible = false//There is no collision between the 2 objects
}
_root.xoText.text = xOverlap
_root.yoText.text = yOverlap
}
Will this thing be any better than the Flash built-in MovieClip.hitTest(x,y,shapeFlag)?
They do the same. My function cDetect() does bounding box hitTest.
Thanks in advance.