Created
July 14, 2016 01:05
-
-
Save djfumberger/9445691cb2d226dc58a55a91e9d01856 to your computer and use it in GitHub Desktop.
Favourites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new BackgroundLayer | |
xSide = 0 | |
class Heart extends Layer | |
constructor:(options) -> | |
super options | |
@.image = "images/heart-" + Utils.randomChoice([1,2,3,4,5,6]) + ".png" | |
#@.image = "images/heart-1.png" | |
if Utils.randomChoice([0,1,2,3]) == 0 | |
Utils.delay 2.0, => | |
@.explode() | |
# else | |
# if Utils.randomChoice([0,1]) == 0 | |
# @.blur = 6 | |
# @.scale = 0.5 | |
Utils.delay 1.0, => | |
@.hide() | |
hide:() -> | |
a = @.animate | |
time: 3.0 | |
properties: | |
opacity: 0.0 | |
a.on Events.AnimationEnd, => | |
@.destroy() | |
explode:() -> | |
n = 6 | |
angle = 0 | |
radius = 80 | |
for i in [0.. n - 1] | |
radians = (angle) * (3.14 / 180) | |
radians2 = (angle + 45) * (3.14 / 180) | |
x = ((radius / 2) + radius) * Math.cos(radians) | |
y = ((radius / 2) + radius) * Math.sin(radians) | |
angle += (360 / n) | |
h = new Layer | |
width: 22 | |
x: 10 | |
y: 10 | |
height: 20 | |
image: @.image | |
scale: 1.0 | |
superLayer: @ | |
h.animate | |
curve: "spring(100,55,2)" | |
properties: | |
x: x | |
y: y | |
h.animate | |
delay: 0.15 | |
curve: "spring(60,50,2)" | |
properties: | |
opacity: 0.0 | |
scale: 0.5 | |
a = @.animate | |
time: 2.5 | |
properties: | |
opacity: 0.0 | |
a.on Events.AnimationEnd, => | |
@.destroy() | |
addHeart = () -> | |
y = Utils.randomNumber(Screen.height) | |
if xSide == 0 | |
xSide = 1 | |
else | |
xSide = 0 | |
x = Utils.randomNumber(Screen.width / 2.0) | |
if xSide == 1 | |
x += Screen.width / 2.0 | |
if y > 537 && y < 537 + 260 | |
y += 600 | |
h = new Heart | |
x: x | |
y: y | |
superLayer: container | |
width: 22 * 1.5 | |
height: 20 * 1.5 | |
h.opacity = 0.0 | |
h.animate | |
time: 2.0 | |
properties: | |
opacity: 1.0 | |
h.animate | |
curve: "linear" | |
time: 3.0 | |
properties: | |
x: h.x - 60 | |
y: h.y - 60 | |
Utils.interval 0.4, -> | |
addHeart() | |
container = new Layer | |
size: Screen.size | |
backgroundColor: "white" | |
favourites_empty_textA = new Layer | |
width: 366 | |
height: 208 | |
x: 192 | |
y: 563 | |
image: "images/favourites-empty-text.png" | |
favourites_header = new Layer | |
width: 748 | |
height: 138 | |
image: "images/favourites-header.png" | |
addHeart() | |
addHeart() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment