Flash Collision Detection

Oct 5, 2009 at 1:45am
Overlooking the following code for collision detection in Adobe Flash, I'm confused as to the function of line trace("shape hit " + i++);. What does the function trace do, as well? I'm very new to collision detection and only have the basics down.

Thanks everybody, I rely on you all for my problems. lol



1
2
3
4
5
6
7
8
9
10
11
12
13
mcShape1.onPress = mcShape2.onPress = function() {
    this.startDrag();
}
mcShape1.onRelease = mcShape2.onRelease = function() {
    this.stopDrag();
}

function shapeHitTest() {
    if (mcShape1.hitTest(mcShape2._x+5, mcShape2._y+7, true)) {
        trace("shape hit " + i++);
    }
}
this.onEnterFrame = shapeHitTest;
Oct 5, 2009 at 2:54am
IIRC, trace just prints something to the little "output" box. In this case, it is to tell you that the hitTest worked.

Btw, why are you posting this on these forums?
Oct 6, 2009 at 2:38am
Trace outputs what ever you tell it to, but The output is only shown at compile time. Basicly it's a debugging tool. Also an easyer way of hittesting is just If(shape1.hitTest(shape2)) { the way that script is working it will hitTest shape2 as if it were 5 pixels to the right and 7 down. And why are you posting here instead of an actionscript forum?
Last edited on Oct 12, 2009 at 2:09am
Topic archived. No new replies allowed.