Advertisement
HuskyLover269

Untitled

Jun 2nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 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("AAASans/Parts/Body")
  5. sanslegs = CreateSprite("AAASans/Parts/Feet")
  6. sanshead = CreateSprite("AAASans/Parts/Head1")
  7.  
  8. --We parent the torso to the legs, so when you move the legs, the torso moves too.
  9. --We do the same for attaching the head to the torso.
  10. sanstorso.SetParent(sanslegs)
  11. sanshead.SetParent(sanstorso)
  12.  
  13. --Now we adjust the height for the individual parts so they look more like a skeleton and less like a pile of bones.
  14. sanslegs.y = 240
  15. sanslegs.x = 320
  16. sanstorso.y = 0 --The torso's height is relative to the legs they're parented to.
  17. sanshead.y = 40 --The head's height is relative to the torso it's parented to.
  18.  
  19. --We set the torso's pivot point to halfway horizontally, and on the bottom vertically,
  20. --so we can rotate it around the bottom instead of the center.
  21. sanstorso.SetPivot(0.5, 0)
  22.  
  23. --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),
  24. --we want the torso to move along upwards with them.
  25. sanstorso.SetAnchor(0.5, 1)
  26. sanslegs.SetPivot(0.5, 0)
  27.  
  28. --Finally, we do some frame-by-frame animation just to show off the feature. You put in a list of sprites,
  29. --and the time you want a sprite change to take. In this case, it's 1/2 of a second.
  30. SetGlobal("stop",false)
  31. emotion = "normal"
  32. Dodge = false
  33. Stop = 0
  34. move = 0
  35.  
  36. function AnimateSans()
  37. if emotion == "sockets" then
  38. sanshead.Set("AAASans/Parts/Head2")
  39. else
  40. sanshead.Set("AAASans/Parts/Head1")
  41. end
  42. sanshead.MoveTo(2*math.sin(Time.time)+move, 42 + 2*math.cos(Time.time))
  43. sanstorso.MoveTo(2*math.sin(Time.time)+move,0)
  44. sanslegs.MoveTo(2*math.sin(Time.time)+move,42 + move*math.cos(Time.time))
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement