[LayaAirIDE 1.0]SCALE_FIXED_WIDTH适配屏幕的问题
主要设置屏幕适配的代码是下面,大部分手机是好的,有少部分andriod机器有比较大的概率出现半屏的情况。请问下是引擎不兼容呢,还是代码写的不完善
问题手机有:三星S8+,oppo r9m,oppo x20,vivo y75,opp r11,opp r15等
user_agent来看有蛮多是 66.0.3359.126 MQQBrowser,如:
Mozilla/5.0 (Linux; Android 8.0.0; SM-G9550 Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TB
Mozilla/5.0 (Linux; Android 8.0.0; STF-AL10 Build/HUAWEISTF-AL10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrows
Mozilla/5.0 (Linux; Android 6.0.1; OPPO R9s Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 T
代码如下,另附上demo
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;
}
}
问题手机有:三星S8+,oppo r9m,oppo x20,vivo y75,opp r11,opp r15等
user_agent来看有蛮多是 66.0.3359.126 MQQBrowser,如:
Mozilla/5.0 (Linux; Android 8.0.0; SM-G9550 Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TB
Mozilla/5.0 (Linux; Android 8.0.0; STF-AL10 Build/HUAWEISTF-AL10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrows
Mozilla/5.0 (Linux; Android 6.0.1; OPPO R9s Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 T
代码如下,另附上demo
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 个回复
想个名字好烦呀!
赞同来自:
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.scaleMode = Stage.SCALE_SHOWALL;
if(Browser.onMobile) Laya.stage.screenMode=Stage.SCREEN_HORIZONTAL;
(as写法,你稍微调整一下)
wu语
赞同来自:
如果是app,可能是全面屏设备问题