diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 669bdb5..0105965 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -197,6 +197,12 @@ { this.scale.y = this._height / this.texture.frame.height; } + + if (this.texture.rotation) { + this.rotation = this.texture.rotation; + // this.pivot.x = this.texture.spritePivot.x; + // this.pivot.y = this.texture.spritePivot.y; + } }; Sprite.prototype._renderWebGL = function (renderer) diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 669bdb5..0105965 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -197,6 +197,12 @@ { this.scale.y = this._height / this.texture.frame.height; } + + if (this.texture.rotation) { + this.rotation = this.texture.rotation; + // this.pivot.x = this.texture.spritePivot.x; + // this.pivot.y = this.texture.spritePivot.y; + } }; Sprite.prototype._renderWebGL = function (renderer) diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 6eed011..3198a53 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -105,6 +105,20 @@ */ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); + /** + * The pivot point to used for a sprite this texture belongs to. + * + * @member {Point} + */ + this.spritePivot = new math.Point(); + + /** + * The rotation value of the texture, copied to a sprite when assigned to it. + * + * @member {number} + */ + this.rotation = 0; + if (baseTexture.hasLoaded) { if (this.noFrame) diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 669bdb5..0105965 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -197,6 +197,12 @@ { this.scale.y = this._height / this.texture.frame.height; } + + if (this.texture.rotation) { + this.rotation = this.texture.rotation; + // this.pivot.x = this.texture.spritePivot.x; + // this.pivot.y = this.texture.spritePivot.y; + } }; Sprite.prototype._renderWebGL = function (renderer) diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 6eed011..3198a53 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -105,6 +105,20 @@ */ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); + /** + * The pivot point to used for a sprite this texture belongs to. + * + * @member {Point} + */ + this.spritePivot = new math.Point(); + + /** + * The rotation value of the texture, copied to a sprite when assigned to it. + * + * @member {number} + */ + this.rotation = 0; + if (baseTexture.hasLoaded) { if (this.noFrame) diff --git a/src/loaders/bitmapFontParser.js b/src/loaders/bitmapFontParser.js index d12425e..e3e522f 100644 --- a/src/loaders/bitmapFontParser.js +++ b/src/loaders/bitmapFontParser.js @@ -20,8 +20,10 @@ } } + var name = resource.data.nodeName; + // skip if no data - if (!resource.data) + if (!resource.data || !name || name.toLowerCase() !== '#document' || name.toLowerCase() !== 'div') { return next(); } diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 669bdb5..0105965 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -197,6 +197,12 @@ { this.scale.y = this._height / this.texture.frame.height; } + + if (this.texture.rotation) { + this.rotation = this.texture.rotation; + // this.pivot.x = this.texture.spritePivot.x; + // this.pivot.y = this.texture.spritePivot.y; + } }; Sprite.prototype._renderWebGL = function (renderer) diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 6eed011..3198a53 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -105,6 +105,20 @@ */ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); + /** + * The pivot point to used for a sprite this texture belongs to. + * + * @member {Point} + */ + this.spritePivot = new math.Point(); + + /** + * The rotation value of the texture, copied to a sprite when assigned to it. + * + * @member {number} + */ + this.rotation = 0; + if (baseTexture.hasLoaded) { if (this.noFrame) diff --git a/src/loaders/bitmapFontParser.js b/src/loaders/bitmapFontParser.js index d12425e..e3e522f 100644 --- a/src/loaders/bitmapFontParser.js +++ b/src/loaders/bitmapFontParser.js @@ -20,8 +20,10 @@ } } + var name = resource.data.nodeName; + // skip if no data - if (!resource.data) + if (!resource.data || !name || name.toLowerCase() !== '#document' || name.toLowerCase() !== 'div') { return next(); } diff --git a/src/loaders/spritesheetParser.js b/src/loaders/spritesheetParser.js index 2d778b7..859633a 100644 --- a/src/loaders/spritesheetParser.js +++ b/src/loaders/spritesheetParser.js @@ -1,4 +1,5 @@ var Resource = require('resource-loader').Resource, + path = require('path'), core = require('../core'); module.exports = function () @@ -13,8 +14,10 @@ loadType: Resource.LOAD_TYPE.IMAGE }; + var route = path.dirname(resource.url.replace(this.baseUrl, '')); + // load the image for this sheet - this.loadResource(new Resource(this.baseUrl + resource.data.meta.image, loadOptions), function (res) + this.loadResource(new Resource(this.baseUrl + route + '/' + resource.data.meta.image, loadOptions), function (res) { resource.textures = {}; @@ -26,9 +29,16 @@ if (rect) { - var size = new core.math.Rectangle(rect.x, rect.y, rect.w, rect.h); + var size = null; var trim = null; + if (frames[i].rotated) { + size = new core.math.Rectangle(rect.x, rect.y, rect.h, rect.w); + } + else { + size = new core.math.Rectangle(rect.x, rect.y, rect.w, rect.h); + } + // Check to see if the sprite is trimmed if (frames[i].trimmed) { @@ -41,6 +51,12 @@ } resource.textures[i] = new core.Texture(res.texture.baseTexture, size, size.clone(), trim); + + if (frames[i].rotated) { + resource.textures[i].spritePivot.x = frames[i].pivot.x; + resource.textures[i].spritePivot.y = frames[i].pivot.y; + resource.textures[i].rotation = -Math.PI / 2; + } } }