Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function anim( dur, steppers, post )
- local t = thread.new(function()
- local start = os.millis()
- local stop = start + dur
- while true do
- local p = math.map( os.millis(), start, stop, 0, 1 )
- p = math.min( 1, p )
- for i, s in ipairs( steppers ) do
- s( p )
- end
- if p == 1 then break end
- end
- post()
- end)
- t.start()
- end
- hud2D.clearAll()
- local text = hud2D.newText("Test", 10, 10)
- text.setOpacity(0)
- text.enableDraw()
- local a, b = 5, 25 --arbitrary values
- function s1( p )
- text.setX( math.map( p, 0, 1, a, b) )
- end
- function s2( p )
- text.setOpacity( p^5 )
- end
- anim( 1000, {s1, s2}, function() log("Done!") end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement