最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Egret Pro學(xué)習(xí)之路(一)輸入

2020-02-25 10:45 作者:抑制住a  | 我要投稿

新建一個(gè)TS文件,命名為Test.ts,寫上以下內(nèi)容

import?{?Application,?Behaviour?}?from?"@egret/engine";

import?{?component?}?from?"@egret/ecs/dist";

@component()

export?class?test?extends?Behaviour?{

}


導(dǎo)入InputCode,?InputManager模塊

import?{?InputCode,?InputManager?}?from?"@egret/input";


在test類中寫上以下內(nèi)容,onUpdate方法每幀都會(huì)調(diào)用一次,onStart方法開始的時(shí)候會(huì)調(diào)用一次,InputManager為輸入管理器,用來處理鍵盤按鍵的按下抬起等。

private?_inputManager:?InputManager;

public?onUpdate()?{

}

public?onStart()?{

}


在onStart方法中寫上以下內(nèi)容

?this._inputManager?=?Application.instance.globalEntity.getComponent(InputManager)!;


在onUpdate方法中寫上以下內(nèi)容

?if?(this._inputManager.getInput(InputCode.KeyW).isDown)?{

????????????console.log("按下W鍵");

}

else?if?(this._inputManager.getInput(InputCode.KeyW).isUp)?{

????????????console.log("抬起W鍵");

}

else if?(this._inputManager.getInput(InputCode.KeyW).isHold)?{

????????????console.log("長按W鍵");

}


然后在Main.ts中寫上以下內(nèi)容

import?{?test?}?from?"./Test";


這樣我們就可以在Egret Pro里添加上我們寫的這個(gè)組件了。

運(yùn)行效果如下





參考資料

Egret Pro官方文檔:http://pro.egret.com/docs/guide/engine-features-input/

Egret Pro學(xué)習(xí)之路(一)輸入的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
拜城县| 三都| 罗平县| 紫阳县| 澳门| 吴堡县| 长阳| 德阳市| 荆门市| 常德市| 高要市| 江津市| 南昌县| 泗洪县| 石楼县| 博兴县| 南投县| 宁德市| 通州区| 西贡区| 乐清市| 怀仁县| 灵山县| 乳山市| 平原县| 全南县| 墨江| 宜黄县| 卢湾区| 深水埗区| 平和县| 元阳县| 丰顺县| 延庆县| 瑞金市| 桃源县| 锦州市| 修水县| 清水县| 河间市| 阿巴嘎旗|