作者etrexetrex (moonet)
看板Flash
标题Re: [问题] dear all
时间Sat Oct 11 10:44:13 2008
※ 引述《kunde (Kunde)》之铭言:
: 各位好~~
: 这是我们写的一个小游戏~~
: http://140.122.91.37
: 但是~~他的操控还有点不稳~~
: 反应没有那麽快~~
: 有建议使用怎样的函式库吗?
: 下面是我们用的~~
: function a(event:KeyboardEvent):void {
: if (event.keyCode==37) {
: box1.rotation-=2;
: }
: if (event.keyCode==39) {
: box1.rotation+=2;
: }
: }
因为键盘按住是
*-------*********
*代表呼叫KeyboardEvent
为了避免这种延迟
在as2时通常会使用Key.isDown
(Key.isDown 方法)
public static isDown(code: Number ) : Boolean
F1里面有范例:
下列 Script 能让使用者控制某个影片片段 (car_mc) 的位置:
car_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x += 10;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 10;
}
};
--
blog:
http://etrex.blogspot.com/
site:
http://web.ntust.edu.tw/~B9409041/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.120.112.186