猫史档案馆


岛喵ro版用gui获取玩家游戏屏幕分辨率代码

用户:LZ编编编编程猫LZ编编编编程猫查看:10 回复: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");
});


回复

上一页1 页 / 共 1下一页
Star_Ink_sansStar_Ink_sans

wow nb!

点赞1


评论


Star_Ink_sansStar_Ink_sans

沙发顺便顶一下)

点赞1


评论


LZ编编编编程猫LZ编编编编程猫

nomen竟然已经出了这个功能了()()不过这段代码我昨天已经发过了((((

点赞1


评论


LZ编编编编程猫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");
});

center_image

点赞1


评论


145a145a

nb!!!!!

点赞1


评论


ZNS_哪吒ZNS_哪吒

d()

点赞1


评论


治愈绾兮治愈绾兮

woc!

点赞1


评论


𝙲ℴ𝗌𝔦𝒹ₑ𝑟𝙲ℴ𝗌𝔦𝒹ₑ𝑟

注:必须是全屏模式下()

点赞1


评论


𝙲ℴ𝗌𝔦𝒹ₑ𝑟𝙲ℴ𝗌𝔦𝒹ₑ𝑟

h5获得的屏幕大小是浏览器大小,那么在box里也同理(

点赞1


评论


万嘉麒万嘉麒

不错不错

点赞1


评论


七式草莓七式草莓

你猜我这个好在哪里(提示: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


评论