forked from HarleyV/ZeldaGroup_CSC17B
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnBox.js
More file actions
29 lines (24 loc) · 761 Bytes
/
AnBox.js
File metadata and controls
29 lines (24 loc) · 761 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
function AnBox(animSet, anim) {
GameObject.call(this);
this.animator = new Animator(animSet, this);
this.animator.setAnim(anim);
this.animator.play();
this.size = this.animator.cell;
this.canCollide = false;
}
// Inherit from GameObject
AnBox.prototype = Object.create(GameObject.prototype);
AnBox.prototype.constructor = AnBox;
AnBox.prototype.update = function(deltaTime) {
if (this.animator.playing == false) {
// Delete self
delObject(this);
}
}
AnBox.prototype.draw = function(deltaTime) {
this.animator.play();
this.animator.update(deltaTime, this);
this.elem.style.backgroundPosition = -this.sprite.x + "px " + -this.sprite.y + "px";
// Call the base version of the draw
GameObject.prototype.draw.call(this, deltaTime);
}