Project1
标题:
死亡特效
[打印本页]
作者:
神思
时间:
2008-2-4 07:34
标题:
死亡特效
强人勿看!!!
第一次试着写VX的脚本..就把以前做过的一个东西做到VX上来...
话说RGSS2写的好规范的说..
就是敌人死亡后的一些莫名其妙的效果..
缩小and旋转.碎片.之类的..
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
# 战斗显示用活动块。Game_Battler 类的实例监视、
# 活动块的状态的监视。
#==============================================================================
module DeadEffect
Normal = 0
Flying = 1
Half = 2
Debris = 3
Debris_Size = 30
Rotating = 4
Wave = 5
end
class Sprite_Battler < Sprite_Base
include DeadEffect
#--------------------------------------------------------------------------
# ● 定量
#--------------------------------------------------------------------------
WHITEN = 1 # 白色闪光 (行动开始)
BLINK = 2 # 闪烁 (伤害)
APPEAR = 3 # 出现 (出现、复活)
DISAPPEAR = 4 # 消失 (逃走)
COLLAPSE = 5 # 崩坏 (战斗不能)
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 视口
# battler : 战斗者 (Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@effect_type = 0 # 效果种类
@effect_duration = 0 # 效果剩余时间
@dead_sprites = [] # 精灵
@dead_type = 0
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if @battler == nil
self.bitmap = nil
else
@use_sprite = @battler.use_sprite?
if @use_sprite
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
update_battler_bitmap
end
setup_new_effect
update_effect
end
end
#--------------------------------------------------------------------------
# ● 刷新传送的位图数据
#--------------------------------------------------------------------------
def update_battler_bitmap
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
end
#--------------------------------------------------------------------------
# ● 设置新效果
#--------------------------------------------------------------------------
def setup_new_effect
if @battler.white_flash
@effect_type = WHITEN
@effect_duration = 16
@battler.white_flash = false
end
if @battler.blink
@effect_type = BLINK
@effect_duration = 20
@battler.blink = false
end
if not @battler_visible and @battler.exist?
@effect_type = APPEAR
@effect_duration = 16
@battler_visible = true
end
if @battler_visible and @battler.hidden
@effect_type = DISAPPEAR
@effect_duration = 32
@battler_visible = false
end
if @battler.collapse
@effect_type = COLLAPSE
@effect_duration = 48
@battler.collapse = false
@battler_visible = false
@dead_type = rand(6)
dead_effect
end
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
mirror = @battler.animation_mirror
start_animation(animation, mirror)
@battler.animation_id = 0
end
end
#--------------------------------------------------------------------------
# ● 刷新效果
#--------------------------------------------------------------------------
def update_effect
if @effect_duration > 0
@effect_duration -= 1
case @effect_type
when WHITEN
update_whiten
when BLINK
update_blink
when APPEAR
update_appear
when DISAPPEAR
update_disappear
when COLLAPSE
update_collapse
end
end
end
#--------------------------------------------------------------------------
# ● 刷新白色闪光效果
#--------------------------------------------------------------------------
def update_whiten
self.blend_type = 0
self.color.set(255, 255, 255, 128)
self.opacity = 255
self.color.alpha = 128 - (16 - @effect_duration) * 10
end
#--------------------------------------------------------------------------
# ● 刷新闪烁效果
#--------------------------------------------------------------------------
def update_blink
self.blend_type = 0
self.color.set(0, 0, 0, 0)
self.opacity = 255
self.visible = (@effect_duration % 10 < 5)
end
#--------------------------------------------------------------------------
# ● 刷新出现效果
#--------------------------------------------------------------------------
def update_appear
self.blend_type = 0
self.color.set(0, 0, 0, 0)
self.opacity = (16 - @effect_duration) * 16
end
#--------------------------------------------------------------------------
# ● 刷新消失效果
#--------------------------------------------------------------------------
def update_disappear
self.blend_type = 0
self.color.set(0, 0, 0, 0)
self.opacity = 256 - (32 - @effect_duration) * 10
end
#--------------------------------------------------------------------------
# ● 刷新崩坏效果
#--------------------------------------------------------------------------
def update_collapse
case @dead_type
when Normal
self.opacity = 256 - (48 - @effect_duration) * 6
when Flying
@dead_sprites.each{|sprite|sprite.y -= 10;sprite.opacity = 256 - (48 - @effect_duration) * 6}
self.opacity = 256 - (32 - @effect_duration) * 10
when Half
@dead_sprites[0].x -= 5
@dead_sprites[1].x += 5
@dead_sprites.each{|sprite|sprite.opacity = 256 - (48 - @effect_duration) * 6}
when Debris
@dead_sprites.each{|sprite|sprite.y -= 5;sprite.x += (rand(5)-2);sprite.opacity = 256 - (48 - @effect_duration) * 6}
when Rotating
@dead_sprites.each{|sprite|sprite.angle += 360/48;sprite.zoom_x -= 0.025;sprite.zoom_y -= 0.025}
when Wave
@dead_sprites.each{|sprite|sprite.update;sprite.opacity = 256 - (48 - @effect_duration) * 6}
end
if @effect_duration == 0
@dead_sprites.each{|sprite|sprite.dispose}
@dead_sprites.clear
end
end
#--------------------------------------------------------------------------
# ● 死亡效果
#--------------------------------------------------------------------------
def dead_effect
case @dead_type
when Normal
self.blend_type = 1
self.color.set(255, 128, 128, 128)
when Flying
sprite = Sprite.new(self.viewport)
sprite.bitmap = self.bitmap
sprite.x = self.x
sprite.y = self.y
sprite.z = self.z + 1
sprite.ox = self.ox
sprite.oy = self.oy
@dead_sprites << sprite
self.blend_type = 0
self.color.set(0, 0, 0, 0)
when Half
sprite_up = Sprite.new(self.viewport)
sprite_up.bitmap = self.bitmap
sprite_up.ox = self.ox
sprite_up.oy = self.oy
sprite_up.x = self.x
sprite_up.y = self.y
sprite_up.src_rect.height /= 2
sprite_down = Sprite.new(self.viewport)
sprite_down.bitmap = self.bitmap
sprite_down.ox = self.ox
sprite_down.oy = self.oy
sprite_down.x = self.x
sprite_down.y = self.y + (self.height / 2)
sprite_down.src_rect.height /= 2
sprite_down.src_rect.y += sprite_down.src_rect.height
@dead_sprites << sprite_up << sprite_down
self.opacity = 0
when Debris
for x in 0...Debris_Size
for y in 0...Debris_Size
sprite = Sprite.new(self.viewport)
sprite.bitmap = self.bitmap
sprite.ox = self.ox
sprite.oy = self.oy
sprite.x = self.x + (x * (self.width / Debris_Size))
sprite.y = self.y + (y * (self.height / Debris_Size))
sprite.src_rect.set(
(x * (self.width / Debris_Size)),
(y * (self.height / Debris_Size)),
(self.width / Debris_Size),
(self.height / Debris_Size))
@dead_sprites << sprite
self.opacity = 0
end
end
when Rotating
sprite = Sprite.new(self.viewport)
sprite.bitmap = self.bitmap
sprite.ox = self.ox
sprite.oy = @height / 2
sprite.x = self.x
sprite.y = self.y - sprite.oy
@dead_sprites << sprite
self.opacity = 0
when Wave
sprite = Sprite.new(self.viewport)
sprite.bitmap = self.bitmap
sprite.ox = self.ox
sprite.oy = self.oy
sprite.x = self.x
sprite.y = self.y
sprite.wave_amp = 10
@dead_sprites << sprite
self.opacity = 0
end
end
end
复制代码
作者:
孤独de思念
时间:
2008-2-4 07:47
我是弱人 要看 试下!
作者:
孤独de思念
时间:
2008-2-4 07:51
好像效果不显著
作者:
司马睿风
时间:
2008-2-4 08:35
有范例或截图没?
作者:
菲恩
时间:
2008-2-4 09:21
提示:
作者被禁止或删除 内容自动屏蔽
作者:
宾少
时间:
2008-11-23 10:41
这个效果很好的说~但是发现角色要是死了的话,就会出错。。。
作者:
桑田百合
时间:
2009-7-7 10:05
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1