赞 | 1 |
VIP | 246 |
好人卡 | 87 |
积分 | 1 |
经验 | 34142 |
最后登录 | 2015-1-15 |
在线时间 | 323 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 323 小时
- 注册时间
- 2010-8-21
- 帖子
- 666
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 沙漠点灰 于 2011-4-3 10:14 编辑
这个是支持子选项窗口的一个范例工程
效果图:
确实很简陋...!
(使用前确定有支持子选项的窗口)
使用方法:地图上按下F8 或者调用$scene = Scene_Set.new
脚本如下:- #==============================================================================
- # 简易设置菜单
- # ISA
- # 主要是示范 如何用 Window_Folder
- # 把你的大名及信息写到这... \n 表示换行(用的是print 别骂我,我的确很懒...)
- Info = "简易设置菜单 + 子选择窗口 -by 沙漠.灰 \n 版本: v0.5 "
- # 是否允许修改帧速(true=是 false=否)
- RunSpeed = true
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 处理地图画面的类。
- #==============================================================================
- class Scene_Map
- alias isa_dust_update update
- def update
- isa_dust_update
- # 按 F8 调出设置菜单
- if Input.trigger?(Input::F8)
- # 不是在事件执行中或菜单禁止中
- unless $game_system.map_interpreter.running? or
- $game_system.menu_disabled
- $scene = Scene_Set.new
- end
- end
- end
- end
- #==============================================================================
- # ■ Scene_Set
- #------------------------------------------------------------------------------
- # 主要是示范 如何用 Window_Folder
- #==============================================================================
- class Scene_Set
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- @temp=[$game_system.bgm_v,$game_system.bgs_v,$game_system.me_v,$game_system.se_v]
- @temp_dup = @temp.dup
- @graphics_frame_rate = Graphics.frame_rate
- # 生成活动块
- @spriteset = Spriteset_Map.new
- commands = [["游戏设置","音量设置(按左右键)","游戏加速(退出游戏无效)","版本信息"],"直接退出","保存退出"]
- @folder_window = Window_Folder.new(50,96,370,32*7,commands)
- @folder_window.disable_item([0,2]) unless RunSpeed
- 17.times{@folder_window.not_really_move("left ")}
- # 生成窗口
- window 0
- # 执行过渡
- Graphics.transition
- 17.times{Graphics.update;@folder_window.not_really_move("right")}
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- 17.times{Graphics.update;@folder_window.not_really_move("left ")}
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @spriteset.dispose
- @set_window.dispose
- @folder_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 生成窗口
- #--------------------------------------------------------------------------
- def window(index)
- @set_window_index = index
- if index == 0
- @set_window.dispose if @set_window != nil
- @set_window = Window_Command.new(192, ["BGM","BGS","ME","SE",])
- @set_window.x = 420
- @set_window.y = 96+32
- @set_window.index = -1
- 4.times{|i|draw(i,@temp[i])}
- 17.times{@set_window.not_really_move("left ")}
- @set_window.visible = @set_window.active = false
- else
- @set_window.dispose if @set_window != nil
- @set_window = Window_Command.new(192, ["帧率"])
- @set_window.x = 420
- @set_window.y = 96+32*2
- @set_window.index = -1
- draw(0,Graphics.frame_rate)
- 17.times{@set_window.not_really_move("left ")}
- @set_window.visible = @set_window.active = false
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘 数字
- #--------------------------------------------------------------------------
- def draw(index,val)
- rect = Rect.new(4+32*2, 32 * index, @set_window.contents.width - 82, 32)
- @set_window.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- @set_window.contents.draw_text(rect, val.to_s,2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- @set_window.update
- @folder_window.update
- if @folder_window.active
- # C键被按下的情况下,并且@folder_window不是在移动
- if Input.trigger?(Input::C) and @folder_window.c
- if @folder_window.index == [0,2] && !RunSpeed
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- end
- case @folder_window.index[0]
- when 0 # 游戏设置
- case @folder_window.index[1]
- when 1 # 音量设置
- @folder_window.active = false
- @set_window.active = @set_window.visible = true
- 17.times{Graphics.update;@set_window.not_really_move("right")}
- @set_window.index = 0
- when 2 # 游戏加速
- window 1
- @folder_window.active = false
- @set_window.active = @set_window.visible = true
- 17.times{Graphics.update;@set_window.not_really_move("right")}
- @set_window.index = 0
- when 3 # 版本信息
- print Info
- return
- end
- when 2 # 保存&退出
- $scene = Scene_Map.new
- when 1 # 直接退出
- Graphics.frame_rate = @graphics_frame_rate
- $game_system.bgm_v,$game_system.bgs_v,$game_system.me_v,$game_system.se_v=@temp_dup
- $game_system.bgm_play($game_system.playing_bgm)
- $scene = Scene_Map.new
- end
- end
- elsif @set_window.active
- if Input.trigger?(Input::B) or Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- @folder_window.active = true
- @set_window.index = -1
- 17.times{Graphics.update;@set_window.not_really_move("left ")}
- @set_window.active = @set_window.visible = false
- window 0
- end
- if Input.repeat?(Input::LEFT)
- if @set_window_index == 0
- @temp[@set_window.index] = [@temp[@set_window.index]-1,0].max
- draw(@set_window.index,@temp[@set_window.index])
- $game_system.bgm_v,$game_system.bgs_v,$game_system.me_v,$game_system.se_v=@temp
- $game_system.se_play($data_system.cursor_se)
- $game_system.bgm_play($game_system.playing_bgm)
- else
- draw(0,Graphics.frame_rate -= 1)
- $game_system.se_play($data_system.cursor_se)
- end
- end
- if Input.repeat?(Input::RIGHT)
- if @set_window_index == 0
- @temp[@set_window.index] = [@temp[@set_window.index]+1,100].min
- draw(@set_window.index,@temp[@set_window.index])
- $game_system.bgm_v,$game_system.bgs_v,$game_system.me_v,$game_system.se_v=@temp
- $game_system.se_play($data_system.cursor_se)
- $game_system.bgm_play($game_system.playing_bgm)
- else
- draw(0,Graphics.frame_rate += 1)
- end
- end
- end # of @folder_window.active
- end # of def update
- end # of class
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # 游戏中全部窗口的超级类。
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- alias isa_dust_initialize initialize
- def initialize(*a)
- isa_dust_initialize(*a)
- @move_count = 0
- @move_to_x = 0
- @move_to_y = 0
- end
- #--------------------------------------------------------------------------
- # ● 伪 移动
- #--------------------------------------------------------------------------
- def not_really_move(d="right")
- d == "right" ? d = 1 : d = -1
- self.x += d * 5
- self.ox += d * 5
- self.width -= d * 5
- self.opacity += d * 15
- self.contents_opacity += d * 15
- end
- #--------------------------------------------------------------------------
- # ● 真 移动
- #--------------------------------------------------------------------------
- def move_to(x,y,count)
- @move_to_x = x
- @move_to_y = y
- @move_count= count
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias isa_dust_update update
- def update
- isa_dust_update
- # 移动完毕时,直接返回
- return if @move_count <= 0
- self.x += (@move_to_x - self.x)/@move_count.to_f
- self.y += (@move_to_y - self.y)/@move_count.to_f
- @move_count -= 1
- end
- end
- #==============================================================================
- # ■ Game_System
- #------------------------------------------------------------------------------
- # 处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
- # $game_system 。
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :bgm_v
- attr_accessor :bgs_v
- attr_accessor :me_v
- attr_accessor :se_v
- alias isa_dust_initialize initialize
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- isa_dust_initialize
- @bgm_v = 80
- @bgs_v = 80
- @me_v = 80
- @se_v = 80
- end
- #--------------------------------------------------------------------------
- # ● 演奏 BGM
- # bgm : 演奏的 BGM
- #--------------------------------------------------------------------------
- def bgm_play(bgm)
- @playing_bgm = bgm
- if bgm != nil and bgm.name != ""
- Audio.bgm_play("Audio/BGM/" + bgm.name, @bgm_v, bgm.pitch)
- else
- Audio.bgm_stop
- end
- Graphics.frame_reset
- end
- #--------------------------------------------------------------------------
- # ● 演奏 BGS
- # bgs : 演奏的 BGS
- #--------------------------------------------------------------------------
- def bgs_play(bgs)
- @playing_bgs = bgs
- if bgs != nil and bgs.name != ""
- Audio.bgs_play("Audio/BGS/" + bgs.name, @bgs_v, bgs.pitch)
- else
- Audio.bgs_stop
- end
- Graphics.frame_reset
- end
- #--------------------------------------------------------------------------
- # ● ME 的演奏
- # me : 演奏的 ME
- #--------------------------------------------------------------------------
- def me_play(me)
- if me != nil and me.name != ""
- Audio.me_play("Audio/ME/" + me.name, @me_v, me.pitch)
- else
- Audio.me_stop
- end
- Graphics.frame_reset
- end
- #--------------------------------------------------------------------------
- # ● SE 的演奏
- # se : 演奏的 SE
- #--------------------------------------------------------------------------
- def se_play(se)
- if se != nil and se.name != ""
- Audio.se_play("Audio/SE/" + se.name, @se_v, se.pitch)
- end
- end
- end
复制代码 附:范例工程
简易设置菜单.rar
(198.22 KB, 下载次数: 1208)
|
|