https://github.com/hackergrrl/phaser-capture
Phaser (http://www.phaser.io) plugin for easily capturing screenshots (PNG, JPEG) and videos (GIF, WebM).
https://github.com/hackergrrl/phaser-capture
Last synced: 6 months ago
JSON representation
Phaser (http://www.phaser.io) plugin for easily capturing screenshots (PNG, JPEG) and videos (GIF, WebM).
- Host: GitHub
- URL: https://github.com/hackergrrl/phaser-capture
- Owner: hackergrrl
- License: mit
- Created: 2015-03-27T01:26:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-27T04:39:19.000Z (over 10 years ago)
- Last Synced: 2024-12-28T21:45:44.285Z (7 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 17
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Why?
Although each OS has their own set of tools for screenshots and video capture, I
wanted something platform agnostic that I could simply plug into whatever
web-based game I was making. This also lets me collect captures on computers
that I don't have software installation rights on.I chose [Phaser](http://www.phaser.io) in particular only because it's what I'm
already using most of the time, but I would like to eventually include a more
minimal module that does the core screenshot/recording work without being
coupled to Phaser.# Usage
The plugin is packaged via [UMD](https://github.com/umdjs/umd), meaning it'll
work happily used if included browser globally (via ``) or if you prefer Node or
[Browserify](http://browserify.org/).Unfortunately [Phaser plugins](http://phaser.io/docs/2.2.2/Phaser.Plugin.html)
are not very well documented, and most rely on their own ad-hoc documentation to
instruct their users. For now, `phaser-capture` is no different:```javascript
// var PhaserCapture = require('phaser-capture'); // For Node/Browserify usersvar playState = {
create: function() {
game.capture = game.plugins.add(Phaser.Plugin.Capture);
// game.capture = game.plugins.add(PhaserCapture); // Node/Browserify// Take a screenshot every 5 seconds.
setInterval(function() {
game.capture.screenshot(function(dataUrl) {
// Outputs a data-url of the image (default image/png).
console.log(dataUrl);
});
}, 5000);
},
};game = new Phaser.Game(800, 600);
game.state.add('play', playState);
game.state.start('play');
```# API
The resultant plugin exposes only one method currently:
### `screenshot(callback, opts)`
* `callback` is the function that will be called once the screenshot render is
complete. It assumes its only argument will be a data-url.
* `options` is an object that may contain:
* `format`, either `image/png` or `image/jpeg`# /THE FUTURE!/
1. Downloading screenshots easily
2. Uploading screenshots somewhere (Dropbox? Something more agnostic?)
3. Video recording! (GIF, WebM)