Advertisement
Guest User

sans_anim.lua

a guest
Aug 21st, 2020
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. --For usage, check out the encounter Lua's EncounterStarting() and Update() functions.
  2.  
  3. -- First, we can create the torso, legs and head.
  4. sanstorso = CreateSprite("sans/sanstorso")
  5. sanslegs = CreateSprite("sans/sanslegs")
  6. sanshead = CreateSprite("sans/sanshead2_noglasses")
  7. glasses = CreateSprite("sans/sansglasses")
  8.  
  9. --We parent the torso to the legs, so when you move the legs, the torso moves too.
  10. --We do the same for attaching the head to the torso.
  11. sanstorso.SetParent(sanslegs)
  12. sanshead.SetParent(sanstorso)
  13. glasses.SetParent(sanshead)
  14.  
  15. --Now we adjust the height for the individual parts so they look more like a skeleton and less like a pile of bones.
  16. sanslegs.y = 240
  17. sanslegs.x = 320
  18. sanstorso.y = -5 --The torso's height is relative to the legs they're parented to.
  19. sanshead.x = 0 --The head's height is relative to the torso it's parented to.
  20. sanshead.y = -50 --The head's height is relative to the torso it's parented to.
  21.  
  22. --We set the torso's pivot point to halfway horizontally, and on the bottom vertically,
  23. --so we can rotate it around the bottom instead of the center.
  24. sanstorso.SetPivot(0.5, 0)
  25.  
  26. --We set the torso's anchor point to the top center. Because the legs are pivoted on the bottom (so rescaling them only makes them move up),
  27. --we want the torso to move along upwards with them.
  28. sanstorso.SetAnchor(0.5, 0.5)
  29. sanslegs.SetPivot(0.5, 0)
  30.  
  31. function AnimateSans()
  32.     sanshead.MoveTo(-7 + 0*math.sin(Time.time), 45 + 2*math.sin(Time.time*10))
  33.     sanstorso.MoveTo(2*math.sin(Time.time*5), 23 + 2*math.sin(Time.time*10))
  34. end
  35.  
  36. function AnimateFresh()
  37.     sanshead.MoveTo(-7 + 0*math.sin(Time.time), 45 + 2*math.sin(Time.time*10))
  38.     sanstorso.MoveTo(1*math.sin(Time.time*5), 23 + 1*math.sin(Time.time*10))
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement