Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Tween.sequence table [solved]

edited August 2013 in Questions Posts: 82

Hi there,

I'd like to create a table of tweens, and then provide these entries as arguments in tween.sequence. Only, I can't figure out how to convert a table into arguments for a function, and tween.sequence doesn't accept tables.

Does anybody know how to do this? Thanks in advance!



  • Posts: 82

    Hm, worked my way around it now by assigning callback functions to the next tween in a loop now. However, I would still like to know if it's possible with tween.sequence and an array :)

  • edited August 2013 Posts: 580

    You can unpack an array into a parameter list with Lua's unpack() function. Here's is the example from the tween.sequence() documentation, modified to put the tweens in an array, and unpack the array into an argument list for tween.sequence():

    function setup() point = {x = 10, y = 10} tweens = { tween(1, point, {x=100}), tween(1, point, {x=50}), tween(1, point, {y=150}), } tween.sequence(unpack(tweens)) end function draw() background(0) ellipse(point.x, point.y, 20) end
  • Posts: 82

    Awesome, that is exactly what I was looking for! This is gonna make things a lot easier.

Sign In or Register to comment.