Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --For usage, check out the encounter Lua's EncounterStarting() and Update() functions.
- -- First, we can create the torso, legs and head.
- sanstorso = CreateSprite("sans/sanstorso")
- sanslegs = CreateSprite("sans/sanslegs")
- sanshead = CreateSprite("sans/sanshead2_noglasses")
- glasses = CreateSprite("sans/sansglasses")
- --We parent the torso to the legs, so when you move the legs, the torso moves too.
- --We do the same for attaching the head to the torso.
- sanstorso.SetParent(sanslegs)
- sanshead.SetParent(sanstorso)
- glasses.SetParent(sanshead)
- --Now we adjust the height for the individual parts so they look more like a skeleton and less like a pile of bones.
- sanslegs.y = 240
- sanslegs.x = 320
- sanstorso.y = -5 --The torso's height is relative to the legs they're parented to.
- sanshead.x = 0 --The head's height is relative to the torso it's parented to.
- sanshead.y = -50 --The head's height is relative to the torso it's parented to.
- --We set the torso's pivot point to halfway horizontally, and on the bottom vertically,
- --so we can rotate it around the bottom instead of the center.
- sanstorso.SetPivot(0.5, 0)
- --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),
- --we want the torso to move along upwards with them.
- sanstorso.SetAnchor(0.5, 0.5)
- sanslegs.SetPivot(0.5, 0)
- function AnimateSans()
- sanshead.MoveTo(-7 + 0*math.sin(Time.time), 45 + 2*math.sin(Time.time*10))
- sanstorso.MoveTo(2*math.sin(Time.time*5), 23 + 2*math.sin(Time.time*10))
- end
- function AnimateFresh()
- sanshead.MoveTo(-7 + 0*math.sin(Time.time), 45 + 2*math.sin(Time.time*10))
- sanstorso.MoveTo(1*math.sin(Time.time*5), 23 + 1*math.sin(Time.time*10))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement