Advertisement
TekSoda

Untitled

Aug 14th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. --For usage, check out the encounter Lua's EncounterStarting() and Update() functions.
  2. -- First, we can create the torso, legs and head.
  3.  
  4. sanslegs = CreateSprite("spr_sansb_legs_0")
  5. sanstorso = CreateSprite("spr_sansb_torso_0")
  6. sanshead = CreateSprite("spr_sans_bface_0")
  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.  
  11. sanstorso.SetParent(sanslegs)
  12. sanshead.SetParent(sanstorso)
  13.  
  14. --Now we adjust the height for the individual parts so they look more like a skeleton and less like a pile of bones.
  15. sanslegs.y = 235
  16. sanstorso.x = -3 --The torso's height is relative to the legs they're parented to.
  17. sanshead.y = 15
  18. --We set the torso's pivot point to halfway horizontally, and on the bottom vertically,
  19. --so we can rotate it around the bottom instead of the center.
  20. sanstorso.SetPivot(0.5, 0)
  21.  
  22. --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),
  23. --we want the torso to move along upwards with them.
  24. sanstorso.SetAnchor(0.5, 1)
  25. sanslegs.SetPivot(0.5, 0)
  26. sanshead.SetPivot(0.5, 0)
  27.  
  28. sanslegs.Scale(2, 2)
  29. sanshead.Scale(2, 2)
  30. sanstorso.Scale(2, 2)
  31.  
  32. sanshead.SetAnimation({GetGlobal("SansFace")}, 1/3)
  33. -- {"spr_sans_bface_0"}, "spr_sansb_blueeye_0", "spr_sansb_blueeye_1", "spr_sansb_face_0", "spr_sansb_face_1", "spr_sansb_face_2", "spr_sansb_face_3", "spr_sansb_face_4", "spr_sansb_face_5", "spr_sansb_face_6", "spr_sansb_face_7", "spr_sansb_face_8", "spr_sansb_face_9"
  34. sanstorso.SetAnimation({"spr_sansb_torso_0"}, 1)
  35. --"spr_sansb_torso_2" "spr_sansb_torso_1"
  36.  
  37. function Animate()
  38. if GetGlobal("dodge") ~= nil then
  39. if GetGlobal("dodge") then
  40. sanslegs.x = sanslegs.x + (200 - sanslegs.x) / 10
  41. if sanslegs.x < 200.1 then
  42. SetGlobal("dodge", false)
  43. end
  44. elseif sanslegs.x ~= 320 and not GetGlobal("dodge") then
  45. sanslegs.x = sanslegs.x + (320 - sanslegs.x) / 10
  46. if sanslegs.x > 319.9 then
  47. SetGlobal("dodge", false)
  48. sanslegs.x = 320
  49. end
  50. end
  51. end
  52. sanstorso.MoveTo(-2 + math.sin(Time.time * 4), math.sin(Time.time * 8))
  53. sanshead.MoveTo(0, 15 + 0.4 * math.sin(Time.time * 1.5))
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement