Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: kreiss on May 29, 2018, 09:20:41 am

Title: [RESOLVED]Animated Picture
Post by: kreiss on May 29, 2018, 09:20:41 am
Hi guys!

I finded a script in Littledrago's blog.
But I don't know how the script work.

I rename my picture by "anime_01-001", "anime_01-002" etc...
But isn't working.

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# [Xp/Vx] Animated Picture
# Version: 1.00
# Author : LiTTleDRAgo
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Name your pictures with "anime_01-001","anime_01-002","anime_01-003" and so on
# You can use more than 1 animated picture
#
#    Just name it like "anime_02-001", "anime_02-002", etc
#                      "anime_03-001", "anime_03-002", etc
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

#==============================================================================
# ** Game_Picture
#------------------------------------------------------------------------------
#  This class handles the picture. It's used within the Game_Screen class
#  ($game_screen).
#==============================================================================

class Game_Picture
  #--------------------------------------------------------------------------
  # * Script Configuration
  #--------------------------------------------------------------------------
  DELAY = 3 # delay after each image (frames)
 
  LAST_FRAME_VAR    = 1
  CURRENT_FRAME_VAR = 2
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias update_animated_pict update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @name =~ /anime_..-(\d+)/i
      @animated = true
    else
      @animated = false
    end
    if @animated
      @counter.nil? ? @counter = 0 : @counter += 1
      if @counter == DELAY
        @counter = 0
        if $game_variables[CURRENT_FRAME_VAR] < $game_variables[LAST_FRAME_VAR]
          $game_variables[CURRENT_FRAME_VAR] += 1
          @frame = $game_variables[CURRENT_FRAME_VAR]
          @temp  = @name.scan(/anime_../)
          case @frame
          when  0..9  then @frame = "00#{@frame}"
          when 10..99 then @frame = "0#{@frame}"
          end
          name = "#{@temp}-#{@frame}"
          @name = name if picture_exist?(name)
        end
      end
    end
    update_animated_pict
  end
  #--------------------------------------------------------------------------
  # * Picture Exist
  #--------------------------------------------------------------------------
  def picture_exist?(filename)
    if defined?(Window_ActorCommand)
      return Cache.picture(filename) rescue return false
    else
      return RPG::Cache.picture(filename) rescue return false
    end
  end
end


Sorry for disturbance.

Edit : Isn't the good section, someone can move the topic please ?
Title: Re: [XP]Animated Picture
Post by: KK20 on May 29, 2018, 11:59:26 am
Are you using game variables 1 and 2 for anything?
Title: Re: [XP]Animated Picture
Post by: kreiss on May 29, 2018, 12:12:36 pm
No, I use a new project.

Edit: Ow...  :facepalm:
I had to use a variable to move pictures.

It was so simple. :facepalm:

Thanks to help !