看板 Flash 關於我們 聯絡資訊
因為想做一個打地鼠的遊戲,但是加分的部分加上去以後就不行了 原本可以讓我的mouse每兩秒出現在螢幕上 一秒後又消失的說..... 可以幫我看一下嗎@@" 謝謝大家!!! --------------以下是程式碼------------------------ var score : int = 0; var playgame = new Timer(2000,20); playgame.addEventListener(TimerEvent.TIMER,onetime); playgame.start(); function onetime(event:TimerEvent){ var mouse : Mouse; mouse = new Mouse(); mouse.x = Math.random()*550; mouse.y = Math.random()*400; addChild(mouse) var looktime = new Timer(1000,1); looktime.addEventListener(TimerEvent.TIMER_COMPLETE,mouseend); looktime.start(); ---------------------------------------------------這段加上就不行了 mouse.addEventListener(MouseEvent.CLICK,hit); function hit(event:MouseEvent){ score = score + 1 removeChild(mouse) } ---------------------------------------------------- function mouseend(event:TimerEvent){ removeChild(mouse) } } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.42.241.111 ※ 文章網址: http://www.ptt.cc/bbs/Flash/M.1398001875.A.1EF.html
starboarder:http://ppt.cc/ytai 04/20 22:04
starboarder:抱歉 第一個沒有縮網址就上傳了 請看第二個@@" 04/20 22:05
SheLoBDenI:function 裡面沒有宣告mouse,他只能抓到最後一個。 04/21 11:32
SheLoBDenI:你應該是要用event.target才是移除每次click的目標 04/21 11:33
KawasumiMai:痾...你Function裡面包function? 04/22 23:24
KawasumiMai:試著把function抓出來獨立然後確定好變數的區域 04/22 23:28
KawasumiMai:然後使用上面說的event.target吧 04/22 23:28
KawasumiMai:猜測你應該是一開始放外面的時候抓不到mouse所以才 04/22 23:28
KawasumiMai:扔進去裡面? 04/22 23:28