Actions
class IntervalAction < Scar::Action
@elapsed = 0f32
def initialize(@interval : Float32, @repeats : Int32, @f : Proc(Void))
end
def completed?(dt)
return true if @repeats <= 0
@elapsed += dt
if @elapsed >= @interval
f.call
@repeats -= 1
@elapsed = 0f32
end
return false
end
end
# Beep every second five times
app.act IntervalAction.new(1f32, 5, -> { app.act Scar::Actions::PlaySound.new(Assets["beep.wav", Assets::Sound]) })Last updated