赞 | 2 |
VIP | 2 |
好人卡 | 4 |
积分 | 1 |
经验 | 96076 |
最后登录 | 2015-12-27 |
在线时间 | 93 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 93 小时
- 注册时间
- 2008-5-16
- 帖子
- 745
|
我说我的脚本就可以了?把我的这个脚本先放到main前
- #==============================================================================
- # ■ Window_Picture_Command
- #------------------------------------------------------------------------------
- =begin
- 该脚本是用图片做命令按钮,使用起来比较简单,脚本会自动判断位置。
- 使用方法:
- 与调用一般命令窗口一样!
- type描绘类型
- type = 1 只支持键盘
- type = 2 支持键盘+鼠标
- 如:先设定一个命令按钮图片以及坐标
- p1 = ["图片名",图片X坐标,图片Y坐标]
- 范例游戏里为
- #################################################
- s1 = ["新游戏",100,0]
- s2 = ["继续游戏",200,150]
- s3 = ["离开游戏",300,200]
- @command_window = Window_Picture_Command.new([s1,s2,s3],type)
- #################################################
- 这里的type的值就是刚才所支持的
- type = 1 只支持键盘
- type = 2 支持键盘+鼠标
- #################################################
- s1 = ["新游戏",100,0]
- s2 = ["继续游戏",200,150]
- s3 = ["离开游戏",300,200]
- @command_window = Window_Picture_Command.new([s1,s2,s3],2)
- #################################################
- 大概就这样了,不明白看范例游戏吧。
- =end
- #==============================================================================
- class Window_Picture_Command < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # width : 窗口的宽
- # commands : 命令字符串序列
- #--------------------------------------------------------------------------
- def initialize(commands,type=1)
- # 由命令的个数计算出窗口的高
- super(0, 0, 640, 480)
- @item_max = commands.size
- @commands = commands
- @dash = []
- @sprite = []
- @type = type
- @move_index = self.index
- self.opacity = 0
- self.contents = Bitmap.new(width - 32, @item_max * 32)
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_picture_item(i, @type)
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- for index in @dash
- if @sprite[index] != nil
- @sprite[index].dispose
- @sprite[index].bitmap.dispose
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘图片项目
- # index : 项目编号
- # type : 描绘类型
- # type = 1 只支持键盘
- # type = 2 双面支持
- #--------------------------------------------------------------------------
- def draw_picture_item(index, type)
- @sprite[index] = Sprite.new
- if @commands[index][0] == nil
- p "图片名设置有误"
- end
- if @commands[index][1] == nil
- p "图片X坐标设置有误"
- end
- if @commands[index][2] == nil
- p "图片Y坐标设置有误"
- end
- bitmap = RPG::Cache.picture(@commands[index][0])
- @sprite[index].bitmap = bitmap
- @sprite[index].x = @commands[index][1]
- @sprite[index].y = @commands[index][2]
- @sprite[index].index = index
- if @sprite[index].index != self.index
- @sprite[index].color = Color.new(0,0,0,100)
- else
- @sprite[index].color = Color.new(0,0,0,0)
- end
- @dash.push(index)
- end
- #--------------------------------------------------------------------------
- # ● 刷新图片项目
- #--------------------------------------------------------------------------
- def update_item
- if Mouse.get_mouse_pos != nil
- $mouse_x,$mouse_y = Mouse.get_mouse_pos
- end
- if @type == 2
- for index in @dash
- if @sprite[index] != nil
- top_x = @sprite[index].x
- top_y = @sprite[index].y
- bottom_x = top_x + @sprite[index].bitmap.width
- bottom_y = top_y + @sprite[index].bitmap.height
- if ($mouse_x > top_x) and ($mouse_y > top_y) and
- ($mouse_x < bottom_x) and ($mouse_y < bottom_y)
- self.index = @sprite[index].index
- if @move_index != self.index
- Se.ok
- @move_index = self.index
- end
- end
- if @sprite[index].index != self.index
- @sprite[index].color = Color.new(0,0,0,100)
- else
- @sprite[index].color = Color.new(0,0,0,0)
- end
- end
- end
- elsif @type == 1
- for index in @dash
- if @sprite[index].index != self.index
- @sprite[index].color = Color.new(0,0,0,100)
- else
- @sprite[index].color = Color.new(0,0,0,0)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 图片项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- @sprite[index].color = Color.new(0,0,0,100)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias window_picture_command_update update
- def update
- window_picture_command_update
- update_item
- end
- #--------------------------------------------------------------------------
- # ● 更新光标举行
- #--------------------------------------------------------------------------
- def update_cursor_rect
- if @index < 0
- self.cursor_rect.empty
- return
- end
- row = @index / @column_max
- if row < self.top_row
- self.top_row = row
- end
- if row > self.top_row + (self.page_row_max - 1)
- self.top_row = row - (self.page_row_max - 1)
- end
- cursor_width = self.width / @column_max - 32
- x = @index % @column_max * (cursor_width + 32)
- y = @index / @column_max * 32 - self.oy
- self.cursor_rect.set(x+5000, y, cursor_width, 32)
- end
- end
- #==============================================================================
- # ■ Se
- #------------------------------------------------------------------------------
- # ■ 音效模块
- #==============================================================================
- module Se
- def self.ok
- $game_system.se_play($data_system.cursor_se)
- end
- def self.no
- $game_system.se_play($data_system.cancel_se)
- end
- end
- #==============================================================================
- # ■ Sprite
- #------------------------------------------------------------------------------
- # ■ index 选择光标
- #==============================================================================
- class Sprite
- attr_accessor :index
- end
复制代码
然后我帮你写了个5选择的图片菜单图片自己放进去,效果自己设置了
- #==============================================================================
- # ■ Scene_Title
- #------------------------------------------------------------------------------
- # 处理标题画面的类。
- #==============================================================================
- class Scene_Title
- #--------------------------------------------------------------------------
- # ● 住处理
- #--------------------------------------------------------------------------
- def main
- # 战斗测试的情况下
- if $BTEST
- battle_test
- return
- end
- # 载入数据库
- $data_actors = load_data("Data/Actors.rxdata")
- $data_classes = load_data("Data/Classes.rxdata")
- $data_skills = load_data("Data/Skills.rxdata")
- $data_items = load_data("Data/Items.rxdata")
- $data_weapons = load_data("Data/Weapons.rxdata")
- $data_armors = load_data("Data/Armors.rxdata")
- $data_enemies = load_data("Data/Enemies.rxdata")
- $data_troops = load_data("Data/Troops.rxdata")
- $data_states = load_data("Data/States.rxdata")
- $data_animations = load_data("Data/Animations.rxdata")
- $data_tilesets = load_data("Data/Tilesets.rxdata")
- $data_common_events = load_data("Data/CommonEvents.rxdata")
- $data_system = load_data("Data/System.rxdata")
- # 生成系统对像
- $game_system = Game_System.new
- # 生成标题图形
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.title($data_system.title_name)
- # 生成命令窗口
- s1 = ["新的游戏",100,0]
- s2 = ["继续游戏",200,150]
- s3 = ["制作人员",300,200]
- s4 = ["关于游戏",400,250]
- s5 = ["离开游戏",500,300]
- @command_window = Window_Picture_Command.new([s1,s2,s3,s4,s5],1)
- @command_window.back_opacity = 160
- @command_window.x = 320 - @command_window.width / 2
- @command_window.y = 288
- # 判定继续的有效性
- # 存档文件一个也不存在的时候也调查
- # 有効为 @continue_enabled 为 true、無効为 false
- @continue_enabled = false
- for i in 0..3
- if FileTest.exist?("Save#{i+1}.rxdata")
- @continue_enabled = true
- end
- end
- # 继续为有效的情况下、光标停止在继续上
- # 无效的情况下、继续的文字显示为灰色
- if @continue_enabled
- @command_window.index = 1
- else
- @command_window.disable_item(1)
- end
- # 演奏标题 BGM
- $game_system.bgm_play($data_system.title_bgm)
- # 停止演奏 ME、BGS
- Audio.me_stop
- Audio.bgs_stop
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换就中断循环
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- # 释放命令窗口
- @command_window.dispose
- # 释放标题图形
- @sprite.bitmap.dispose
- @sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新命令窗口
- @command_window.update
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口的光标位置的分支
- case @command_window.index
- when 0 # 新游戏
- command_new_game
- when 1 # 继续
- command_continue
- when 2 # 退出
- command_shutdown
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 命令 : 新游戏
- #--------------------------------------------------------------------------
- def command_new_game
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 停止 BGM
- Audio.bgm_stop
- # 重置测量游戏时间用的画面计数器
- Graphics.frame_count = 0
- # 生成各种游戏对像
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # 设置初期同伴位置
- $game_party.setup_starting_members
- # 设置初期位置的地图
- $game_map.setup($data_system.start_map_id)
- # 主角向初期位置移动
- $game_player.moveto($data_system.start_x, $data_system.start_y)
- # 刷新主角
- $game_player.refresh
- # 执行地图设置的 BGM 与 BGS 的自动切换
- $game_map.autoplay
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换地图画面
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 命令 : 继续
- #--------------------------------------------------------------------------
- def command_continue
- # 继续无效的情况下
- unless @continue_enabled
- # 演奏无效 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到读档画面
- $scene = Scene_Load.new
- end
- #--------------------------------------------------------------------------
- # ● 命令 : 退出
- #--------------------------------------------------------------------------
- def command_shutdown
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # BGM、BGS、ME 的淡入淡出
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- # 退出
- $scene = nil
- end
- #--------------------------------------------------------------------------
- # ● 战斗测试
- #--------------------------------------------------------------------------
- def battle_test
- # 载入数据库 (战斗测试用)
- $data_actors = load_data("Data/BT_Actors.rxdata")
- $data_classes = load_data("Data/BT_Classes.rxdata")
- $data_skills = load_data("Data/BT_Skills.rxdata")
- $data_items = load_data("Data/BT_Items.rxdata")
- $data_weapons = load_data("Data/BT_Weapons.rxdata")
- $data_armors = load_data("Data/BT_Armors.rxdata")
- $data_enemies = load_data("Data/BT_Enemies.rxdata")
- $data_troops = load_data("Data/BT_Troops.rxdata")
- $data_states = load_data("Data/BT_States.rxdata")
- $data_animations = load_data("Data/BT_Animations.rxdata")
- $data_tilesets = load_data("Data/BT_Tilesets.rxdata")
- $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
- $data_system = load_data("Data/BT_System.rxdata")
- # 重置测量游戏时间用的画面计数器
- Graphics.frame_count = 0
- # 生成各种游戏对像
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # 设置战斗测试用同伴
- $game_party.setup_battle_test_members
- # 设置队伍 ID、可以逃走标志、战斗背景
- $game_temp.battle_troop_id = $data_system.test_troop_id
- $game_temp.battle_can_escape = true
- $game_map.battleback_name = $data_system.battleback_name
- # 演奏战斗开始 BGM
- $game_system.se_play($data_system.battle_start_se)
- # 演奏战斗 BGM
- $game_system.bgm_play($game_system.battle_bgm)
- # 切换到战斗画面
- $scene = Scene_Battle.new
- end
- end
复制代码 |
|