#幻影by 66rpg 神思 不知为什么在原点(大慨要在scene_map下
#__END__
class Game_Player < Game_Character
def mirage(opacity)
$scene.spriteset.mirage(self, opacity)
end
alias update_naiyoudadangao update
def update
update_naiyoudadangao
if Input.dir8 != 0
mirage(120)
end
end
end
class Game_Event < Game_Character
def mirage(opacity)
$scene.spriteset.mirage(self, opacity)
end
end
class Sprite_MirageCharacter < RPG::Sprite
attr_accessor :character
def initialize(viewport, opacity, character = nil)
super(viewport)
@character = character
self.opacity = opacity
update
end
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
self.x = @character.screen_x
self.y = @character.screen_y
end
end
self.visible = (not @character.transparent)
if @tile_id == 0 and !@t
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
@t = true
end
self.z = @character.screen_z(@ch)
self.color.set(0,0,170,120)
self.opacity -= 8 #b残像减少(大就没有)小效果多
self.blend_type = 0
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
class Spriteset_Map
alias initialize_naiyoudadangao initialize
def initialize
@mirage = {}
initialize_naiyoudadangao
end
def mirage(obj, opacity)
@mirage[obj] ||= []
smc = Sprite_MirageCharacter.new(@viewport1, opacity, obj)
@mirage[obj] << Mirage.new(obj.real_x, obj.real_y, smc)#(Sprite_MirageCharacter.new(@viewport1, opacity, obj))
end
alias update_naiyoudadangao update
def update
update_naiyoudadangao
for value in @mirage.values
for v in value
v.smc.x = (v.x - $game_map.display_x + 3) / 4 + 16
v.smc.y = (v.y - $game_map.display_y + 3) / 4 + 32
v.smc.update
if v.smc.opacity <= 0
v.smc.dispose
value.delete(v)
end
end
end
end
end
class Scene_Map
attr_reader :spriteset
end
Mirage = Struct.new(:x, :y, :smc)