Ruby on RGSS
影表示
キャラクターの影を表示します。
影の方向は後ろに固定ですが、長さは調整可能です。
すべてのイベントに適用されるわけではなく、あくまでキャラクター
(四方向のグラフィックが用意されているもの)のみ適用となります。立て札などはなりません。
また、簡易的なもののためキャラクターの設置のしかたによっては不自然になります。
ご了承ください。
# 影表示 Ver 1.0 by 半導体 # http://h2so5.web.fc2.com/ # 概要:キャラクターの影を表示します。 # タイルセットからグラフィックを選んでいるイベントには # 適用されません。 # また、かなり簡易的ですので不自然に見えることがあります。 class Sprite_Character < RPG::Sprite #設定 SHADE_COLOR = 80 #影の濃さ(0〜255) SHADE_LENGTH = 2.0 #影の長さ(倍数) end class Sprite_Character < RPG::Sprite #影をつける def shade(bitmap,x,y,z,rect,vp) if @sahde == nil @sahde = Sprite.new(vp) @sahde.bitmap = Bitmap.new(rect.width,rect.height) end @sahde.bitmap.clear @sahde.bitmap.blt(0, 0, bitmap,rect) @sahde.tone = Tone.new(-255, -255, -255) @sahde.ox = rect.width / 2 @sahde.oy = rect.height @sahde.zoom_y = SHADE_LENGTH @sahde.opacity = SHADE_COLOR @sahde.x = x @sahde.y = y @sahde.z = z - 1 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # タイル ID、ファイル名、色相のどれかが現在のものと異なる場合 if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue # タイル ID とファイル名、色相を記憶 @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue # タイル ID が有効な値の場合 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 # タイル ID が無効な値の場合 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 end end #画像を更新するかしないかに関わらずキャラクターか判定 unless @tile_id >= 384 chara = true else chara = false end # 可視状態を設定 self.visible = (not @character.transparent) # グラフィックがキャラクターの場合 if @tile_id == 0 # 転送元の矩形を設定 sx = @character.pattern * @cw sy = (@character.direction - 2) / 2 * @ch self.src_rect.set(sx, sy, @cw, @ch) end # スプライトの座標を設定 self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z(@ch) # 不透明度、合成方法、茂み深さを設定 self.opacity = @character.opacity self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth #影をつける if chara shade(self.bitmap,@character.screen_x,@character.screen_y,@character.screen_z(@ch),Rect.new(sx, sy, @cw, @ch),self.viewport) end # アニメーション if @character.animation_id != 0 animation = $data_animations[@character.animation_id] animation(animation, true) @character.animation_id = 0 end end end
Back