Project1

标题: 战斗图加特效 [打印本页]

作者: 白魔导师宝儿    时间: 2014-2-8 12:24
标题: 战斗图加特效
当战斗受到伤害时,让战斗图震动和加上红色闪烁。
闪烁不是动画内的。
请问怎么做
作者: 恐惧剑刃    时间: 2014-2-8 13:06
SE 与闪烁效果

编辑 到某帧红色闪烁即可
作者: 白魔导师宝儿    时间: 2014-2-8 13:12
恋′挂机 发表于 2014-2-8 13:06
SE 与闪烁效果

编辑 到某帧红色闪烁即可

我不想在动画中加闪烁效果
能在别的地方实现吗
另外受伤时怎么让战斗图震动或者抖动
作者: 恐惧剑刃    时间: 2014-2-8 13:26
本帖最后由 恋′挂机 于 2014-2-8 13:36 编辑

红色闪烁 + 抖动
闪烁是要在数据库中先定义那么个动画才行
其实就是多播发了个动画


module Battler_set
  def self.震动帧数
    return 5
  end
  def self.震动坐标偏移量
    return 1
  end
  def self.红色闪烁的动画
    return 100 # id 100
  end
end
class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 战斗者为 nil 的情况下
    if @battler == nil
      self.bitmap = nil
      loop_animation(nil)
      return
    end
    # 文件名和色相与当前情况有差异的情况下
    if @battler.battler_name != @battler_name or
       @battler.battler_hue != @battler_hue
      # 获取、设置位图
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
      # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
      if @battler.dead? or @battler.hidden
        self.opacity = 0
      end
    end
    # 动画 ID 与当前的情况有差异的情况下
    if @battler.damage == nil and
       @battler.state_animation_id != @state_animation_id
      @state_animation_id = @battler.state_animation_id
      loop_animation($data_animations[@state_animation_id])
    end
    # 应该被显示的角色的情况下
    if @battler.is_a?(Game_Actor) and @battler_visible
      # 不是主状态的时候稍稍降低点透明度
      if $game_temp.battle_main_phase
        self.opacity += 3 if self.opacity < 255
      else
        self.opacity -= 3 if self.opacity > 207
      end
    end
    # 明灭
    if @battler.blink
      blink_on
    else
      blink_off
    end
    # 不可见的情况下
    unless @battler_visible
      # 出现
      if not @battler.hidden and not @battler.dead? and
         (@battler.damage == nil or @battler.damage_pop)
        appear
        @battler_visible = true
      end
    end
    # 可见的情况下
    if @battler_visible
      # 逃跑
      if @battler.hidden
        $game_system.se_play($data_system.escape_se)
        escape
        @battler_visible = false
      end
      # 白色闪烁
      if @battler.white_flash
        whiten
        @battler.white_flash = false
      end
      # 动画
      if @battler.animation_id != 0
        animation = $data_animations[@battler.animation_id]
        animation(animation, @battler.animation_hit)
        @battler.animation_id = 0
      end
      # 伤害
      if @battler.damage_pop
        damage(@battler.damage, @battler.critical)
        animation($data_animations[Battler_set.红色闪烁的动画], true)
        for i in 1..Battler_set.震动帧数
          self.x += Battler_set.震动坐标偏移量
          Graphics.update
          Input.update
          self.y -= Battler_set.震动坐标偏移量
        end
        for i in 1..Battler_set.震动帧数
          self.x -= Battler_set.震动坐标偏移量
          Graphics.update
          Input.update
          self.y += Battler_set.震动坐标偏移量
        end
        @battler.damage = nil
        @battler.critical = false
        @battler.damage_pop = false
      end
      # korapusu
      if @battler.damage == nil and @battler.dead?
        if @battler.is_a?(Game_Enemy)
          $game_system.se_play($data_system.enemy_collapse_se)
        else
          $game_system.se_play($data_system.actor_collapse_se)
        end
        collapse
        @battler_visible = false
      end
    end
    # 设置活动块的坐标
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
  end
