Project1
标题:
我参考范例做的物品大图脚本
[打印本页]
作者:
zxc3824
时间:
2011-1-2 17:12
标题:
我参考范例做的物品大图脚本
本帖最后由 zxc3824 于 2011-1-15 12:42 编辑
这是我参考着做的,但是进入游戏以后发生错误,请高手帮忙解决一下,错误部分用红字体标出
#==============================================================================
# 本脚本来自[url]www.66rpg.com[/url],转载和使用请保留此信息 #==============================================================================
module RPG
class Weapon
def name
name = @name.split(/@/)[0]
return name != nil ? name : ''
end
def pic_name
pic_name = @name.split(/@/)[1]
return pic_name != nil ? pic_name : ""
end
end
class Armor
def name
name = @name.split(/@/)[0]
return name != nil ? name : ''
end
def pic_name
pic_name = @name.split(/@/)[1]
return pic_name != nil ? pic_name : ""
end
end
end
#==============================================================================
# ■ Window_Equip
#------------------------------------------------------------------------------
# 普通物品大图标显示。
#==============================================================================
class Window_Item < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
@item = nil
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item != nil
bitmap = RPG::Cache.picture(@item.pic_name)
pic_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(0, 0, bitmap, pic_rect)
end
end
def set_item(item)
@item = item
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口、物品窗口
@help_window = Window_Help2.new
@item_window = Window_Item.new
# 关联帮助窗口
@item_window.help_window = @help_window [color=Red]就是这里,系统说我未定义[/color]
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# 执行过度
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@item_window.update
@target_window.update
# 物品窗口被激活的情况下: 调用 update_item
if @item_window.active
update_item
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
end
end
复制代码
这是工程
物品大图工程.rar
(1.16 MB, 下载次数: 77)
2011-1-15 12:42 上传
点击文件名下载附件
作者:
白鬼
时间:
2011-1-2 20:33
Window_Item 有调用 help_window 吗?
作者:
zxc3824
时间:
2011-1-4 21:14
回复
白鬼
的帖子
默认脚本那里抄过来的
作者:
白鬼
时间:
2011-1-4 21:57
回复
zxc3824
的帖子
我想我大概知道了。
Window_Item 有调用 help_window
但是并没有给help_window 定义
而装备大图的时候调用了Window_Item,却也没有定义help_window
于是出现了这个错误
解决方法:最好把你的工程拿来让大家帮你看看。因为这段脚本是没什么问题的。
让大家看看是哪里调用了Window_Item 却没有定义help_window
作者:
enghao_lim
时间:
2011-1-7 00:44
其实是你得window_item是继承window_base的父类,window_base未定义help_window,window_selectable才有。
作者:
zxc3824
时间:
2011-1-7 12:28
回复
enghao_lim
的帖子
那我将selectable里面的help_window复制到window_base可不可以?
现在我没时间继续研究,所以就问各位高手和大侠
作者:
银·乌尔
时间:
2011-1-8 18:56
不用,你把Window_Item < Window_Base
这句的Window_Base换成Window_Selectable就好了...
作者:
zxc3824
时间:
2011-1-9 20:29
回复
银·乌尔
的帖子
还是有错啊,定义.............
zxc3824于2011-1-15 12:43补充以下内容:
工程已上,欢迎指教
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1