egret键盘事件监听

    document.addEventListener("keydown", function (event: any) {
                //alert(event.key);
                //console.log(event.keyCode);//ASCII码
                if (event.key == "1") {
                    //this.play();//报错property  "play" does not exist on type "document" 此时this 指的是document
                } 
            });

1, egret 中好像没有看到 ?PC 按键事件的类库,
但是可以直接使用 

document.addEventListener("keydown",function(evt:any){
if(evt.keyCode==65){
//
}
})

 类似

2, egret 的index.html 里面就会设置目标宽高,

data-content-width="640"

data-content-height="1136"

然后在页面中
如果设计的时候是640 *1136 的话, ? 在不同的手机上就会根据屏幕适配方法来调整了, 例如, fixedwidth 那么宽 就一定会占满屏幕,
但是高度就不一定了.

3, TypeScript 的方法重写也是跟Java 差不多, 只要子类有跟父类一样签名的方法就会自动重写.
都不需要像c# 一样加个override

posted @ 2019-03-28 23:28  icon_sunny  阅读(799)  评论(0编辑  收藏  举报