Anyone know if we can start a tween by this id ? If we have another function that tween.sequence ?
local id = tween(time, subject, target, ...) tween.reset(id) tween.start(id) -- something like this ```
Anyone know if we can start a tween by this id ? If we have another function that tween.sequence ?
local id = tween(time, subject, target, ...) tween.reset(id) tween.start(id) -- something like this ```
Have a look at tween with pairs like you would a table and you’ll find there’s what would appear to be some undocumented functionality ;).
tween.play()
seems to be what your looking for take a look
function setup()
r = {x=0,y=0,w=100,h=100}
r2 = {x=0,y=0,w=100,h=100}
-- take a peek at tweens functions
local tw = tween
for i,v in pairs(tw) do
print(i,"=",v)
end
local tw2 = tween(5,r2,{x=WIDTH-r2.w},{loop=tween.loop.pingpong})
local twid = nil
-- example usage
parameter.action("Start",function()
if twid == nil then
twid = tween(10,r,{x=WIDTH-r.w})
else
tween.play(twid)
end
end)
parameter.action("Stop",function()
if twid ~= nil then
tween.play(twid)
tween.stop(twid)
end
end)
parameter.action("Reset",function()
if twid ~= nil then
tween.play(twid)
tween.reset(twid)
end
end)
end
function draw()
background(40, 40, 50)
strokeWidth(5)
-- draw rect
translate(0,HEIGHT/2)
rect(r.x,r.y,r.w,r.h)
translate(0,r2.h+30)
rect(r2.x,r2.y,r2.w,r2.h)
end
Thanks !