所以,我试图用变量创建一个无限循环,就像在某种程度上乒乓球一样,你击球,它会一次又一次地向后,向左,向右,向左,向右。它有效,但每次它都变得越来越快而且速度更快,我也知道为什么了每次都以相同的速度,而不是越来越快,有没有办法解决这个问题,或者如果有的话,你能建议一个替代方案吗?谢谢!
import flash.events.Event;
var badbee1right:uint = setInterval (beebad1right, 100);
function beebad1right():void {
beebad1.x+=15;
}
var badbee1left:uint = setInterval (beebad1left, 100);
clearInterval(badbee1left);
function beebad1left():void {
beebad1.x-=15;
}
leftbadbeewall.addEventListener(Event.ENTER_FRAME, leftbadbeewallhit);
function leftbadbeewallhit(e:Event) {
if(beebad1.hitTestObject(leftbadbeewall)) {
beebad1.x+=7;
clearInterval(badbee1left);
clearInterval(badbee1right);
}
}
rightbadbeewall.addEventListener(Event.ENTER_FRAME, rightbadbeewallhit);
function rightbadbeewallhit(e:Event) {
if(beebad1.hitTestObject(rightbadbeewall)) {
clearInterval(badbee1right);
bee.x-=7;
clearInterval(badbee1left);
}
}