[LayaAir 1.0]设置适配SCALE_FIXED_WIDTH,结果少部分andriod机型不能正确适配屏幕
主要设置屏幕适配的代码是下面,大部分手机是好的,有少部分andriod机器有比较大的概率出现半屏的情况。请问下是引擎不兼容呢,还是代码写的不完善
class Main {
private _roomId = 0;
constructor(roomId?: number) {
this._roomId = roomId;
Laya.init(750, 1218, Laya.WebGL);
Laya.Browser.document.title = 'GG游戏;
if (Laya.Browser.onPC) {
//设置舞台缩放模式
Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
} else {
Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_WIDTH;
Laya.stage.screenMode = Laya.Stage.SCREEN_VERTICAL;
}
Laya.stage.bgColor = "#222d39";
//设置舞台对齐模式
Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
//Laya.stage.frameRate = Laya.Stage.FRAME_MOUSE;
Laya.stage.frameRate = Laya.Stage.FRAME_SLOW;
//注册自定义按钮控件
Laya.View.regComponent("ScaleButton", ScaleButton);
Laya.loader.load("res/atlas/com/loading.atlas", Laya.Handler.create(this, this.loadGame));
}
private loadGame(): void {
var resArray = [
{ url: "res/atlas/lobby/create_room.atlas", type: Laya.Loader.ATLAS },
.......
];
let createGameScene = () => {
Laya.stage.width = 1218;
Laya.stage.height = 750;
if (Laya.Browser.onPC) {
//设置舞台缩放模式
Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
} else {
Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_WIDTH;
Laya.stage.screenMode = Laya.Stage.SCREEN_HORIZONTAL;
}
AppConfig.init();
let game = new Game(Laya.stage);
if (!this._roomId && this.getGets()["roomId"]) {
this._roomId = parseInt(this.getGets()["roomId"]);
}
if (this._roomId) {
game.enterRoom(this._roomId);
}
}
AppFunction.showLoadingView_fullScreen(resArray, createGameScene, null, "正在进入游戏...");
}
private getGets() {
var tempUrl: String = Laya.Browser.window.location.href;
var u = tempUrl.split("?");
var gets: Object = {};
if (u[1]) {
u = u[1].split("&");
for (var p of u) {
var param = p.split("=");
gets[param[0]] = param[1];
}
}
return gets;
}
}
class Main {
private _roomId = 0;
constructor(roomId?: number) {
this._roomId = roomId;
Laya.init(750, 1218, Laya.WebGL);
Laya.Browser.document.title = 'GG游戏;
if (Laya.Browser.onPC) {
//设置舞台缩放模式
Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
} else {
Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_WIDTH;
Laya.stage.screenMode = Laya.Stage.SCREEN_VERTICAL;
}
Laya.stage.bgColor = "#222d39";
//设置舞台对齐模式
Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
//Laya.stage.frameRate = Laya.Stage.FRAME_MOUSE;
Laya.stage.frameRate = Laya.Stage.FRAME_SLOW;
//注册自定义按钮控件
Laya.View.regComponent("ScaleButton", ScaleButton);
Laya.loader.load("res/atlas/com/loading.atlas", Laya.Handler.create(this, this.loadGame));
}
private loadGame(): void {
var resArray = [
{ url: "res/atlas/lobby/create_room.atlas", type: Laya.Loader.ATLAS },
.......
];
let createGameScene = () => {
Laya.stage.width = 1218;
Laya.stage.height = 750;
if (Laya.Browser.onPC) {
//设置舞台缩放模式
Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
} else {
Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_WIDTH;
Laya.stage.screenMode = Laya.Stage.SCREEN_HORIZONTAL;
}
AppConfig.init();
let game = new Game(Laya.stage);
if (!this._roomId && this.getGets()["roomId"]) {
this._roomId = parseInt(this.getGets()["roomId"]);
}
if (this._roomId) {
game.enterRoom(this._roomId);
}
}
AppFunction.showLoadingView_fullScreen(resArray, createGameScene, null, "正在进入游戏...");
}
private getGets() {
var tempUrl: String = Laya.Browser.window.location.href;
var u = tempUrl.split("?");
var gets: Object = {};
if (u[1]) {
u = u[1].split("&");
for (var p of u) {
var param = p.split("=");
gets[param[0]] = param[1];
}
}
return gets;
}
}
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
boobo
赞同来自:
Aar0n
赞同来自: