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

[制作教程] Anatomy of Windows

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

    连续签到: 2 天

    [LV.7]常住居民III

    4552

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Also viewable: http://cobbtocs.co.uk/wp/?p=401

    So I’ve been meaning to do this for a while and today I finally got nudged into doing this so let’s jump right into the anatomy of windows!

    Firstly there are a lot of windows in RPG Maker Ace by default and if you’re scripting at some point you’re going to need to make a window. Which can be quite daunting and also waste a lot of your time when you’re trying to get it right. First let’s have a look at all the windows, the arrows indicate inheritance.



    As you can see all windows inherit from Window_Base and there are several windows that act as bases for the other windows. Let’s strip it down to just the windows that are inherited from:



    That’s a bit easier on the eyes now isn’t it? Also in case you’re not sure what I mean by inheritance, I’ll explain it quickly. Inheritance is where one class inherits from another class which is to say that it effectively copies all of the original classes methods and variables. So we can literally do this:



                    Code:       
    1. class Window_Name < Window_Base
    2. end
    复制代码

    And our new window Window_Name has everything Window_Base has, pretty cool huh?

    Ok so now we need to decide what window to inherit from, generally it is going to be one of four:



    So our first question should be are you using the window to just display information or is the player going to be able to select something in the window? Well if you just want to display things then all you really need to do is look at the drawing methods in Window_Base. If you want to have the window selectable then you need to know a few more things and we’ll go through them. The easiest way I think would be to go through the methods you’ll use/edit most. So let’s start there.



    Window_Base

    line_height – this is by default 24, the hight of an icon and the default font size. Useful with fitting_height which calculate the minimum window height given a number of lines.

    standard_padding – if you ever need to get closer to the edge of a window then decrease this also if the window itself is not visible (self.opacity = 0) then this padding is wasted. By default this is 12.

    Now going into Window_Selectable assume that the above remains unchanged unless I mention it again.

    Window_Selectable

    col_max – the number of columns by default 1.

    spacing – the space between the coloums. 32 by default.

    item_max – 0 by default, you need to change that if you’re going to display anything. I’m going to advocate having an array that contains the data you need to draw your items and then you can make this something like @data.size

    item_width – you are very unlikely to need to change this, in fact if you think you need to change this then you should probably be looking at standard_padding and spacing. This automatically calculates the width your item should have.

    item_height -this is by default the same size as line_height, you should only need to change it  if you for example have have the battle hud in columns and not rows and need to make the cursor bigger. Or maybe you want to display more information about items and want each items to have another row of space to work with.

    item_rect -this gets you a rect based on the item number this rect is also the one which the cursor uses. In general you should use item_rect_for_text

    item_rect_for_text -Basically item_rect but  with four pixels cut off each side, basically stopping the cursor obscuring the first or last letters of anything you put.

    Also in case you didn’t already know you need to write a draw_item method a standard one would get a rect from item_rect_for_text and then used it to position everything.

    Window_Command

    Right a few changes this time Window_Command uses @list to store the data for drawing (item_max is automatically done for you in Window_Command) and you should add them using add_command. Which accepts two to four parameters

    name, symbol, enabled, ext

    name is what’s displayed to the players, symbol is something like :identifier and enabled is whether or not they can click that option by default this is true and I don’t know what ext does I’ve never used it.

    visible_line_number – how many rows before the command window scrolls.

    make_command_list – this is where you should really be adding commands to the window, it’s called when the window is made and again everytime the command wndow is refreshed.

    Window_HorzCommand

    There’s no real difference for you between this and Window_Command except if you want this window to scroll. There is a bug with the default scripts and I don’t know if they fixed it yet. If when you make a scrolling HorzCommand window it scrolls but doesn’t work right add this code to your project:



                    Code:       
    1. class Window_HorzList < Window_HorzCommand
    2. #--------------------------------------------------------------------------
    3. # * Set Leading Digits - BUGFIX
    4. #--------------------------------------------------------------------------
    5. def top_col=(col)
    6. col = 0 if col < 0 col = item_max - (col_max - 1) if col > item_max - 1
    7. self.ox = col * (item_width + spacing)
    8. end
    9. end
    复制代码




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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-15 19:08 , Processed in 0.120966 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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