Project1
标题:
心情SE
[打印本页]
作者:
仲秋启明
时间:
2010-12-26 16:47
标题:
心情SE
一直都在翻译脚本,这次是真的“原创”了(整合了一下)。
这个脚本可以在显示心情图标时播放对应SE
设定方法在脚本中
#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
# 角色显示用脚本。监视 Game_Character 类的实例、自动变化脚本状态。
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ● 常量
#--------------------------------------------------------------------------
BALLOON_WAIT = 12 # 最後心情图标等待时间
Balloon_SE = Array.new # 心情图标SE
Balloon_SE[0] = ''
Balloon_SE[1] = 'Jump2' # !
Balloon_SE[2] = 'Miss' # ?
Balloon_SE[3] = 'Bell' # 音符
Balloon_SE[4] = 'Jump1' # 心
Balloon_SE[5] = 'Confuse' # 生气
Balloon_SE[6] = 'Load' # 汗
Balloon_SE[7] = 'Paralyze1' # 乱绪
Balloon_SE[8] = '' # ...
Balloon_SE[9] = 'Flash1' # 灯泡
Balloon_SE[10] = 'Horse' # Zzz
Balloon_SE_Volume = 80 # SE音量
Balloon_SE_Pitch = 100 # SE声调
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :character
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 显示端口
# character : 角色 (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
@balloon_duration = 0
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
dispose_balloon
super
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_bitmap
self.visible = (not @character.transparent)
update_src_rect
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
update_balloon
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
start_animation(animation)
@character.animation_id = 0
end
if @character.balloon_id != 0
@balloon_id = @character.balloon_id
start_balloon
@character.balloon_id = 0
end
end
#--------------------------------------------------------------------------
# ● 获取包含所选图块的元件图档
# tile_id : 元件ID
#--------------------------------------------------------------------------
def tileset_bitmap(tile_id)
set_number = tile_id / 256
return Cache.system("TileB") if set_number == 0
return Cache.system("TileC") if set_number == 1
return Cache.system("TileD") if set_number == 2
return Cache.system("TileE") if set_number == 3
return nil
end
#--------------------------------------------------------------------------
# ● 更新传送源的位图
#--------------------------------------------------------------------------
def update_bitmap
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_index != @character.character_index
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_index = @character.character_index
if @tile_id > 0
sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
sy = @tile_id % 256 / 8 % 16 * 32;
self.bitmap = tileset_bitmap(@tile_id)
self.src_rect.set(sx, sy, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = Cache.character(@character_name)
sign = @character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
@cw = bitmap.width / 3
@ch = bitmap.height / 4
else
@cw = bitmap.width / 12
@ch = bitmap.height / 8
end
self.ox = @cw / 2
self.oy = @ch
end
end
end
#--------------------------------------------------------------------------
# ● 更新传送源的矩形
#--------------------------------------------------------------------------
def update_src_rect
if @tile_id == 0
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
#--------------------------------------------------------------------------
# ● 开始显示心情图标
#--------------------------------------------------------------------------
def start_balloon
dispose_balloon
@balloon_duration = 8 * 8 + BALLOON_WAIT
@balloon_sprite = ::Sprite.new(viewport)
@balloon_sprite.bitmap = Cache.system("Balloon")
@balloon_sprite.ox = 16
@balloon_sprite.oy = 32
@ball_se = Balloon_SE[0]
if @ball_se == ''
@ball_se = Balloon_SE[@character.balloon_id]
end
RPG::SE.new(@ball_se,Balloon_SE_Volume,Balloon_SE_Pitch).play
update_balloon
end
#--------------------------------------------------------------------------
# ● 更新心情图标
#--------------------------------------------------------------------------
def update_balloon
if @balloon_duration > 0
@balloon_duration -= 1
if @balloon_duration == 0
dispose_balloon
else
@balloon_sprite.x = x
@balloon_sprite.y = y - height
@balloon_sprite.z = z + 200
if @balloon_duration < BALLOON_WAIT
sx = 7 * 32
else
sx = (7 - (@balloon_duration - BALLOON_WAIT) / 8) * 32
end
sy = (@balloon_id - 1) * 32
@balloon_sprite.src_rect.set(sx, sy, 32, 32)
end
end
end
#--------------------------------------------------------------------------
# ● 释放心情图标
#--------------------------------------------------------------------------
def dispose_balloon
if @balloon_sprite != nil
@balloon_sprite.dispose
@balloon_sprite = nil
end
end
end
复制代码
作者:
连贴大侠
时间:
2010-12-26 17:11
本帖最后由 连贴大侠 于 2010-12-26 17:11 编辑
这是RMXP还是RMVX?
好像很有爱。
我想说些什么……
复制代码
作者:
企鹅达达
时间:
2010-12-26 19:11
貌似原来的脚本比较简洁呢……
作者:
zeroko
时间:
2010-12-26 20:16
嗯
很早就想要这效果,谢谢~
作者:
漫漫人生路
时间:
2011-1-6 22:41
刚刚试验完毕,很不错啊。至少不需要手动设置心情的SE了。
作者:
越前リョーマ
时间:
2011-1-15 00:11
带音效啊……那不错,方便多了。话说之前我都没给加音效囧
作者:
忧雪の伤
时间:
2011-8-8 19:05
嘛,没修改到的地方可以不用复制下来- -b。
作者:
西西瓜瓜
时间:
2013-2-17 14:32
非常适合我这个懒人用
作者:
289307768
时间:
2013-3-4 17:03
万分感谢,这样就不用再去选择音效了。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1