Skip to content

Instantly share code, notes, and snippets.

@djfumberger
Created August 11, 2017 04:27
Show Gist options
  • Save djfumberger/e6f5e25fea0d9ce9c24e83a61993454a to your computer and use it in GitHub Desktop.
Save djfumberger/e6f5e25fea0d9ce9c24e83a61993454a to your computer and use it in GitHub Desktop.
class PresentItem extends Layer
constructor:(args) ->
super args
@.backgroundColor = null
@.content = new Layer
width: @.width
height: @.height
superLayer: @
image: "images/small-present.png"
explode:() ->
t = 0.5
up = new Animation
time: t
curve: "ease-out"
layer: @
properties:
y: @.y - 100 - Utils.randomNumber(350)
down = new Animation
time: t
curve: "ease-in"
layer: @
properties:
y: @.y + 50 + Utils.randomNumber(300)
up.on Events.AnimationEnd, down.start
up.start()
xDir = Utils.randomChoice([-1, 1])
@.content.animate
time: t * 2.0
curve: "ease-in-out"
properties:
x: Utils.randomNumber(300) * xDir
rotation: Utils.randomNumber(360) * xDir
scale: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment