#============================================================================== # ■ XP-RGSS-19 動くアクター(基本セット) [Ver.3.3.0] by Claimh #------------------------------------------------------------------------------ # ウィンドウ上でアクターを動かすための基本セットです。 #============================================================================== module Move_Actor CORPSE_FILE = [] #============================================================================== # カスタマイズSTART #============================================================================== # 歩くスピード WALK_SPEED = 10 # 回るスピード TURN_SPEED = 10 # ステートアニメーションの表示をする STATE_ANIME = false # 動作停止時に向きを強制的に下向きにする DIREC_DOWN = true # 戦闘不能時には別画像を表示する CORPSE = true # アクターごとの戦闘不能時の画像ファイル(Graphic/Characters) # 規格としては4×4のファイルを使用する。 # CORPSE_FILE = { # アクターID => ["ファイル名", 左から何番目?, 上から何番目?] # } CORPSE_FILE = { 1 => ["189-Down01", 0, 0], 2 => ["189-Down01", 1, 2], 7 => ["190-Down02", 0, 3], 8 => ["191-Down03", 1, 1] } #============================================================================== # カスタマイズEND #============================================================================== end class Sprite_MoveActor < RPG::Sprite WALK_I = {2=>0, 4=>1, 6=>2, 8=>3} TURN_I = [0, 1, 3, 2] #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :move_actor # アクター attr_accessor :move_type # 動作タイプ attr_accessor :move_stop # 動作停止フラグ attr_accessor :direction # 歩行向き #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport, actor = nil) super(viewport) @move_actor = actor @move_type = 0 @move_stop = false @move_index = 0 @dead_already = false @stop_already = false @state_animation_id = nil @direction = 2 end #-------------------------------------------------------------------------- # ● 初期表示 #-------------------------------------------------------------------------- def setup @move_index = 0 # 戦闘不能 if @move_actor.dead? and Move_Actor::CORPSE @dead_already = true draw_actor_corpse # 停止 elsif @move_stop and Move_Actor::DIREC_DOWN @stop_already = true draw_actor_down_direc # 通常 else draw_move_actor end end #-------------------------------------------------------------------------- # ● アニメーション実行 #-------------------------------------------------------------------------- def exe_animation(animation_id) animation($data_animations[animation_id], true) end #-------------------------------------------------------------------------- # ● 明暗実行 #-------------------------------------------------------------------------- def exe_blink(flag) flag ? blink_on : blink_off end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # アクターが nil の場合 if @move_actor == nil self.bitmap = nil loop_animation(nil) return end # アニメーション ID が現在のものと異なる場合 if @move_actor.state_animation_id != @state_animation_id and Move_Actor::STATE_ANIME @state_animation_id = @move_actor.state_animation_id loop_animation($data_animations[@state_animation_id]) end # 戦闘不能なら別画面表示 if @move_actor.dead? and Move_Actor::CORPSE # 二重描画はしない unless @dead_already @move_index = 0 draw_actor_corpse @dead_already = true end return end # 動作停止状態か? if self.move_stop # 二重描画はしない unless @stop_already @move_index = 0 @stop_already = true # 停止時は強制下向き表示 draw_actor_down_direc if Move_Actor::DIREC_DOWN end return else @stop_already = false end # 動作タイプごとの定数 move_refect = @move_type==0 ? Move_Actor::WALK_SPEED : Move_Actor::TURN_SPEED # 動作カウント(フレームカウント) @move_index += 1 # アクターの描画 if (@move_index % move_refect) == 0 @move_index = 0 if @move_index == move_refect * 4 draw_move_actor end end #-------------------------------------------------------------------------- # ● アクター表示 #-------------------------------------------------------------------------- def draw_move_actor # ビットマップを取得、設定 self.bitmap = RPG::Cache.character(@move_actor.character_name, @move_actor.character_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 # 動作変更 case @move_type when 0 # 歩く x_index = @move_index / Move_Actor::WALK_SPEED * @width y_index = @height * WALK_I[@direction] when 1 # 回る x_index = 0 cc = @move_index / Move_Actor::TURN_SPEED % 4 y_index = @height * TURN_I[cc] end self.src_rect.set(x_index, y_index, @width, @height) self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● アクター表示(下向き) #-------------------------------------------------------------------------- def draw_actor_down_direc # ビットマップを取得、設定 self.bitmap = RPG::Cache.character(@move_actor.character_name, @move_actor.character_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 # 動作変更 x_index = @move_index / Move_Actor::WALK_SPEED * @width y_index = 0 self.src_rect.set(x_index, y_index, @width, @height) self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● 戦闘不能表示 #-------------------------------------------------------------------------- def draw_actor_corpse # ビットマップを取得、設定 self.bitmap = RPG::Cache.character(Move_Actor::CORPSE_FILE[@move_actor.id][0], @move_actor.character_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 x_index = @width * (Move_Actor::CORPSE_FILE[@move_actor.id][1]) y_index = @height * (Move_Actor::CORPSE_FILE[@move_actor.id][2]) # 転送元の矩形を設定 self.src_rect.set(x_index, y_index, @width, @height) self.ox = @width / 2 self.oy = @height end end