Problems with animation

0

There is an animation in the game that the character attacking with the sword, ah sword and an image behind the character, the code draws so. but my real problem is with Index, when the player goes through a type of portal to go to another map, i ends up being Nill

  #--------------------------------------------------------------------------
  # * Atualização do ataque
  #-------------------------------------------------------------------------- 
  def update_attack
      for i in 1..$game_temp.Player_HighIndex 
      if $game_system.PlayerAttacking(i)
      if @createdanim[i] == 0 
        create_anim(i)
        end
      if @createdanim[i].nil?
        create_anim(i)
      end
    end
    end

    if @anim.nil? || @count.nil? || @icon_index.nil? || @createdanim.nil?
      @anim = []
      @count = []
      @icon_index = []
      @createdanim = []

    end

    for i in 1..$game_temp.Player_HighIndex
    if @count[i] && @count[i] >= 0
      @anim[i].x = 1
      @anim[i].x = (StructManager.Player(i).X + 1 ) * 32 + Position[StructManager.Player(i).Dir][0] - 16
      @anim[i].y = (StructManager.Player(i).Y + 1 ) * 32 + Position[StructManager.Player(i).Dir][1] - 5
      case @count[i]
      when 12; set_angle(i, 0)
      when 9; set_angle(i, 1)
      when 6; set_angle(i, 2)
      when 3; set_angle(i, 3)
      when 0
        @anim[i].bitmap = nil
        @count[i] = nil
        @anim[i].visible = false
        @anim[i].dispose
        @anim[i] = nil
        $game_system.SetPlayerAttacking(i, false)
        @createdanim[i] = 0
      end
      @count[i] -= 1 if @count[i]
      end
    end
    @createdanim[i] == 0
 return;
  end

Exp

In case

if @createdanim[i] == 0 

ends up being if @createdanim[Nill] == 0 if the player presses Z from but at the time of passing the portal.

but in this case it would have to be i of the player ( for i in 1..$game_temp.Player_HighIndex ).

I want to know how do I make the animation not happen if the i is Null or until it repeats the animation if it is Null

Some tips I tried to use a return if @createdanim[i] == Nill or false but maybe I did not do it right.

Possible solution.

I think I already understand the source of the problem, the i of the player only updates once, in case if I press the Z button for the second time the i = 0.

That's where the

if @createdanim[i] == 0
    create_anim(i)
  end

When the player changes the map, the def update_attack updates and the i is no longer zero, so it's a bug rolling since this two action is done at the same time.

Then in case I have to make def update_attack be called every time the person presses Z, so it is always updating the i of the player.

    
asked by anonymous 04.02.2018 / 13:41

0 answers