-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimatedButtonClass.js
More file actions
42 lines (35 loc) · 924 Bytes
/
Copy pathAnimatedButtonClass.js
File metadata and controls
42 lines (35 loc) · 924 Bytes
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
"use strict";
function AnimatedButton (image) {
Button.call(this, image);
this.position = undefined;
this.scaleFactor = 0;
this.showUp = false;
this.hide = false;
this.showed = false;
this.removed = false;
}
AnimatedButton.prototype = Object.create(Button.prototype);
AnimatedButton.prototype.appear = function (delta) {
this.scaleFactor += 0.1;
if(this.scaleFactor >= 0.9) {
this.scaleFactor = 1;
this.showed = true;
}
};
AnimatedButton.prototype.remove = function (delta) {
console.log(this.showUp);
console.log(this.showed);
}
AnimatedButton.prototype.update = function (delta) {
if (this.showUp && !this.showed) {
this.appear();
}
if (this.hide && !this.removed) {
this.remove();
}
};
AnimatedButton.prototype.draw = function (delta) {
if (!this.visible)
return;
Canvas2D.drawImage(this.image, this.position, this.origin, this.scaleFactor);
};