Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Punch Animation Problem

I am creating a system to run much like double dragon and river city ransom. Most of the system animation like walking, running and jumping work, but when I try to program in a punch attack. Its tied to the Input::L button, but when I press the button only the first frame is shown.

I should also point out that I am editing a dash script to work for the punch attack.

Code:
 

#==============================================================================

# ** Game_Character (part 1)

#------------------------------------------------------------------------------

#  This class deals with characters. It's used as a superclass for the

#  Game_Player and Game_Event classes.

#==============================================================================

class Game_Character

  attr_accessor :character_name

  attr_accessor :animating

  attr_accessor :frame

  

  #--------------------------------------------------------------------------

  # * Set Animation

  #--------------------------------------------------------------------------

  def set_animate(name)

    return if @animating

    @frame = 8

    @old_char = @character_name

    @character_name = name

    @animating = true

    @anim_wait = 40

    @pattern = 0

    @direction_fix = true

  end

  #--------------------------------------------------------------------------

  # * End Animate

  #--------------------------------------------------------------------------

  def end_animate

    @animating = false

    @character_name = @old_char

    @direction_fix = false

  end

end

 

 

#==============================================================================

# ++ グラフィック変更ダッシュ ver. 1.21 ++

#  Script by パラ犬

#  http://para.j-mx.com/

#------------------------------------------------------------------------------

# 「Graphics/Characters」フォルダに

# ã€Œï¼ˆå…ˆé ­ã‚­ãƒ£ãƒ©ã®æ­©è¡Œã‚°ãƒ©ãƒ•ã‚£ãƒƒã‚¯åï¼‰ï¼‹_dashã€ã¨ã„ã†åå‰ã®ãƒ•ã‚¡ã‚¤ãƒ«ãŒã‚ã‚‹å ´åˆ

# ダッシュ時のグラフィックとして使用します。(例:001-Fighter01_dash)

#==============================================================================

 

class Game_Player < Game_Character

 

  SPEED_PUNCH = 5    # How fast to punch

 

  #The Key to press when punching

  KEY_PUNCH = Input::L

 

  # "_dash"グラフィックが存在しないå ´åˆãƒ€ãƒƒã‚·ãƒ¥ã‚’するか( true:する / false:しない )

  NO_FILE_PUNCH = true

  

  # 静止時はグラフィックを変更しない( true:変更しない / false:変更する )

  CHANGE_IN_MOVING = false

  

  # ダッシュ禁止イベントスイッチID

  # (イベントコマンド「スイッチの操作」でこの番号のスイッチをONにしている間は

  #  Ã£Æ’€ãƒƒã‚·ãƒ¥ã‚’機能を無効にします)

  NO_PUNCH_SWITCH = 998

 

end

 

#==============================================================================

# â–  Game_Player

#==============================================================================

 

class Game_Player < Game_Character

 

  #--------------------------------------------------------------------------

  # ● フレーム更新

  #--------------------------------------------------------------------------

  alias punch_update update

  def update

    # イベント実行中、移動ルート強制中、

    # メッセージウィンドウ表示中のいずれでもないå ´åˆ

    unless $game_system.map_interpreter.running? or

           @move_route_forcing or $game_temp.message_window_showing

      if !($game_switches[NO_PUNCH_SWITCH])

        # キー判定

        if Input.press?(KEY_PUNCH) and (CHANGE_IN_MOVING == false or Input.dir8 != 0)

          if (punch_graphic_exist?($game_party.actors[0]) or NO_FILE_PUNCH)

            # ダッシュ中でなければダッシュ

            if @move_speed != SPEED_PUNCH

              @move_speed = SPEED_PUNCH

              @punch_on = true

              animate(@character_name)

              $game_player.refresh

            end

          end

        elsif @punch_on == nil or @punch_on

            @move_speed = SPEED_NORMAL

            @punch_on = nil

            $game_player.refresh

        end

      end

    end

    dash_update

  end

  #--------------------------------------------------------------------------

  # â—‹ ダッシュグラフィックの有無をチェック

  #--------------------------------------------------------------------------

  def punch_graphic_exist?(actor)    

    # 読み込みテスト

    begin

      RPG::Cache.character(actor.character_name.to_s + "_punch", actor.character_hue)

    rescue

      return false

    end

    return true

  end

  #--------------------------------------------------------------------------

  # ● リフレッシュ

  #--------------------------------------------------------------------------

  alias punch_refresh refresh

  def refresh

    dash_refresh

    # パーティ人数が 0 人でないå ´åˆ

    if $game_party.actors.size != 0

      actor = $game_party.actors[0]

      # キャラクターのファイル名と色相を設定

      if @punch_on and punch_graphic_exist?(actor)

        fileplus = "_punch"

      else

        fileplus = ""

      end

      @character_name = actor.character_name + fileplus

      @character_hue = actor.character_hue

      

    end

  end

  #--------------------------------------------------------------------------

  # * Animate(object, name)

  #--------------------------------------------------------------------------

  def animate(name)

    set_animate(name)

  end

end

 

I think I may know the problem, but I would like someone who knows about these things to give their opinion first.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top