Flash Collision Detection

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;
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?
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
Topic archived. No new replies allowed.