zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    SGU 242. Student's Morning( 网络流 )
    8.23单词
    bzoj1083:繁忙的城市
    求连通分量
    bzoj2761:不重复数字
    bzoj1207:打鼹鼠
    bzoj2748:音量调节
    bzoj1050:旅行comf
    bzoj1996:合唱队
    羞耻羞耻羞耻!!!
  • 原文地址:https://www.cnblogs.com/allyh/p/10618567.html
Copyright © 2011-2022 走看看