• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Code 12d - tween path

br1wr2el3 Apr 30th, 2013 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2. --# Main
3. -- Code 12d - tween path
4.
5. -- Bruce Elliott
6. -- April 2013
7.
8. -- Accepts a table of waypoints to follow
9.
10. -- Setup multiple destinations or stop points
11. -- strt is the starting point
12. -- t1 - t5 are waypoints for the path
13. -- Then you will find four tweens - only one
14. -- at a time should be uncommented. The last tween
15. -- takes two lines so comment or uncomment carefully
16.
17. -- Use this function to perform your initial setup
18. function setup()
19.     strt = {x = WIDTH, y = HEIGHT, size = 20}
20.
21.     t1 = {x = 102, y = 100, size = 10}
22.     t2 = {x = 200, y = 500, size = 50}
23.     t3 = {x = WIDTH/2, y = HEIGHT/2, size = 100}
24.     t4 = {x = WIDTH/4, y = HEIGHT/4, size = 10}
25.     t5 = {x = 300, y = 200, size = 75}
26.
27.   --  tween.path(20, strt, {strt, t1, t2, t3, t4,  t5 ,t1})
28.  --   tween.path(20, strt, {strt, t1, t2, t3, t4,  t5 ,t1, strt})
29.     tween.path(20, strt, {t1, t2, t3, t4,  t5 ,t1, strt})
30.  --   tween.path(20, strt, {strt, t1, t2, t3, t4,  t5 ,t1}
31.  --   , {loop=tween.loop.forever})
32. end
33.
34. -- This function gets called once every frame
35. function draw()
36.     -- This sets a dark background color
37.     background(40, 40, 50)
38.
39.     noFill()
40.     -- This sets the line thickness
41.     strokeWidth(2)
42.
43.     -- The object moved during the path execution
44.     -- note that even though strt is the final
45.     -- waypoint the path never seems to return
46.     -- there
47.     -- If strt is the first waypoint the path will
48.     -- start there but, even with a loop, we never
49.     -- seem to return there
50.
51.     ellipse(strt.x, strt.y, strt.size)
52.
53. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top