AS3 で簡単なフラッシュ ゲームを作成していますが、記号ではなく形状に適用される点を除いて、"hitTestPoint()" に似たコードを使用できるかどうか疑問に思っていました。
迷路は単なる線の形なので、ボールが形から外れるとゲームオーバーです。これは可能ですか?
ありがとう、ピーター
AS3 で簡単なフラッシュ ゲームを作成していますが、記号ではなく形状に適用される点を除いて、"hitTestPoint()" に似たコードを使用できるかどうか疑問に思っていました。
迷路は単なる線の形なので、ボールが形から外れるとゲームオーバーです。これは可能ですか?
ありがとう、ピーター
十分に単純です。ボールの現在の位置で迷路が見つかるかどうかをテストするだけです。
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);