赞 | 1 |
VIP | 10 |
好人卡 | 2 |
积分 | 1 |
经验 | 132388 |
最后登录 | 2016-5-9 |
在线时间 | 34 小时 |
Lv1.梦旅人 冰王子
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 34 小时
- 注册时间
- 2008-1-27
- 帖子
- 1875
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
- #============角色选择=========By凌冰==========================================
- #用法 $scene = Scene_SelectActor.new
- #=============================================================================
- #参与选择的角色ID
- ACT_SEL = [1,2,3,4]
- #====================================
- #存储选择结果的变量ID
- VA_ID = 1
- #====================================
- #窗口设置
- WIDTH = 600#窗口宽度
- HEIGHT = 320#窗口高度
- OPACITY = 180#窗口透明度
- BACK_OPACITY = 180#窗口透明度
- #====================================
- #选择显示图形
- CHAORBAT = 1
- #0为显示人物战斗图,1为显示人物行走图
- #2为显示Pictures文件夹下的自定义图片(图片名为角色名)
- #其他为不显示图片
- #====================================
- #人物说明= =暂时仅限一行
- DES_SWI = true#说明开关
- ACT_DES = []#初始化,请不要修改
- #以下填写格式为ACT_DES[角色ID] = "说明文字"
- ACT_DES[1] = "小色狼"
- ACT_DES[2] = "小流氓"
- ACT_DES[3] = "小荡妇"
- ACT_DES[4] = "小贱人"
- #====================================
- #背景图片
- BGP_SWI = false#背景开关= =打开后PDE_SWI被屏蔽
- BGP_PIC = "Logo"#背景图片文件名Pictures文件夹下
- BGP_OPA = 180#开关打开后,窗口透明度
- BGP_BOP = 0#开关打开后,窗口(不包括边框)透明度
- #====================================
- #说明图片
- #移动光标矩形时自动切换图片
- PDE_SWI = true#图片开关= =BGP_SWI打开后被屏蔽
- PIC_DES = []#初始化,请不要修改
- #以下填写格式为PIC_DES[角色ID] = "图片文件名"
- PIC_DES[1] = "Logo1"
- PIC_DES[2] = "Logo2"
- PIC_DES[3] = "Logo1"
- PIC_DES[4] = "Logo2"
- PDE_OPA = 180#开关打开后,窗口透明度
- PDE_BOP = 0#开关打开后,窗口(不包括边框)透明度
- #====================================
- class Window_SelectActor < Window_Selectable
- def initialize
- super(0, 0, WIDTH, HEIGHT)
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = ACT_SEL.size
- @column_max = ACT_SEL.size
- @index = 0
- self.x = (640-self.width)/2
- self.y = (480-self.height)/2
- refresh
- end
- def refresh
- self.contents.clear
- for i in 0...ACT_SEL.size
- x = (self.width-32)/ACT_SEL.size * i
- actor = $game_actors[ACT_SEL[i]]
- x_plus = contents.text_size(actor.name).width
- x_plus = ((self.width-32)/ACT_SEL.size - x_plus)/2
- draw_actor_name(actor, x+4+x_plus, 4)
- case CHAORBAT
- when 0
- bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- x_plus = bitmap.width
- x_plus = ((self.width-32)/ACT_SEL.size - x_plus)/2
- self.contents.blt(x+x_plus, 36, bitmap, src_rect)
- when 1
- bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
- y_plus = bitmap.height/4
- x_plus = bitmap.width/4
- x_plus2 = ((self.width-32)/ACT_SEL.size - x_plus)/2
- draw_actor_graphic(actor, x+x_plus/2+x_plus2, y_plus+36)
- when 2
- bitmap = RPG::Cache.picture(actor.name)
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- x_plus = bitmap.width
- x_plus = ((self.width-32)/ACT_SEL.size - x_plus)/2
- self.contents.blt(x+x_plus, 36, bitmap, src_rect)
- end
- end
- end
- def update_cursor_rect
- if @index < 0
- self.cursor_rect.empty
- else
- self.cursor_rect.set( @index * (self.width-32)/ACT_SEL.size,0, (self.width-32)/ACT_SEL.size, self.height-32)
- end
- end
- end
- class Window_Help_New < Window_Help
- def initialize
- super
- self.contents = Bitmap.new(width, height)
- self.width = WIDTH
- self.contents = Bitmap.new(width - 32, height - 32)
- end
- end
- class Scene_SelectActor
- def main
- @window = Window_SelectActor.new
- @help_window = Window_Help_New.new
- @help_window.visible = DES_SWI
- @help_window.x = @window.x
- @help_window.y = @window.y + @window.height
- @help_window.width = @window.width
- @help_window.back_opacity = @window.back_opacity = PDE_SWI ? PDE_BOP : BACK_OPACITY
- @help_window.opacity = @window.opacity = PDE_SWI ? PDE_OPA : OPACITY
- @help_window.back_opacity = @window.back_opacity = BGP_BOP if BGP_SWI
- @help_window.opacity = @window.opacity = BGP_OPA if BGP_SWI
- if BGP_SWI
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.picture(BGP_PIC)
- elsif PDE_SWI
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.picture(PIC_DES[1])
- else
- @sprite = Spriteset_Map.new
- end
- # 执行过度4
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换就中断循环
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- @window.dispose
- @help_window.dispose
- @sprite.dispose
- end
- def update
- @window.update
- @sprite.update
- if DES_SWI
- @help_window_update
- actor_id = ACT_SEL[@window.index]
- text = ACT_DES[actor_id]
- @help_window.set_text(text,1) if text != nil
- end
- if !BGP_SWI and PDE_SWI
- pic = PIC_DES[ACT_SEL[@window.index]]
- @sprite.bitmap = RPG::Cache.picture(pic) if pic != nil
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- for i in 0...$game_party.actors.size
- id = $game_party.actors[i].id
- actors_id = [] if actors_id == nil
- actors_id.push(id)
- end
- actors_id.each do |i|
- $game_party.remove_actor(i)
- end
- id = ACT_SEL[@window.index]
- $game_party.add_actor(id)
- $game_variables[VA_ID] = id
- $scene = Scene_Map.new
- end
- end
- end
复制代码
脚本用法:
#============角色选择=========By凌冰==========================================
#用法 $scene = Scene_SelectActor.new
#=============================================================================
效果截图:
范例工程:
http://rpg.blue/upload_program/files/角色选择_97776380.rar
应求角色双排显示版
- #============角色选择=========By凌冰==========================================
- #用法 $scene = Scene_SelectActor.new
- #=============================================================================
- #参与选择的角色ID
- ACT_SEL = [1,2,3,4,5,6,7]
- #====================================
- #存储选择结果的变量ID
- VA_ID = 1
- #====================================
- #窗口设置
- WIDTH = 600#窗口宽度
- HEIGHT = 320#窗口高度
- OPACITY = 180#窗口透明度
- BACK_OPACITY = 180#窗口透明度
- #====================================
- #选择显示图形
- CHAORBAT = 1
- #0为显示人物战斗图,1为显示人物行走图
- #2为显示Pictures文件夹下的自定义图片(图片名为角色名)
- #其他为不显示图片
- #====================================
- #人物说明= =暂时仅限一行
- DES_SWI = true#说明开关
- ACT_DES = []#初始化,请不要修改
- #以下填写格式为ACT_DES[角色ID] = "说明文字"
- ACT_DES[1] = "小色狼"
- ACT_DES[2] = "小流氓"
- ACT_DES[3] = "小荡妇"
- ACT_DES[4] = "小贱人"
- #====================================
- #背景图片
- BGP_SWI = false#背景开关= =打开后PDE_SWI被屏蔽
- BGP_PIC = "Logo"#背景图片文件名Pictures文件夹下
- BGP_OPA = 180#开关打开后,窗口透明度
- BGP_BOP = 0#开关打开后,窗口(不包括边框)透明度
- #====================================
- #说明图片
- #移动光标矩形时自动切换图片
- PDE_SWI = true#图片开关= =BGP_SWI打开后被屏蔽
- PIC_DES = []#初始化,请不要修改
- #以下填写格式为PIC_DES[角色ID] = "图片文件名"
- PIC_DES[1] = "Logo1"
- PIC_DES[2] = "Logo2"
- PIC_DES[3] = "Logo1"
- PIC_DES[4] = "Logo2"
- PDE_OPA = 180#开关打开后,窗口透明度
- PDE_BOP = 0#开关打开后,窗口(不包括边框)透明度
- #====================================
- #双排显示
- TWR_SWI = true#双排开关
- class Window_SelectActor < Window_Selectable
- def initialize
- super(0, 0, WIDTH, HEIGHT)
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = ACT_SEL.size
- @column_max = ACT_SEL.size
- @column_max = (ACT_SEL.size+1)/2 if TWR_SWI
- @index = 0
- self.x = (640-self.width)/2
- self.y = (480-self.height)/2
- refresh
- end
- def refresh
- self.contents.clear
- for i in 0...ACT_SEL.size
- unless TWR_SWI
- x = (self.width-32)/ACT_SEL.size * i
- y = 4
- else
- case (ACT_SEL.size%2)
- when 0
- row_size = ACT_SEL.size/2
- else
- row_size = ACT_SEL.size/2 + 1
- end
- x = (i%@column_max) * (self.width-32)/row_size
- y = 4
- y = (self.height-32) / 2 if i > row_size - 1
- end
- actor = $game_actors[ACT_SEL[i]]
- x_plus = contents.text_size(actor.name).width
- x_plus = ((self.width-32)/row_size - x_plus)/2
- draw_actor_name(actor, x+4+x_plus, y)
- case CHAORBAT
- when 0
- bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- x_plus = bitmap.width
- x_plus = ((self.width-32)/row_size - x_plus)/2
- self.contents.blt(x+x_plus, y+36, bitmap, src_rect)
- when 1
- bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
- y_plus = bitmap.height/4
- x_plus = bitmap.width/4
- x_plus2 = ((self.width-32)/row_size - x_plus)/2
- draw_actor_graphic(actor, x+x_plus/2+x_plus2,y+ y_plus+36)
- when 2
- bitmap = RPG::Cache.picture(actor.name)
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- x_plus = bitmap.width
- x_plus = ((self.width-32)/row_size - x_plus)/2
- self.contents.blt(x+x_plus, y+36, bitmap, src_rect)
- end
- end
- end
- def update_cursor_rect
- unless TWR_SWI
- if @index < 0
- self.cursor_rect.empty
- else
- self.cursor_rect.set( @index * (self.width-32)/ACT_SEL.size,0, (self.width-32)/ACT_SEL.size, self.height-32)
- end
- else
- if @index < 0
- self.cursor_rect.empty
- else
- case (ACT_SEL.size%2)
- when 0
- row_size = ACT_SEL.size/2
- else
- row_size = ACT_SEL.size/2 + 1
- end
- x = (@index%@column_max) * (self.width-32)/row_size
- y = 0
- y = (self.height-32) / 2 if @index > row_size - 1
- self.cursor_rect.set( x,y, (self.width-32)/row_size, (self.height-32)/2)
- end
- end
- end
- end
- class Window_Help_New < Window_Help
- def initialize
- super
- self.contents = Bitmap.new(width, height)
- self.width = WIDTH
- self.contents = Bitmap.new(width - 32, height - 32)
- end
- end
- class Scene_SelectActor
- def main
- @window = Window_SelectActor.new
- @help_window = Window_Help_New.new
- @help_window.visible = DES_SWI
- @help_window.x = @window.x
- @help_window.y = @window.y + @window.height
- @help_window.width = @window.width
- @help_window.back_opacity = @window.back_opacity = PDE_SWI ? PDE_BOP : BACK_OPACITY
- @help_window.opacity = @window.opacity = PDE_SWI ? PDE_OPA : OPACITY
- @help_window.back_opacity = @window.back_opacity = BGP_BOP if BGP_SWI
- @help_window.opacity = @window.opacity = BGP_OPA if BGP_SWI
- if BGP_SWI
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.picture(BGP_PIC)
- elsif PDE_SWI
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.picture(PIC_DES[1])
- else
- @sprite = Spriteset_Map.new
- end
- # 执行过度4
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换就中断循环
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- @window.dispose
- @help_window.dispose
- @sprite.dispose
- end
- def update
- @window.update
- @sprite.update
- if DES_SWI
- @help_window_update
- actor_id = ACT_SEL[@window.index]
- text = ACT_DES[actor_id]
- @help_window.set_text(text,1) if text != nil
- end
- if !BGP_SWI and PDE_SWI
- pic = PIC_DES[ACT_SEL[@window.index]]
- @sprite.bitmap = RPG::Cache.picture(pic) if pic != nil
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- for i in 0...$game_party.actors.size
- id = $game_party.actors[i].id
- actors_id = [] if actors_id == nil
- actors_id.push(id)
- end
- actors_id.each do |i|
- $game_party.remove_actor(i)
- end
- id = ACT_SEL[@window.index]
- $game_party.add_actor(id)
- $game_variables[VA_ID] = id
- $scene = Scene_Map.new
- end
- end
- end
复制代码 |
|