mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
More FPS agnosticism, fixed pause after finishing an event's repeating move route
This commit is contained in:
@@ -2,13 +2,23 @@
|
||||
# Walking charset, for use in text entry screens and load game screen
|
||||
#===============================================================================
|
||||
class TrainerWalkingCharSprite < Sprite
|
||||
attr_accessor :anim_duration
|
||||
|
||||
# Default time in seconds for one animation cycle of a charset. The icon for a
|
||||
# storage box is 0.4 instead (set manually).
|
||||
ANIMATION_DURATION = 0.5
|
||||
|
||||
def initialize(charset, viewport = nil)
|
||||
super(viewport)
|
||||
@animbitmap = nil
|
||||
self.charset = charset
|
||||
@animframe = 0 # Current pattern
|
||||
@frame = 0 # Frame counter
|
||||
self.animspeed = 5 # Animation speed (frames per pattern)
|
||||
@current_frame = 0 # Current pattern
|
||||
@anim_duration = ANIMATION_DURATION
|
||||
end
|
||||
|
||||
def dispose
|
||||
@animbitmap&.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def charset=(value)
|
||||
@@ -38,13 +48,8 @@ class TrainerWalkingCharSprite < Sprite
|
||||
end
|
||||
end
|
||||
|
||||
def animspeed=(value)
|
||||
@frameskip = value * Graphics.frame_rate / 40
|
||||
end
|
||||
|
||||
def dispose
|
||||
@animbitmap&.dispose
|
||||
super
|
||||
def update_frame
|
||||
@current_frame = (4 * (System.uptime % @anim_duration) / @anim_duration).floor
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -54,12 +59,9 @@ class TrainerWalkingCharSprite < Sprite
|
||||
@animbitmap.update
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
end
|
||||
@frame += 1
|
||||
if @frame >= @frameskip
|
||||
@animframe = (@animframe + 1) % 4
|
||||
self.src_rect.x = @animframe * @animbitmap.bitmap.width / 4
|
||||
@frame -= @frameskip
|
||||
end
|
||||
# Update animation
|
||||
update_frame
|
||||
self.src_rect.x = self.src_rect.width * @current_frame
|
||||
@updating = false
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user