Comparing version 0.4.0 to 0.4.1
@@ -10,7 +10,6 @@ var resources = require('./lib/resources'); | ||
Batch: require('./lib/batch'), | ||
resources: resources, | ||
onReady: resources.onReady, | ||
animations: resources.animations, | ||
spritesheet: resources.spritesheet, | ||
}; | ||
resources.bootstrap(); |
@@ -12,3 +12,2 @@ var vec2d = require('vec2d'); | ||
module.exports = Engine; | ||
Engine.getImage = getImage; | ||
@@ -26,14 +25,2 @@ var targetFps = 60; | ||
function getImage(name, frameIndex){ | ||
if (frameIndex == null) frameIndex = 0; | ||
var anim = resources.animations[name]; | ||
var buffer = document.createElement('canvas'); | ||
var frame = anim.frames[frameIndex]; | ||
buffer.width = frame.size.x; | ||
buffer.height = frame.size.y; | ||
var context = buffer.getContext('2d'); | ||
context.drawImage(resources.spritesheet, frame.pos.x, frame.pos.y, frame.size.x, frame.size.y, 0, 0, frame.size.x, frame.size.y); | ||
return buffer; | ||
} | ||
util.inherits(Engine, EventEmitter); | ||
@@ -40,0 +27,0 @@ function Engine(canvas) { |
@@ -9,2 +9,3 @@ var vec2d = require('vec2d'); | ||
var animationsJsonDone = false; | ||
var alreadyStarted = false; | ||
@@ -16,2 +17,3 @@ exports.bootstrap = bootstrap; | ||
exports.useSpritesheet = true; | ||
exports.getImage = getImage; | ||
@@ -27,2 +29,6 @@ function onReady(cb) { | ||
function bootstrap(){ | ||
// don't bootstrap twice | ||
if (alreadyStarted) return; | ||
alreadyStarted = true; | ||
// give the app a chance to skip spritesheet loading | ||
@@ -79,1 +85,18 @@ setTimeout(loadSpritesheet); | ||
} | ||
function getImage(name, frameIndex){ | ||
if (frameIndex == null) frameIndex = 0; | ||
var anim = exports.animations[name]; | ||
var buffer = document.createElement('canvas'); | ||
var frame = anim.frames[frameIndex]; | ||
buffer.width = frame.size.x; | ||
buffer.height = frame.size.y; | ||
var context = buffer.getContext('2d'); | ||
context.drawImage(exports.spritesheet, | ||
frame.pos.x, frame.pos.y, | ||
frame.size.x, frame.size.y, | ||
0, 0, | ||
frame.size.x, frame.size.y); | ||
return buffer; | ||
} | ||
@@ -5,3 +5,3 @@ { | ||
"author": "Andrew Kelley <superjoe30@gmail.com>", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
@@ -587,2 +587,9 @@ chem - html5 game engine optimized for rapid development | ||
### 0.4.1 | ||
* `chem.getImage` moved to `chem.resources.getImage` | ||
* `chem.animations` moved to `chem.resources.animations` | ||
* `chem.spritesheet` moved to `chem.resources.spritesheet` | ||
* fix double bootstrap bug | ||
### 0.4.0 | ||
@@ -589,0 +596,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33625
595
637
0