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

[制作教程] Center Windows XP Edition

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

    连续签到: 2 天

    [LV.7]常住居民III

    4471

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 7 天前 | 显示全部楼层 |阅读模式
    Center Windows XP Edition

    By Kyonides


    Difficulty Level: Intermediate

    Introduction


    The sole purpose of this tutorial is to show you how easily you can center any kind of windows at will.
    Even so a few basic features will be reviewed quickly to remind you of some important and unavoidable aspects of creating or modifying anything on a game scene.

    Planned Stages

    1 - Introductory Stage


    • Display Windows
    • Unfreeze / Freeze Pictures
    • Create a Loop
    • Update Method
    2 - Window Creation

    • Basic Window's Elements
    • Passing Parameters
    • Creating Bitmaps & Strings
    • Drawing Bitmaps & Strings
    3 - Alter Windows

    • Modularity & Encapsulation
    • Relocate Windows
    • Improve Modularity by Creating Reusable Code
    • Center Windows

    Introductory Stage
    Optional Depending on Your End Goal​


    Note: You may not need to go through this stage if you're just planning to modify a default script.

    Step 1 - To properly Display Windows we need a scene.

    SpoilerThe engine has plenty of them but a brand new one will let you concentrate on our new windows only.

    Here's the barebones of our new scene:

                    Ruby:        
    class Scene_Test end


    Following the ancient RM class naming conventions, our scene is called Scene_Test.
    class lets us create a brand new object that can be copied multiple times.

    Why is this important?

    Well, without that we could be forced to draw the last state of that very same scene only instead of getting a fresh scene on demand.
    You wouldn't like to only open the inventory or the equip menu every single time you hit the Cancel button right?
    You want some options to show up instead. Then a class is what you need here.

    Now that we got one, what do we do next?




    Step 2 - Unfreeze / Freeze all pictures on screen.

    Spoiler                 Ruby:        
    class Scene_Test   def main     Graphics.transition     # some code here     Graphics.freeze   end end


    def means we are defining a method that will belong to our custom scene class from now on.

    There we defined the main method. This is a method that all scenes need in order to be able to keep playing our game. The lack of this method would quickly throw an error in our faces here.

    We need to call the transition and freeze methods defined in the Graphics module to be able to create a seamless transition between the previous scene, our scene and the next one. This is mandatory.

    Usually, this means leaving the map, opening our scene, and then going back to the current map.




    Step 3 - Create a loop for this new scene.

    Spoiler                 Ruby:        
    class Scene_Test   def main     Graphics.transition     loop do       Graphics.update       Input.update       update       break if $scene != self     end     Graphics.freeze   end end


    Why do we create a loop?
    That's because we need to stay in our current scene. Otherwise, it'd go back to the map. It's highly likely that you'd just notice that the map events stopped moving briefly and that would be all.

    To keep our scene running smoothly, we need to update 2 things:

    • Graphics
    • Input
    If we don't refresh our graphics, the maker will soon tell us that it got stuck.
    Not updating the input function would render our new scene completely useless UNLESS we never intended to make it interactive.

    Note: Usually, transitional scenes don't need any input at all. Instead they'd depend on a timer.

    We also need to break that loop or will never be able to return to our map or any other scene you can think off. self stands for the current scene we're working on.

    Note: So far we can't see anything on screen... except for an error message telling us that there's no update method.




    Step 4- Adding an update method.

    Spoiler: Tutorial 01 Code
                    Ruby:        
    class Scene_Test   def main     Graphics.transition     loop do       Graphics.update       Input.update       update       break if $scene != self     end     Graphics.freeze   end    def update     if Input.trigger?(Input::B)       $game_system.se_play($data_system.cancel_se)       $scene = Scene_Map.new       return     end   end end


    SpoilerNow that the update method does exist, we can leave our empty scene and return to the map.

    Input.trigger? allows us to ask if the player has pressed a button, the Cancel button in this case, and released it. That's triggering a button. In all RGSS-based engines those buttons are represented by CONSTANTS like A, B, C, SHIFT and others. All of them are part of the Input module. The reference :: operator makes the connection for us.

    The $game_system.se_play($data_system.cancel_se) method call is the long way RMXP relies upon to make any SE play in game. In this particular case it plays the Cancel SE.

    $game_system is our running copy of the Game_System class.
    se_play is one of its methods. It does play SE.
    $data_system is a copy of the System tab's contents already loaded into memory.
    cancel_se stands for the Cancel SE variable we once picked in the System tab.

    If we had never added such a if statement, our condition, we wouldn't be able to ever get out of our test scene.

    You don't want to shut down your game by brute force, do you?


    return stands for returning to the method that originally called it. In this case it's the loop found inside the main method.




    Note: Keep in mind that right now we can only watch a big black nothing on screen.


    In my next chapter I'll start dealing with defining the actual windows.


    本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/center-windows-xp-edition.167070/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 18:01 , Processed in 0.070446 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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