| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2021-10-3 |
| 在线时间 | 1006 小时 |
- 梦石
- 0
- 星屑
- 108
- 在线时间
- 1006 小时
- 注册时间
- 2008-11-9
- 回帖
- 1633
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 判约之轮 于 2012-4-4 17:21 编辑
不知道该发在哪里,要说求具体代码也不是,要说求思路···总觉得如果能知道到底错在哪里的话,以后自己继续编写下去也容易得多了~
所以发在这个区了嗯,如果违反了版规的话,就请版主移动到提问区吧囧~
目前在做一个仿幻想三国志1的菜单系统,背景问题解决了,菜单位置问题也解决了,字体问题也解决了~
于是在光标暂时性置换问题上卡住了~
于是来求思路······
我原先的做法是在Window_Base里面将初始化函数第二行改为:- def initialize(x, y, width, height)
- super
- if $menu_open == false
- self.windowskin = Cache.system("Window")
- else
- self.windowskin = Cache.system("Window2")
- end
- update_padding
- update_tone
- create_contents
- @opening = @closing = false
- end
复制代码 而Scence_MenuBase中重定义掉这些函数:- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_background
- $menu_open = true
- @actor = $game_party.menu_actor
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_background
- $menu_open = false
- end
- #--------------------------------------------------------------------------
- # ● 生成背景
- #--------------------------------------------------------------------------
- #def create_background
- # @background_sprite = Sprite.new
- # @background_sprite.bitmap = SceneManager.background_bitmap
- # @background_sprite.color.set(16, 16, 16, 128)
- #end
- #--------------------------------------------------------------------------
- # ● 生成背景2
- #--------------------------------------------------------------------------
- def create_background
- @menuback = Sprite.new
- @menuback.bitmap = Bitmap.new("Graphics/Menu/background.png")
- @menuback.x = 0
- @menuback.y = 0
- @menuback.z = 0
- @menuback.opacity = 255
- @menutext1 = Sprite.new
- @menutext1.bitmap = Bitmap.new("Graphics/Menu/menutext1.png")
- @menutext1.x = 0
- @menutext1.y = 0
- @menutext1.z = 2
- @menutext1.opacity = 255
- $menu_open = true
- end
- #--------------------------------------------------------------------------
- # ● 释放背景
- #--------------------------------------------------------------------------
- def dispose_background
- #@background_sprite.dispose
- @menuback.dispose
- @menutext1.dispose
- $menu_open = false
- end
复制代码 在Window_Command中,各种设置文字对齐的操作就不提了,那都是些无关紧要的东西~
我的整体思路是:
利用开关型变量,在ESC窗口开启时,自动把窗口皮肤切换到透明模式,只剩下选择框还保留着(已解决,另一个窗口皮肤用PS很容易弄出来)
在显示菜单的同时,将真正的菜单界面以图片的形式显示在最下层(即z = 0),文字作为单独的图片显示在第二层(z = 2),用来将选中的选项高亮显示的覆盖图片显示在第一层(z = 1)(已解决部分,第一层因为需要光标的配合还没解决)
调整选单窗口的坐标和文字间距,达到调整光标位置的效果(已解决)
调整头像等的坐标和缩放度,使其适应菜单背景(有思路,未解决)
其余下级菜单等预备以后再解决~
其实就是想问一下,到底怎么才能把矩形类的光标变为精灵类的图片呢?
我试过将显示和更新光标的函数重定义为精灵类的,可是一进入ESC菜单就报错~
大概是这一个函数:- #--------------------------------------------------------------------------
- # ● 绘制内容
- # args : 与 Bitmap#draw_text 相同
- #--------------------------------------------------------------------------
- def draw_text(*args)
- contents.draw_text(*args)
- end
复制代码 但是我始终是不明白,我在我修改的脚本里并没有找到这个子函数,contents函数虽然有,但是也丝毫看不出怎么会出现错误提示中"5 for 3"(参数错误)这种情况~
顺便在下面贴上我在Window_Selectable中修改的函数:- #--------------------------------------------------------------------------
- # ● 获取项目的绘制矩形
- #--------------------------------------------------------------------------
- def item_rect(index)
- if $menu_open == false
- rect = Rect.new
- # if $menu_open == false
- rect.width = item_width
- # else
- # rect.width = 44
- # end
- rect.height = item_height
- rect.x = index % col_max * (item_width + spacing)
- rect.y = index / col_max * item_height
- rect
- else
- $rect = Sprite.new
- $rect.bitmap = Bitmap.new("Graphics/Menu/menurect1.png")
- $rect.x = index % col_max * (item_width + spacing)
- $rect.y = index / col_max * item_height
- $rect.z = 1
- $rect
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取项目的绘制矩形(内容用)
- #--------------------------------------------------------------------------
- def item_rect_for_text(index)
- rect = item_rect(index)
- if $menu_open = false
- rect.x += 4
- rect.width -= 8
- rect
- else
- $rect.x += 4
- $rect
- end
- end
复制代码- #--------------------------------------------------------------------------
- # ● 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- if $menu_open == false
- if @cursor_all
- cursor_rect.set(0, 0, contents.width, row_max * item_height)
- self.top_row = 0
- elsif @index < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- cursor_rect.set(item_rect(@index))
- end
- else
- if @cursor_all
- #cursor_rect.set(0, 0, contents.width, row_max * item_height)
- $rect.x = 10
- $rect.y = 105
- $rect
- self.top_row = 0
- elsif @index < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- cursor_rect.set(item_rect(@index))
- end
- end
- end
复制代码- #--------------------------------------------------------------------------
- # ● 消除项目
- #--------------------------------------------------------------------------
- def clear_item(index)
- #contents.clear_rect(item_rect(index))
- $rect.dispose
- end
复制代码 |
|