AS3.0新手问题【访问可能未定义的属性 x y】
varleftArrow:Boolean=false;varrightArrow:Boolean=false;varupArrow:Boolean=false;vardo...
var leftArrow:Boolean=false;
var rightArrow:Boolean=false;
var upArrow:Boolean=false;
var downArrow:Boolean=false;
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyPressedDown);
stage.addEventListener(KeyboardEvent.KEY_UP,keyPressedUp);
stage.addEventListener(Event.ENTER_FRAME ,moveMascot);
function keyPressedDown(event:KeyboardEvent) {
if (event.keyCode==37) {
leftArrow=true;
} else if (event.keyCode == 39) {
rightArrow=true;
} else if (event.keyCode == 38) {
upArrow=true;
} else if (event.keyCode == 40) {
downArrow=true;
}
}
function keyPressedUp(event:KeyboardEvent) {
if (event.keyCode==37) {
leftArrow=false;
} else if (event.keyCode == 39) {
rightArrow=false;
} else if (event.keyCode == 38) {
upArrow=false;
} else if (event.keyCode == 40) {
downArrow=false;
}
}
function moveMascot(event:Event) {
var speed:Number=5;
if (leftArrow) {
mascot.x-=speed;
}
if (rightArrow) {
mascot.x+=speed;
}
if (upArrow) {
mascot.y-=speed;
}
if (downArrow) {
mascot.y+=speed;
}
}
= = 好像是什么 实例名 链接的什么问题- -我不明白 展开
var rightArrow:Boolean=false;
var upArrow:Boolean=false;
var downArrow:Boolean=false;
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyPressedDown);
stage.addEventListener(KeyboardEvent.KEY_UP,keyPressedUp);
stage.addEventListener(Event.ENTER_FRAME ,moveMascot);
function keyPressedDown(event:KeyboardEvent) {
if (event.keyCode==37) {
leftArrow=true;
} else if (event.keyCode == 39) {
rightArrow=true;
} else if (event.keyCode == 38) {
upArrow=true;
} else if (event.keyCode == 40) {
downArrow=true;
}
}
function keyPressedUp(event:KeyboardEvent) {
if (event.keyCode==37) {
leftArrow=false;
} else if (event.keyCode == 39) {
rightArrow=false;
} else if (event.keyCode == 38) {
upArrow=false;
} else if (event.keyCode == 40) {
downArrow=false;
}
}
function moveMascot(event:Event) {
var speed:Number=5;
if (leftArrow) {
mascot.x-=speed;
}
if (rightArrow) {
mascot.x+=speed;
}
if (upArrow) {
mascot.y-=speed;
}
if (downArrow) {
mascot.y+=speed;
}
}
= = 好像是什么 实例名 链接的什么问题- -我不明白 展开
微测检测5.10
2023-07-11 广告
2023-07-11 广告
IEC62133与en62133的区别如下:1. 认证机构不同:IEC62133是国际的标准,它以国际通用的标准进行生产;而en62133采用的是欧盟的标准,它使用欧盟的生产需求进行生产。2. 宗旨不同:IEC62133的宗旨是促进电气、电...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询