Yep, you are missing some stuff. At least 3 important things.
1. You are actually not drawing anything related with "label". If you want to see it on the screen, you have to print it somewhere!
2. The variable "label" is a local variable created inside love.draw. Local variables which are not referenced from outside or returned by their function get destroyed when the function is finished.
3. You are creating many tweeners per second. Let me explain this a bit more.
In LÖVE, the functions love.draw and love.update are called
may times per second. Usually more than 30.
If you put this line inside love.draw:
Code: Select all
tween(4, label, { y=300 }, 'outBounce')
It gets executed
many times per second. You just need to create one, and then let it "live" (update) until it expires.
In order to make your example work, you must conserve the label between love.draw invocations. This can be done by declaring the `label` variable outside of all functions.
You also want to create a single tweener, not one every frame . A good place to do that is love.load, since it get executed only once at the beginning of the game.
And of course, you need to actually print the label somewhere!
This will give you this:
Code: Select all
local tween = require 'tween'
local label -- declare label here so it is available to all the functions below
function love.load()
label = { x=200, y=0, text = "hello" }
tween(4, label, { y=300 }, 'outBounce')
end
function love.draw()
love.graphics.draw(label.text, label.x, label.y) -- print the label! This is very important! :D
end
function love.update(dt)
tween.update(dt)
end