用户:
LZ编编编编程猫查看:578 回复:11 评论:10 创建时间:2023-07-18T19:49:22
world.onPlayerJoin(async ({ entity }) => {
await gui.init(entity, {
"": {
display: true,
data: `
<dialog percentWidth="100" percentHeight="100" id="fullscreen">
</dialog>
`
}
});
console.log(await gui.getAttribute(entity, "#fullscreen", "width"));
console.log(await gui.getAttribute(entity, "#fullscreen", "height"));
gui.remove(entity, "#fullscreen");
});
LZ编编编编程猫实际上好像要乘上1.25才是真实的游戏屏幕大小()
world.onPlayerJoin(async ({ entity }) => {
await gui.init(entity, {
"": {
display: true,
data: `
<dialog percentWidth="100" percentHeight="100" id="fullscreen">
</dialog>
`
}
});
entity.player.screenWidth = await gui.getAttribute(entity, "#fullscreen", "width") * 1.25;
entity.player.screenHeight = await gui.getAttribute(entity, "#fullscreen", "height") * 1.25;
console.log(entity.player.name + '的游戏屏幕大小为' + entity.player.screenWidth + '*' + entity.player.screenHeight);
gui.remove(entity, "#fullscreen");
});

点赞1
评论
𝙲ℴ𝗌𝔦𝒹ₑ𝑟h5获得的屏幕大小是浏览器大小,那么在box里也同理(
点赞1
评论
全屏模式=屏幕分辨率=浏览器页面=bx获得的
没听懂))这个原理是生成一个覆盖整个游戏界面的dialog,然后获取dialog的长和宽()不是必须开全屏啊()
webapi没听说过获得屏幕信息的api啊()
游戏界面 == 网页界面
这样获取游戏屏幕分辨率可以方便做排版,比如居中、区分手机和电脑进行界面排版之类的()
是,但不需要全屏也能获取界面大小))
az这个不是html,是xml()()
七式草莓你猜我这个好在哪里(提示:Network latency)
world.onPlayerJoin(async ({ entity }) => {
await gui.init(entity, {
"": {
display: true,
data: `
<dialog percentWidth="100" percentHeight="100" id="fullscreen">
</dialog>
`
}
});
[entity.player.screenWidth, entity.player.screenHeight] = (await Promise.all([gui.getAttribute(entity, "#fullscreen", "width"), gui.getAttribute(entity, "#fullscreen", "height")])).map((v) => v * 1.25);
console.log(entity.player.name + '的游戏屏幕大小为' + entity.player.screenWidth + '*' + entity.player.screenHeight);
gui.remove(entity, "#fullscreen");
});点赞1
评论
时间减半(