Help - Search - Members - Calendar
Full Version: Change Player/Character Animation Frame Count
RPG RPG Revolution Forums > Scripting > Script Development and Support
Resource Dragon
Somewhere in the scripts i've seen the frame count for the characters, but i don't remember where. It's been way to long since i've used VX lol.

example:

a normal sprite animation sheet is 3 wide x 4 long (4 directions, each with three sprites)

I just know i've seen the code in the scripts where you can change this amount.

Any idea where? :S
Kread-EX
Within Sprite_Character.

CODE
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_index != @character.character_index
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_index = @character.character_index
      if @tile_id > 0
        sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = Cache.character(@character_name)
        sign = @character_name[/^[\!\$]./]
        if sign != nil and sign.include?('$')
          @cw = bitmap.width / 3
          @ch = bitmap.height / 4
        else
          @cw = bitmap.width / 12
          @ch = bitmap.height / 8
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
  end
Resource Dragon
Let me rephrase my question.

I meant I needed the amount of frames in one character changed.

I've played around with it but I can't figure out how to change it so the '$name.png'
will change from a 3 x 4 animation to a 5 x 4 animation.

Could you post how it would be changed?
Kread-EX
Basically, look at this:
CODE
        if sign != nil and sign.include?('$')
          @cw = bitmap.width / 3
          @ch = bitmap.height / 4

If you have a $ in the name, the bitmap width is divided per 3 and the height per 4.
To change it into a 5x4 sheet, you just need to replace this:
CODE
          @cw = bitmap.width / 3
with this:
CODE
          @cw = bitmap.width / 5

Obviously this won't show in the editor, just in the game.
Resource Dragon
EDIT: For some reason when I try to add another one, e.g. "#(name).png", It keeps giving me an ErCode, "nil can't be coerced into Fixnum"

I changed the $ one to 5 x 4,

and it takes the first 3 frames of each row and plays them instead of all 5.

...?
Kread-EX
QUOTE
EDIT: For some reason when I try to add another one, e.g. "#(name).png", It keeps giving me an ErCode, "nil can't be coerced into Fixnum"

If you want to use another symbol other than $, you need to update the regexp. Like this:
CODE
        sign = @character_name[/^[\!\$\#]./]
        if sign != nil and sign.include?('$')
          @cw = bitmap.width / 3
          @ch = bitmap.height / 4
       elsif sign != nil and sign.include?('#')
          @cw = bitmap.width / 5
          @ch = bitmap.height / 4
        else
          @cw = bitmap.width / 12
          @ch = bitmap.height / 8
        end


QUOTE
and it takes the first 3 frames of each row and plays them instead of all 5.

Because by default, there is only 3 animation patterns. Patterns are more or less universal, so differentiate between certain characters can be tricky. You need to alter both Game_Character and Sprite_Character, but I can't give you more precise informations without knowing a bit more what you want to do. Can this apply to the player? Or only events? Things like that.
Resource Dragon
QUOTE
Because by default, there is only 3 animation patterns. Patterns are more or less universal, so differentiate between certain characters can be tricky. You need to alter both Game_Character and Sprite_Character, but I can't give you more precise informations without knowing a bit more what you want to do. Can this apply to the player? Or only events? Things like that.


The '#' symbol would be the same as the '$' symbol, except it would play a 5 x 4 animation instead of a 3 x 4 animation.
It would apply to everything the '$' symbol can.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.