| 赞 | 274 |
| VIP | |
| 好人卡 | |
| 积分 | 496 |
| 经验 | |
| 最后登录 | 2024-6-21 |
| 在线时间 | 1919 小时 |
- 梦石
- 10
- 星屑
- 39550
- 在线时间
- 1919 小时
- 注册时间
- 2010-11-14
- 回帖
- 3214

|
发表于 2019-2-11 14:54:53
|
显示全部楼层
本帖最后由 KB.Driver 于 2019-2-11 17:18 编辑
在你问这个问题之前,我觉得你应该先搞清楚你要问的是什么。
如果你自己都不清楚自己问的问题是什么,别人更加没有办法帮到你。
1 “我想做一个xxx窗口”
请问窗口(Window)与界面(Scene)的区别与联系是什么?
这个“窗口”由什么方式进入?菜单选项?与某个NPC对话?在地图上按某个按键?
2 “光标落到该选项时自动显示一段文字”
请问显示文字的方式是什么?弹出新窗口?在已有的某个窗口里显示?
我的建议是,在熟练使用事件和插件脚本的基础上,再定制脚本比较好。
 
连问题名字带描述一起改,非常的高明(笑)
拾取物品窗口显示的脚本其实已经有了,就是Yanfly Ace Engine的。
所以追求华丽效果的话直接去找那个脚本比较好。
简单点的效果就看这个吧
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 生成所有窗口
- #--------------------------------------------------------------------------
- alias create_all_windows_cld99 create_all_windows
- def create_all_windows
- create_all_windows_cld99
- create_itemget_window
- end
-
- def create_itemget_window
- @itemget_window = Window_Itemget.new
- end
-
- def itemget_set_text(string)
- @itemget_window.set_text(string)
- end
-
- end
-
- # Window_Itemget 大部分方法来自Window_Help
- class Window_Itemget < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(line_number = 1)
- @line_number = line_number
- super(window_x, window_y, window_width, window_height)
- end
-
- def window_x
- 0
- end
-
- def window_y
- Graphics.height - window_height
- end
-
- def window_width
- Graphics.width / 2
- end
-
- def window_height
- fitting_height(@line_number)
- end
- #--------------------------------------------------------------------------
- # ● 设置内容
- #--------------------------------------------------------------------------
- def set_text(text)
- if text != @text
- @text = text
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 清除
- #--------------------------------------------------------------------------
- def clear
- set_text("")
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_text_ex(4, 0, @text)
- end
-
- def update
- super
- if Time.should_clear_text?
- self.clear
- Time.text_cleared
- end
- end
- end
-
- class Game_Party
- #--------------------------------------------------------------------------
- # ● 增加/减少物品
- # include_equip : 是否包括装备
- #--------------------------------------------------------------------------
- alias gain_item_cld99 gain_item
- def gain_item(item, amount, include_equip = false)
- gain_item_cld99(item, amount, include_equip)
- if SceneManager.scene_is?(Scene_Map)
- text = make_text_item(item, amount)
- SceneManager.scene.itemget_set_text(text)
- Time.clear_text_reserve
- end
- end
-
- def make_text_item(item, amount)
- gain_lose = amount > 0 ? "获得" : "失去"
- sprintf("%s了%d个%s", gain_lose, amount.abs, item.name)
- end
-
- #--------------------------------------------------------------------------
- # ● 增加/减少持有金钱
- #--------------------------------------------------------------------------
- alias gain_gold_cld99 gain_gold
- def gain_gold(amount)
- gain_gold_cld99(amount)
- if SceneManager.scene_is?(Scene_Map)
- text = make_text_gold(amount)
- SceneManager.scene.itemget_set_text(text)
- Time.clear_text_reserve
- end
- end
-
- def make_text_gold(amount)
- gain_lose = amount > 0 ? "获得" : "失去"
- sprintf("%s了%d%s", gain_lose, amount.abs, Vocab.currency_unit)
- end
-
- end
- class Time
- def self.clear_text_reserve
- @now = Time.now
- end
-
- def self.should_clear_text?
- return false unless @now
- (Time.now - @now).to_i >= 1
- end
-
- def self.text_cleared
- @now = nil
- end
- end
复制代码
|
评分
-
查看全部评分
|