Hi, i'm using this script for animated battlebacks:
I did everything it said, my game runs normally, but the battleback is still static. How is that possible?
Also, does anyone know who made this script? So i can give credit.
thanks :blush:
This script enables you to have animated battle backgrounds with the use of multiple frames.
Your animated battleback files should always end with two numbers, first is the total number of frames (ranging from 0 to 9) and the second is the current frame for this battleback (starting from 0 to total number - 1), so if you had 3 frames for some forest back you'd name the files:
forest30
forest31
forest32
That's all, the script will check the second number from the end of the string (total frames), if it's a number in range of 0 to 9 it'll update the battleback, change the number 20 in @delay = 20 to change the animation speed.
Add the following variables after @timer_sprite = Sprite_Timer.new in the initialize method of Spriteset_Battle (line 49):
@frame = 0
@frame_num = 1
@delay = 20
@old_fc = Graphics.frame_count
In the update method, under @battleback_name = $game_temp.battleback_name add:
frame_num = @battleback_name[@battleback_name.size-2].chr
@frame_num = (0..9).include?(@frame_num.to_i) ? @frame_num.to_i : 1
Finally, add the following if statement to the end of the update method (after @viewport4.update)
if @frame_num > 1 and Graphics.frame_count - @old_fc > @delay
@frame += 1
@frame %= @frame_num
@battleback_name[@battleback_name.size - 1] = @frame.to_s
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@old_fc = Graphics.frame_count
end
Your animated battleback files should always end with two numbers, first is the total number of frames (ranging from 0 to 9) and the second is the current frame for this battleback (starting from 0 to total number - 1), so if you had 3 frames for some forest back you'd name the files:
forest30
forest31
forest32
That's all, the script will check the second number from the end of the string (total frames), if it's a number in range of 0 to 9 it'll update the battleback, change the number 20 in @delay = 20 to change the animation speed.
Add the following variables after @timer_sprite = Sprite_Timer.new in the initialize method of Spriteset_Battle (line 49):
@frame = 0
@frame_num = 1
@delay = 20
@old_fc = Graphics.frame_count
In the update method, under @battleback_name = $game_temp.battleback_name add:
frame_num = @battleback_name[@battleback_name.size-2].chr
@frame_num = (0..9).include?(@frame_num.to_i) ? @frame_num.to_i : 1
Finally, add the following if statement to the end of the update method (after @viewport4.update)
if @frame_num > 1 and Graphics.frame_count - @old_fc > @delay
@frame += 1
@frame %= @frame_num
@battleback_name[@battleback_name.size - 1] = @frame.to_s
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@old_fc = Graphics.frame_count
end
Also, does anyone know who made this script? So i can give credit.
thanks :blush: