本帖最后由 taroxd 于 2014-11-1 20:13 编辑
文本编辑器对输入法支持不好,英文解释凑合看看吧
# Problem 1
# 我在类里定义的变量,在函数(方法)中使用的时候提示不存在。
see the comment
class Window_TitleCommand < Window_Command # the instance variable of Window_TitleCommand # it will last forever, unless the class Window_TitleCommand is destroyed @img_the_story = {} @img_the_story["oi"] = Cache.img_titlecommand("Option.png") @img_the_story = Cache.img_titlecommand("Option.png") # 函数体 def img_rect_test # the instance variable of an instance of Window_TitleCommand # it will exist as long as the instance exists @img_the_story["hl"] = (Cache.img_titlecommand("Option_hl.png")) contents.blt(x,y,@img_the_story["oi"],@img_the_story["oi"].rect) end # # ... # end
class Window_TitleCommand < Window_Command
# the instance variable of Window_TitleCommand
# it will last forever, unless the class Window_TitleCommand is destroyed
@img_the_story = {}
@img_the_story["oi"] = Cache.img_titlecommand("Option.png")
@img_the_story = Cache.img_titlecommand("Option.png")
# 函数体
def img_rect_test
# the instance variable of an instance of Window_TitleCommand
# it will exist as long as the instance exists
@img_the_story["hl"] = (Cache.img_titlecommand("Option_hl.png"))
contents.blt(x,y,@img_the_story["oi"],@img_the_story["oi"].rect)
end
#
# ...
#
end
# Problem 2
# Window_Command 类中 add_command 的用法,这个函数(方法)有四个参数,其中第四个参数 ext 提示的是可扩展数据,
# 那它可以是一个 Bitmap 对象,甚至是链表或者哈希表的一个元素吗?
ok.
#############################################################################################################
# Problem 3
# nil 的用法。nil 应该用在什么场合?值为 nil 变量能用 Bitmap 对象再赋值吗?
nil is just an object indicating 'nothing'. It can be used in a if statement, just like false.
Actually, you may be frequently using nil in an if condition, even without knowing it!
Just treat it as false.
The variable can always be assigned with a bitmap, or an object of any class.
#############################################################################################################
|