Howdy, Stranger!

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

How To Make A Sequence Tween Go On Forever??

in Questions Posts: 104

How do you make “tween.sequence()” repeat itself forever? It’s for my 2D game that I’m currently developing.
Thanks in advance :)

Comments

  • dave1707dave1707 Mod
    Posts: 9,441

    @Creator27 In the last tween of the sequence, have it’s callback restart the tween sequence again.

  • Posts: 104

    @dave1707, I’m not quite sure what I’m supposed to write though. Could you give me an example to show me what to write and where to write it?

    Thank you :)

  • dave1707dave1707 Mod
    Posts: 9,441

    @Creator27 Here's an example. The circle will go in a clockwise direction around the screen.

    viewer.mode=STANDARD
    
    function setup()
        point = {x = 50, y = 50}
    end
    
    function tween1()
        t1 = tween(2, point, {x = 50,y=HEIGHT-50})
        t2 = tween(2, point, {x = WIDTH-50,y=HEIGHT-50})
        t3 = tween(2, point, {x=WIDTH-50,y = 50})
        t4 = tween(2, point, {x=50,y = 50},tween.easing.linear,restart)
        tween.sequence( t1, t2, t3, t4)
    end
    
    function draw()
        background(0)
        fill(255)
        text("tap screen to start",WIDTH/2,HEIGHT/2)
        ellipse(point.x, point.y, 50)
    end
    
    function touched(t)
        if t.state==BEGAN then
            tween1()
        end
    end
    
    function restart()
        print("restarting tween sequence")
        tween1()
    end
    
Sign In or Register to comment.