加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 吾不知 于 2012-8-22 12:59 编辑
这是一个取巧的图片菜单的制作方法,即先使窗口透明,再添加一层背景调低 z 值做背景,再清空界面选项位置,添加一层背景调高 z 值覆盖选项位置!
class Scene_Menu < Scene_MenuBase alias start_YUN start def start start_YUN @command_window.opacity = 0 #选项窗口透明处理 @gold_window.opacity = 0 #金钱窗口透明处理 @status_window.opacity = 0 #状态窗口透明处理 end def create_command_window @command_window = Window_MenuCommand.new @command_window.set_handler(:item, method(:command_item)) @command_window.set_handler(:skill, method(:command_personal)) @command_window.set_handler(:equip, method(:command_personal)) @command_window.set_handler(:status, method(:command_personal)) @command_window.set_handler(:formation, method(:command_formation)) @command_window.set_handler(:save, method(:command_save)) @command_window.set_handler(:game_end, method(:command_game_end)) @command_window.set_handler(:cancel, method(:return_scene)) ############### @command_window.contents.clear_rect(Rect.new(0,0,160,200)) #清空选项位置文字 ########################################## end def create_background #创建背景 @background_sprite = Sprite.new @background_sprite.bitmap = Cache.system("menu") #创建覆盖选项的图片 @background_sprite.z = 200 @background1_sprite = Sprite.new @background1_sprite.bitmap = Cache.system("menu1") #创建背景图片 @background1_sprite.z = -10 end def dispose_background #清除 @background_sprite.dispose @background1_sprite.dispose end end
class Scene_Menu < Scene_MenuBase
alias start_YUN start
def start
start_YUN
@command_window.opacity = 0 #选项窗口透明处理
@gold_window.opacity = 0 #金钱窗口透明处理
@status_window.opacity = 0 #状态窗口透明处理
end
def create_command_window
@command_window = Window_MenuCommand.new
@command_window.set_handler(:item, method(:command_item))
@command_window.set_handler(:skill, method(:command_personal))
@command_window.set_handler(:equip, method(:command_personal))
@command_window.set_handler(:status, method(:command_personal))
@command_window.set_handler(:formation, method(:command_formation))
@command_window.set_handler(:save, method(:command_save))
@command_window.set_handler(:game_end, method(:command_game_end))
@command_window.set_handler(:cancel, method(:return_scene))
###############
@command_window.contents.clear_rect(Rect.new(0,0,160,200)) #清空选项位置文字
##########################################
end
def create_background #创建背景
@background_sprite = Sprite.new
@background_sprite.bitmap = Cache.system("menu") #创建覆盖选项的图片
@background_sprite.z = 200
@background1_sprite = Sprite.new
@background1_sprite.bitmap = Cache.system("menu1") #创建背景图片
@background1_sprite.z = -10
end
def dispose_background #清除
@background_sprite.dispose
@background1_sprite.dispose
end
end
使用方法:在“System”文件夹中创建两张图片“menu”,“menu1”分别作为背景图片和选项图片,将脚本插入在“main”上面。
这是一个通用的图片菜单方法,其他窗口的方法也与这类似,如 “物品窗口”
############################################# class Scene_Item < Scene_ItemBase alias start_YUN start def start start_YUN @category_window.opacity = 0 #分类窗口透明 @item_window.opacity = 0 #物品窗口透明 @help_window.opacity = 0 #帮助窗口透明 end def create_category_window @category_window = Window_ItemCategory.new @category_window.viewport = @viewport @category_window.help_window = @help_window @category_window.y = @help_window.height @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:return_scene)) ## @category_window.contents.clear_rect(Rect.new(0,0,544,200)) #清空删除位置区域 ## end def create_background @background_sprite = Sprite.new @background_sprite.bitmap = Cache.system("menuitems") #创建覆盖选项的图片 @background_sprite.z = 200 @background1_sprite = Sprite.new @background1_sprite.bitmap = Cache.system("menuitems1") #创建背景图片 @background1_sprite.z = -10 end def dispose_background #清除 @background_sprite.dispose @background1_sprite.dispose end end
#############################################
class Scene_Item < Scene_ItemBase
alias start_YUN start
def start
start_YUN
@category_window.opacity = 0 #分类窗口透明
@item_window.opacity = 0 #物品窗口透明
@help_window.opacity = 0 #帮助窗口透明
end
def create_category_window
@category_window = Window_ItemCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @help_window.height
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
##
@category_window.contents.clear_rect(Rect.new(0,0,544,200)) #清空删除位置区域
##
end
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = Cache.system("menuitems") #创建覆盖选项的图片
@background_sprite.z = 200
@background1_sprite = Sprite.new
@background1_sprite.bitmap = Cache.system("menuitems1") #创建背景图片
@background1_sprite.z = -10
end
def dispose_background #清除
@background_sprite.dispose
@background1_sprite.dispose
end
end
|