熱門文章

Ⓒegret.OrientationMode 用法

橫豎屏切換的變通方法

let tf = new egret.TextField();
this.addChild(tf);
let orientation_flag; //判斷橫豎改變
window.onresize = () => {
    let orientation = window.innerHeight > window.innerWidth ? egret.OrientationMode.PORTRAIT : egret.OrientationMode.LANDSCAPE;
    if (orientation_flag != orientation) {
        orientation_flag = orientation;
        this.stage.dispatchEventWith("orientation_change", false, orientation);
    }
}
this.stage.addEventListener("orientation_change", (e) => tf.text = e.data, this);
window.onresize(null);

沒有留言:

張貼留言