设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 65|回复: 0

[转载发布] Fit to Browser Window

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    8256

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    30519
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    39669

    灌水之王

    发表于 6 天前 | 显示全部楼层 |阅读模式
    Fit to Browser Window
    v1.00

    Description

    Designed for browser deployed games, this automatically fits the game screen to the width and height of the client's browser window.

    Instructions

    Plug and play, though it is up to you to create appropriately sized maps and graphics, and to understand how and why this script should or should not be used.

    The creator can specify a maximum size and minimum size for their game; the game will not go beyond these boundaries. Leave blank or 0 and the game will just fill the available space.

    When testing this plugin please note that the size of the game's title screen and first map are for a small screen, so you won't initially notice that the plugin is working! As I said it is up to you to tailor your game to the plugin.

    Credits

    Credit to YanFly for a few lines from the resolution changing script. I have just plugged my own variables into these lines.

    Notes

    I am not used to releasing my plugins publicly so I apologise if I have broken any unwritten rules in my plugin; I've tried to keep to the standards set in the plugins I've seen.

    I want to do a new version eventually which will resize the game when the client resizes their browser window, but I am not sure if this is possible. Currently the player will have to reload the game if they change their window size.

    The plugin has no benefit whatsoever to a standalone release.

    Plugin

                    Code:       
    1. //=============================================================================
    2. // FitToBrowser.js
    3. //=============================================================================
    4. /*:
    5. * @plugindesc Fit to Browser v1.00
    6. * @author Afar Build 2 / Credit to YanFly for a couple of lines from ScreenResolution.js
    7. *
    8. * @param Minimum Width
    9. * @desc Makes the game not go below this size. 0 = doesn't matter.
    10. * Default: 640
    11. * @default 640
    12. *
    13. * @param Minimum Height
    14. * @desc Makes the game not go below this size.  0 = doesn't matter.                     
    15. * Default: 480
    16. * @default 480
    17. *
    18. * @param Maximum Width
    19. * @desc Makes the game not go above this size. 0 = doesn't matter.
    20. * Default: 1024
    21. * @default 1024
    22. *
    23. * @param Maximum Height
    24. * @desc Makes the game not go above this size. 0 = doesn't matter.                     
    25. * Default: 768
    26. * @default 768
    27. */
    28. var AmyPond = AmyPond || {};
    29. AmyPond.resolution = AmyPond.resolution || {};
    30. AmyPond.parameters = PluginManager.parameters('FitToBrowser');
    31. AmyPond.minWidth = Number(AmyPond.parameters['Minimum Width'] || 0);
    32. AmyPond.minHeight = Number(AmyPond.parameters['Minimum Height'] || 0);
    33. AmyPond.maxWidth = Number(AmyPond.parameters['Maximum Width'] || 0);
    34. AmyPond.maxHeight = Number(AmyPond.parameters['Maximum Height'] || 0);
    35. AmyPond.resize = function() {
    36.     AmyPond.w = window.innerWidth
    37.     || document.documentElement.clientWidth
    38.     || document.body.clientWidth;
    39.     AmyPond.h = window.innerHeight
    40.     || document.documentElement.clientHeight
    41.     || document.body.clientHeight;
    42.     if (AmyPond.minWidth != 0) {
    43.         if (AmyPond.w < AmyPond.minWidth) {
    44.             AmyPond.w = AmyPond.minWidth;
    45.         }
    46.     }
    47.     if (AmyPond.maxWidth != 0) {
    48.         if (AmyPond.w > AmyPond.maxWidth) {
    49.             AmyPond.w = AmyPond.maxWidth;
    50.         }
    51.     }
    52.     if (AmyPond.minHeight != 0) {
    53.         if (AmyPond.h < AmyPond.minHeight) {
    54.             AmyPond.h = AmyPond.minHeight;
    55.         }
    56.     }
    57.     if (AmyPond.maxHeight != 0) {
    58.         if (AmyPond.h > AmyPond.maxHeight) {
    59.             AmyPond.h = AmyPond.maxHeight;
    60.         }
    61.     }
    62.     SceneManager._screenWidth = AmyPond.w;
    63.     SceneManager._screenHeight = AmyPond.h;
    64.     SceneManager._boxWidth = AmyPond.w;
    65.     SceneManager._boxHeight = AmyPond.h;
    66.    window.resizeBy(AmyPond.w, AmyPond.h);
    67. };
    68. AmyPond.resize();
    69. //=============================================================================
    70. // End of File
    71. //=============================================================================
    复制代码




    本贴来自国际rpgmaker官方论坛作者:Ellie Jane处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/fit-to-browser-window.75199/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 18:44 , Processed in 0.063777 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表