Flash CS4三维游戏设计(赛车)(15)
时间:2016-11-25 19:00 来源:毕业论文 作者:毕业论文 点击:次
} if (m_nSpeedZ>0) { m_nSpeedZ--; } if (m_nSpeedZ<0) { m_nSpeedZ++; } if (m_nSpeedX>0) { m_nSpeedX-=4; } if (m_nSpeedX<0) { m_nSpeedX+=4; } } } } (4) RacingGame类的代码 RacingGame类对应游戏的舞台,该类代码如下所述: package classes { import flash.display.MovieClip; import flash.events.Event; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.utils.Timer; public class RacingGame extends MovieClip { private var m_aKeys:Array=[-1,-1,-1,-1]; public function RacingGame() { T_Road.stop(); T_Tree.stop(); T_Rock.stop(); this.stop(); T_PlayButton.addEventListener(MouseEvent.MOUSE_UP,OnMouseUp); } public function OnMouseUp(e:MouseEvent):void { T_Title.visible=false; T_PlayButton.visible=false; this.stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyboardDown); this.stage.addEventListener(KeyboardEvent.KEY_UP,onKeyboardUp); var myTimer:Timer=new Timer(100,0); myTimer.addEventListener("timer",timerHandler); myTimer.start(); } public function onKeyboardDown(e:KeyboardEvent):void { for(var i:int=0;i<m_aKeys.length;i++) { if(m_aKeys[i]==e.keyCode) return; } for(i=0;i<m_aKeys.length;i++) { if(m_aKeys[i]==-1) m_aKeys[i]=e.keyCode; break; (责任编辑:qin) |