ClearAnimation = {} ClearAnimation.__index = ClearAnimation function ClearAnimation.new(is_2p) local self = setmetatable({}, ClearAnimation) self.is_2p = is_2p self.idx = is_2p and 1 or 0 self.draw_clear_full = false self.name = "in" self.frame = 0 self.bachio_fade_in = tex.get_animation(46, "game") self.bachio_texture_change = tex.get_animation(47, "game") self.bachio_out = tex.get_animation(55, "game") self.bachio_move_out = tex.get_animation(66, "game") self.clear_highlight_fade_in = tex.get_animation(56, "game") self.bachio_fade_in:start() self.bachio_texture_change:start() self.bachio_out:start() self.bachio_move_out:start() self.clear_highlight_fade_in:start() self.clear_separate_fade_in = {} self.clear_separate_stretch = {} for i = 0, 4 do local fade = anim.fade(100, { initial_opacity = 0.0, final_opacity = 1.0, delay = i * 50 }) fade:start() self.clear_separate_fade_in[i + 1] = fade local stretch = anim.text_stretch(200, { delay = i * 50 }) stretch:start() self.clear_separate_stretch[i + 1] = stretch end audio.play_sound("clear", "sound") self.t_clear = tex.get_texture("game/ending_anim/clear") self.t_clear_separated = tex.get_texture("game/ending_anim/clear_separated") self.t_clear_highlight = tex.get_texture("game/ending_anim/clear_highlight") self.t_bachio_l_in = tex.get_texture("game/ending_anim/bachio_l_in") self.t_bachio_l_out = tex.get_texture("game/ending_anim/bachio_l_out") self.t_bachio_r_in = tex.get_texture("game/ending_anim/bachio_r_in") self.t_bachio_r_out = tex.get_texture("game/ending_anim/bachio_r_out") local spacing = tex.get_skin_config("clear_animation_x_spacing") self.clear_anim_x_spacing = (spacing and spacing.x) or 0 return self end function ClearAnimation:update(current_ms) self.bachio_fade_in:update(current_ms) self.bachio_texture_change:update(current_ms) self.bachio_out:update(current_ms) self.bachio_move_out:update(current_ms) self.clear_highlight_fade_in:update(current_ms) if self.clear_highlight_fade_in.is_finished or self.clear_highlight_fade_in.attribute >= 1.0 then self.draw_clear_full = true end for i = 1, 5 do self.clear_separate_fade_in[i]:update(current_ms) self.clear_separate_stretch[i]:update(current_ms) end if self.bachio_texture_change.is_finished then self.name = "out" self.frame = math.floor(self.bachio_out.attribute) else self.frame = math.floor(self.bachio_texture_change.attribute) end end function ClearAnimation:draw() if self.draw_clear_full then tex.draw_texture(self.t_clear, { index = self.idx }) else for i = 5, 1, -1 do local j = i - 1 tex.draw_texture(self.t_clear_separated, { frame = j, x = j * self.clear_anim_x_spacing, y = -self.clear_separate_stretch[i].attribute, y2 = self.clear_separate_stretch[i].attribute, fade = self.clear_separate_fade_in[i].attribute, index = self.idx, }) end end tex.draw_texture(self.t_clear_highlight, { fade = self.clear_highlight_fade_in.attribute, index = self.idx, }) local ltex = (self.name == "in") and self.t_bachio_l_in or self.t_bachio_l_out local rtex = (self.name == "in") and self.t_bachio_r_in or self.t_bachio_r_out tex.draw_texture(ltex, { frame = self.frame, x = -self.bachio_move_out.attribute, fade = self.bachio_fade_in.attribute, index = self.idx, }) tex.draw_texture(rtex, { frame = self.frame, x = self.bachio_move_out.attribute, fade = self.bachio_fade_in.attribute, index = self.idx, }) end