查看完整版本: flash 猜杯子 程試問題!
頁: [1]

s3023420070 發表於 2012-9-19 11:35 AM

flash 猜杯子 程試問題!

1.計時器出不來2.該如何讓前一段程式重復
目前杯子可以隨機互換位置掀開一次,我要讓他能掀開八次,且速度還要加快
該如何改??


import flash.utils.Timer;import flash.events.TimerEvent;import fl.motion.MotionEvent; stop();var inCup:uint; //老鼠位置(1~3)var steps:uint=0; //已執行的交換次數var maxSteps:uint=3; //交換次數,預設3次var isHere:Boolean; deactivate();var level = 1;var correct = 0;var incorrect = 0;var rolling = false; function check1(event:MouseEvent) {    if (inCup== 1)    {        isHere= true;    cups_mc.gotoAndPlay("good1");    }    else    {        isHere= false;       messages_mc.gotoAndStop("wrong");       cups_mc.gotoAndPlay("bad1");    } // endelse if   deactivate();} function check2(event:MouseEvent) {    if (inCup== 2)    {        isHere= true;       //correct_sound.start();       cups_mc.gotoAndPlay("good2");    }    else    {        isHere= false;       messages_mc.gotoAndStop("wrong");       cups_mc.gotoAndPlay("bad2");    } // endelse if   deactivate();} function check3(event:MouseEvent) {    if (inCup== 3)    {        isHere= true;       //correct_sound.start();       cups_mc.gotoAndPlay("good3");    }    else    {        isHere= false;       messages_mc.gotoAndStop("wrong");       cups_mc.gotoAndPlay("bad3");    } // endelse if   deactivate();} var time:int=60;var gameTimer:Timer=new Timer(1000,60);gameTimer.addEventListener(TimerEvent.TIMER,tickGame);function tickGame(event:TimerEvent):void {    time=time-1;    timer_txt.text=time.toString();

}gameTimer.addEventListener(TimerEvent.TIMER_COMPLETE,endGame);function endGame(event:TimerEvent):void {    gotoAndStop(14); }

...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>

his6214 發表於 2012-9-24 06:46 PM

本帖最後由 his6214 於 2012-9-24 06:48 PM 編輯

一、計數器變數gameTimer沒有設定開始
-> gameTimer.start();

二、不太清楚你要表達的事情

check1~3因為只是編號問題,可以做修改,這樣會比較簡短,方便統一修改import flash.events.MouseEvent;

var inCup:Number = 2;

cups_mc.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent)
{
        checked(2);
}

function checked(n:Number)
{
        if (inCup == n)
        {
                //isHere = true;
                cups_mc.gotoAndPlay("good" + n);
        }
        else
        {
                //isHere = false;
                //messages_mc.gotoAndStop("wrong");
                //cups_mc.gotoAndPlay("bad" + n);
        }// endelse if
}...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div>

his6214 發表於 2012-9-24 07:38 PM

至於速度加快
可以利用時間控制TimerEvent搭配nextFrame()來控制執行速度

his6214 發表於 2012-9-24 08:04 PM

我也看過您另外一篇,也下載看過。
如果要實現「掀開八次」
可以在玩家點選錯誤、成功之後將cups_mc影片片段跳到影格1(初始化動畫),並且開啟杯子的點選功能,根據您的設定因該是這個吧「_root.activate();」

並在root多增加一個變數計數玩家掀開幾次

jankin 發表於 2014-10-29 02:59 AM

不錯的小遊戲,我要下載來玩看看,真的很不錯哦!
<br><br><br><br><br><div></div>

leroygod 發表於 2014-12-21 01:55 AM

適用flash嗎?  可是我之前用的不能寫程式阿
頁: [1]