Re: [問題] dear all
※ 引述《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
討論串 (同標題文章)