-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
251 additions
and
26 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{"frames": { | ||
|
||
"0.png": | ||
{ | ||
"frame": {"x":14,"y":28,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"1.png": | ||
{ | ||
"frame": {"x":14,"y":42,"w":12,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":12,"h":14}, | ||
"sourceSize": {"w":12,"h":14} | ||
}, | ||
"2.png": | ||
{ | ||
"frame": {"x":14,"y":14,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"3.png": | ||
{ | ||
"frame": {"x":42,"y":0,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"4.png": | ||
{ | ||
"frame": {"x":28,"y":0,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"5.png": | ||
{ | ||
"frame": {"x":14,"y":0,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"6.png": | ||
{ | ||
"frame": {"x":0,"y":42,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"7.png": | ||
{ | ||
"frame": {"x":0,"y":28,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"8.png": | ||
{ | ||
"frame": {"x":0,"y":14,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}, | ||
"9.png": | ||
{ | ||
"frame": {"x":0,"y":0,"w":14,"h":14}, | ||
"rotated": false, | ||
"trimmed": false, | ||
"spriteSourceSize": {"x":0,"y":0,"w":14,"h":14}, | ||
"sourceSize": {"w":14,"h":14} | ||
}}, | ||
"meta": { | ||
"app": "http://www.texturepacker.com", | ||
"version": "1.0", | ||
"image": "hud.png", | ||
"format": "RGBA8888", | ||
"size": {"w":64,"h":64}, | ||
"scale": "1", | ||
"smartupdate": "$TexturePacker:SmartUpdate:47025c98c8b10634b75172d4ed7e7edc$" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function spritesheetMiddleware() | ||
{ | ||
return function (resource, next) | ||
{ | ||
// skip if no data, its not json, or it isn't spritesheet data | ||
if (!resource.data || !resource.isJson || !resource.data.frames) | ||
{ | ||
return next(); | ||
} | ||
|
||
var loadOptions = { | ||
crossOrigin: resource.crossOrigin, | ||
loadType: Resource.LOAD_TYPE.IMAGE | ||
}; | ||
|
||
var route = dirname(resource.url.replace(this.baseUrl, '')); | ||
|
||
// load the image for this sheet | ||
this.add(resource.name + '_image', route + '/' + resource.data.meta.image, loadOptions, function (res) | ||
{ | ||
next(); | ||
}); | ||
}; | ||
}; | ||
|
||
|
||
function dirname(path) { | ||
var result = posixSplitPath(path), | ||
root = result[0], | ||
dir = result[1]; | ||
|
||
if (!root && !dir) { | ||
// No dirname whatsoever | ||
return '.'; | ||
} | ||
|
||
if (dir) { | ||
// It has a dirname, strip trailing slash | ||
dir = dir.substr(0, dir.length - 1); | ||
} | ||
|
||
return root + dir; | ||
} | ||
|
||
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; | ||
|
||
function posixSplitPath(filename) { | ||
return splitPathRe.exec(filename).slice(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
{ | ||
"framework" : "mocha", | ||
"launch_in_dev" : ["Chrome"], | ||
"launch_in_ci" : ["Firefox"], | ||
"src_files" : [ | ||
"node_modules/chai/chai.js", | ||
"node_modules/sinon/pkg/sinon.js", | ||
"node_modules/sinon-chai/lib/sinon-chai.js", | ||
"framework": "mocha+chai", | ||
"launch_in_dev": ["Chrome"], | ||
"launch_in_ci": ["Firefox"], | ||
"src_files": [ | ||
"dist/resource-loader.js", | ||
"test/unit/**/*.test.js" | ||
], | ||
"serve_files": [ | ||
"node_modules/sinon/pkg/sinon.js", | ||
"node_modules/sinon-chai/lib/sinon-chai.js", | ||
|
||
"dist/asset-loader.js", | ||
"test/setup.js", | ||
"test/unit/**/*.test.js" | ||
] | ||
"dist/resource-loader.js", | ||
|
||
"test/setup.js", | ||
"test/fixtures/spritesheetMiddleware.js", | ||
|
||
"test/unit/**/*.test.js" | ||
], | ||
"routes": { | ||
"/fixtures": "test/fixtures" | ||
} | ||
} |