end

作者: 白魔导师宝儿    时间: 2014-2-8 13:39
本帖最后由 白魔导师宝儿 于 2014-2-8 13:44 编辑
恋′挂机 发表于 2014-2-8 13:26
红色闪烁 + 抖动
闪烁是要在数据库中先定义那么个动画才行
其实就是多播发了个动画


多谢你
请问如果在此基础上加红色闪烁也行吗?
@恋′挂机
差不多,就像行动时的那个白色闪烁一样。
作者: 恐惧剑刃    时间: 2014-2-8 13:59
白魔导师宝儿 发表于 2014-2-8 13:39
多谢你
请问如果在此基础上加红色闪烁也行吗?
@恋′挂机

替换原代码即可
module Battler_set
  def self.震动帧数
    return 5
  end
  def self.震动坐标偏移量
    return 1
  end
  def self.红色
    return Color.new(250, 50, 50, 160)
  end
end
class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 战斗者为 nil 的情况下
    if @battler == nil
      self.bitmap = nil
      loop_animation(nil)
      return
    end
    # 文件名和色相与当前情况有差异的情况下
    if @battler.battler_name != @battler_name or
       @battler.battler_hue != @battler_hue
      # 获取、设置位图
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
      # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
      if @battler.dead? or @battler.hidden
        self.opacity = 0
      end
    end
    # 动画 ID 与当前的情况有差异的情况下
    if @battler.damage == nil and
       @battler.state_animation_id != @state_animation_id
      @state_animation_id = @battler.state_animation_id
      loop_animation($data_animations[@state_animation_id])
    end
    # 应该被显示的角色的情况下
    if @battler.is_a?(Game_Actor) and @battler_visible
      # 不是主状态的时候稍稍降低点透明度
      if $game_temp.battle_main_phase
        self.opacity += 3 if self.opacity < 255
      else
        self.opacity -= 3 if self.opacity > 207
      end
    end
    # 明灭
    if @battler.blink
      blink_on
    else
      blink_off
    end
    # 不可见的情况下
    unless @battler_visible
      # 出现
      if not @battler.hidden and not @battler.dead? and
         (@battler.damage == nil or @battler.damage_pop)
        appear
        @battler_visible = true
      end
    end
    # 可见的情况下
    if @battler_visible
      # 逃跑
      if @battler.hidden
        $game_system.se_play($data_system.escape_se)
        escape
        @battler_visible = false
      end
      # 白色闪烁
      if @battler.white_flash
        whiten
        @battler.white_flash = false
      end
      # 动画
      if @battler.animation_id != 0
        animation = $data_animations[@battler.animation_id]
        animation(animation, @battler.animation_hit)
        @battler.animation_id = 0
      end
      # 伤害
      if @battler.damage_pop
        damage(@battler.damage, @battler.critical)
        #animation($data_animations[Battler_set.红色闪烁的动画], true)
        flash(Battler_set.红色, 20)
        for i in 1..Battler_set.震动帧数
          self.x += Battler_set.震动坐标偏移量
          Graphics.update
          Input.update
          self.y -= Battler_set.震动坐标偏移量
        end
        for i in 1..Battler_set.震动帧数
          self.x -= Battler_set.震动坐标偏移量
          Graphics.update
          Input.update
          self.y += Battler_set.震动坐标偏移量
        end
        
        @battler.damage = nil
        @battler.critical = false
        @battler.damage_pop = false
      end
      # korapusu
      if @battler.damage == nil and @battler.dead?
        if @battler.is_a?(Game_Enemy)
          $game_system.se_play($data_system.enemy_collapse_se)
        else
          $game_system.se_play($data_system.actor_collapse_se)
        end
        collapse
        @battler_visible = false
      end
    end
    # 设置活动块的坐标
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
  end
end

作者: 白魔导师宝儿    时间: 2014-2-10 11:40
恋′挂机 发表于 2014-2-8 13:59
替换原代码即可

多谢指点




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1