-
Notifications
You must be signed in to change notification settings - Fork 277
/
Copy pathbubble.js
43 lines (26 loc) · 1.12 KB
/
bubble.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
goog.provide('zlizer.Bubble');
goog.require('lime.Sprite');
zlizer.Bubble = function(value) {
lime.Sprite.call(this);
this.value = value;
this.circle = new lime.Sprite().setFill('assets/bubble_back.png').setSize(70, 70);
this.appendChild(this.circle);
this.lbl = new lime.Label().setText(value).setFontSize(34).setFontColor('#fff').setFontWeight(700).setFontFamily('Impact');
this.appendChild(this.lbl);
this.GRAVITY = 2.5;
this.setAnchorPoint(0, 0);
this.setScale(1.2);
//this.setRenderer(lime.Renderer.CANVAS);
this.v = new goog.math.Vec2(0, this.GRAVITY);
};
goog.inherits(zlizer.Bubble, lime.Sprite);
zlizer.Bubble.random = function(max) {
var value = Math.ceil(Math.random() * max);
return new zlizer.Bubble(value);
};
zlizer.Bubble.prototype.updateFloatingSpeed = function() {
this.v.add(new goog.math.Vec2((Math.random() * 2 - 1) * .6, Math.random() * .1));
var delta = this.v.clone().scale(zlizer.BUBBLE_SPEED);
this.move = new lime.animation.MoveBy(delta.x, delta.y).setDuration(20).setEasing(lime.animation.Easing.LINEAR);
this.runAction(this.move);
};