Advertisement
HuskyLover269

Untitled

Jun 2nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 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. SetGlobal("Dodge", false)
  33. Dodge2 = false
  34. Dodging = false
  35. Dodging1 = false
  36. Stop = 0
  37. move = 0
  38. Dodgetimer = 0
  39. Dodgetimer2 = 0
  40. Dodgetimer3 = 0
  41.  
  42. function AnimateSans()
  43. if emotion == "sockets" then
  44. sanshead.Set("AAASans/Parts/Head2")
  45. else
  46. sanshead.Set("AAASans/Parts/Head1")
  47. end
  48. if GetGlobal("Dodge") == true then
  49. move = 1
  50. Dodging = true
  51. end
  52. if Dodging == true then
  53. Dodgetimer = Dodgetimer + 1
  54. Dodgetimer3 = Dodgetimer3 + 1
  55. end
  56.  
  57. if Dodgetimer == 100 then
  58. SetGlobal("Dodge", false)
  59. move = 0
  60. SetGlobal("Dodging", false)
  61. Dodgetimer = 0
  62. end
  63.  
  64. if Dodgetimer3 == 250 then
  65. Dodge2 = true
  66. end
  67.  
  68. if Dodge2 == true then
  69. move = -1
  70. Dodging2 = true
  71. end
  72.  
  73. if Dodging2 == true then
  74. Dodgetimer2 = Dodgetimer2 + 1
  75. end
  76.  
  77. if Dodgetimer2 == 100 then
  78. Dodgetimer3 = 0
  79. Dodge2 = false
  80. move = 0
  81. Dodging = false
  82. Dodgetimer2 = 0
  83. end
  84. sanshead.MoveTo(2*math.sin(Time.time*5), 42 + 2*math.cos(Time.time*5))
  85. sanstorso.MoveTo(2*math.sin(Time.time),0)
  86. sanslegs.Move(move,0)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement