0

AS3 で簡単なフラッシュ ゲームを作成していますが、記号ではなく形状に適用される点を除いて、"hitTestPoint()" に似たコードを使用できるかどうか疑問に思っていました。

迷路は単なる線の形なので、ボールが形から外れるとゲームオーバーです。これは可能ですか?

ありがとう、ピーター

4

3 に答える 3

0

十分に単純です。ボールの現在の位置で迷路が見つかるかどうかをテストするだけです。

function test():Boolean {
    // First we get the absolute coordinates of the ball
    var loc:Point = ball.localToGlobal(new Point(0,0));
    // Next we collect all the DisplayObjects at that coordinate.
    var stack:Array = getObjectsUnderPoint(loc);
    var found:Boolean = false;

    // Now we cycle through the array looking for our maze
    for each (var item in stack) {
        if (item.name == "mazeShape") {
            found = true;
        }
    }

    return found;
}

マウス (ボールではなく) が迷路から外れているかどうかに本当に関心がある場合は、最初の行を次のように置き換えます。

var loc:Point = new Point(mouseX, mouseY);
于 2013-05-01T15:07:42.497 に答える