我打算做一个拔河比赛,我在这方面有困难...游戏是用户必须快速点击按钮才能赢得游戏。我在数字1点击= +1时同时点击或不点击控制器的值减少0.5
感谢您的帮助
var controller = 10;
blocker.visible = false;
function decreasing(){
controller = controller - 0.5;
}
decreasing();
pushBtn.addEventListener(MouseEvent.CLICK, theGame);
function theGame (e:MouseEvent): void {
controller = controller + 1;
if ((controller <= 5) || (controller >=9)){
ropeMc.gotoAndPlay("down1");
}
if ((controller <= 1) || (controller >=4)){
ropeMc.gotoAndPlay("down1");
}
if ((controller >= 15) || (controller <=19)){
ropeMc.gotoAndPlay("up1");
}
if ((controller >= 20) || (controller <=29)){
ropeMc.gotoAndPlay("up2");
}
if (controller >= 30){
ropeMc.gotoAndStop(20);
blocker.visible = true;
}
}
答案 0 :(得分:0)
试试这个,
var controller = 10;
blocker.visible = false;
stage.addEventListener(Event.ENTER_FRAME, decreasing);
pushBtn.addEventListener(MouseEvent.CLICK, theGame);
function theGame (e:MouseEvent): void {
controller = controller + 1;
changeState();
}
function decreasing(e:Event){
controller = controller - 0.5;
}
function changeState():void{
if ((controller <= 5) || (controller >=9)){
ropeMc.gotoAndPlay("down1");
}
if ((controller <= 1) || (controller >=4)){
ropeMc.gotoAndPlay("down1");
}
if ((controller >= 15) || (controller <=19)){
ropeMc.gotoAndPlay("up1");
}
if ((controller >= 20) || (controller <=29)){
ropeMc.gotoAndPlay("up2");
}
if (controller >= 30){
ropeMc.gotoAndStop(20);
blocker.visible = true;
stage.removeEventListener(Event.ENTER_FRAME, decreasing);
}
}
希望它有所帮助。