egret 开发阶段 显示屏幕像素坐标

    private showMousePos() {
        
        var canvas = document.getElementsByTagName('canvas')[0];
        var ctx = canvas.getContext('2d');
        var tips:egret.TextField = new egret.TextField();
        tips.size = 32; 
        tips.x = 0; 
        tips.y = 380; 
        tips.width = this.stage.stageWidth - 40;
        this.addChild(tips);    
        
        canvas.addEventListener('mousemove', function (e) {
            // 偏移值一直变。。。 不准,是因为egret引擎使用了屏幕适配策略,需要开发阶段需要屏蔽适配:data-scale-mode="noScale" 
            tips.text = "x:" + (e.x) + ", y:" + e.y; 
        }.bind(this))
    }


 
 

你可能感兴趣的:(game)