Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
v2.1.3: fix 2xcall acc bug; suspend/resume feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesliu96 committed May 23, 2015
1 parent 60feb9d commit 6bddca5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ Clear the screen.
damoo.clear();
```

If needed, you may suspend the animation.

```javascript
damoo.suspend();
```

And resume it when ready to go.

```javascript
damoo.resume();
```

Enjoy! And explore more of the code! :)

Contributing
Expand Down
36 changes: 31 additions & 5 deletions damoo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Damoo - HTML5 Danmaku Engine v2.1.2
* Damoo - HTML5 Danmaku Engine v2.1.3
* https://github.com/jamesliu96/Damoo
*
* Copyright (c) 2015 James Liu
Expand All @@ -12,9 +12,11 @@
}
this.canvas = new Canvas(m, n, r, t);
this.thread = new Thread(r);
this.afid = null;
this.state = null;
};

Damoo.version = "v2.1.2";
Damoo.version = "v2.1.3";

Damoo.dom = window.document;

Expand Down Expand Up @@ -44,6 +46,14 @@
window.oRequestAnimationFrame ||
function(cb) { setTimeout(cb, 17); };

var _CAF = window.cancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.webkitCancelRequestAnimationFrame ||
window.msCancelAnimationFrame ||
window.oCancelAnimationFrame ||
function(id) { clearTimeout(id); };

Damoo.prototype.show = function() {
this.canvas.parent.appendChild(this.canvas.layer);
};
Expand All @@ -70,7 +80,7 @@
this.thread.empty();
};

Damoo.prototype.start = function() {
var _render = function() {
this.canvas.clear();
for (var i = 0; i < this.thread.length; i++) {
var d = this.thread.get(i),
Expand All @@ -82,13 +92,29 @@
this.thread.remove(i);
}
}
_RAF(function(self) {
this.afid = _RAF(function(self) {
return function() {
self.start();
_render.call(self);
};
}(this));
};

Damoo.prototype.start = function() {
if (!this.state) {
_render.call(this);
this.state = 1;
}
};

Damoo.prototype.suspend = function() {
_CAF(this.afid);
this.state = 0;
};

Damoo.prototype.resume = function() {
this.start();
};

var Canvas = function(m, n, r, t) {
this.parent = Damoo.dom.getElementById(m);
this.parent.style.position = "relative";
Expand Down
15 changes: 8 additions & 7 deletions damoo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6bddca5

Please sign in to comment.