0
var i:int = 0;
stage.focus=stage;
var Walls:Array = [Wall,Wall1];
addEventListener(Event.ENTER_FRAME,HitDetection);
function HitDetection(event:Event):void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
function myKeyDown(e:KeyboardEvent):void
{
{
if (e.keyCode == Keyboard.LEFT)
{
if (KeemStar1.hitTestObject(Walls[i])) {
trace("1")
KeemStar1.x -=-0.1;
}
else
{
KeemStar1.x -=0.1;
}
}
if (e.keyCode == Keyboard.RIGHT)
{
{
if (KeemStar1.hitTestObject(Walls[i])) {
KeemStar1.x -=-0.1;
trace ("n")
}
else
{
KeemStar1.x +=0.1;
}
}
}
}
}
}
アレイ内のすべての壁ではなく、最初の壁に衝突するだけです。私はすべてを試しましたが、私はそれを理解することができません。私はactionscrip3に新しくなので、何をすべきか分かりません。ありがとう!!衝突を作成しようとしています