Cache.addBitmapData has a new parameter: frameData allowing you to pass a Phaser.FrameData object along with the BitmapData.

Cache.getFrameData has a new parameter: `map` which allows you to specify which cache to get the FrameData from, i.e. `Phaser.Cache.IMAGE` or `Phaser.Cache.BITMAPDATA`.
Sprite.loadTexture if given a BitmapData as the texture will now query the cache to see if it has any associated FrameData, and if so it will load that into the AnimationManager.
This commit is contained in:
photonstorm 2014-10-01 03:10:13 +01:00
parent 26f9e05dca
commit d65c526184
4 changed files with 17 additions and 6 deletions

View file

@ -89,6 +89,9 @@ Version 2.1.2 - "Whitebridge" - in development
* Text.clearColors resets any previously set colors from `Text.addColor`.
* If you pass a tinted Sprite to `BitmapData.draw` or `BitmapData.copy` it will now draw the tinted version of the Sprite to the BitmapData and not the original texture.
* BitmapData.shadow(color, blur, x, y) provides a quick way to set all the relevant shadow settings, which are then be used in future draw calls.
* Cache.addBitmapData has a new parameter: `frameData` allowing you to pass a `Phaser.FrameData` object along with the BitmapData.
* Cache.getFrameData has a new parameter: `map` which allows you to specify which cache to get the FrameData from, i.e. `Phaser.Cache.IMAGE` or `Phaser.Cache.BITMAPDATA`.
* Sprite.loadTexture if given a BitmapData as the texture will now query the cache to see if it has any associated FrameData, and if so it will load that into the AnimationManager.

View file

@ -1074,6 +1074,7 @@ Phaser.BitmapData.prototype = {
/**
* Sets the shadow properties of this BitmapDatas context which will affect all draw operations made to it.
* You can cancel an existing shadow by calling this method and passing no parameters.
* Note: At the time of writing (October 2014) Chrome still doesn't support shadowBlur used with drawImage.
*
* @method Phaser.BitmapData#shadow
* @param {string} color - The color of the shadow, given in a CSS format, i.e. `#000000` or `rgba(0,0,0,1)`. If `null` or `undefined` the shadow will be reset.

View file

@ -379,6 +379,7 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) {
{
// This works from a reference, which probably isn't what we need here
this.setTexture(key.texture);
setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key.key, Phaser.Cache.BITMAPDATA), frame);
}
else if (key instanceof PIXI.Texture)
{

View file

@ -226,11 +226,14 @@ Phaser.Cache.prototype = {
* @method Phaser.Cache#addBitmapData
* @param {string} key - Asset key for this BitmapData.
* @param {Phaser.BitmapData} bitmapData - The BitmapData object to be addded to the cache.
* @param {Phaser.FrameData} [frameData] - Optional FrameData set associated with the given BitmapData.
* @return {Phaser.BitmapData} The BitmapData object to be addded to the cache.
*/
addBitmapData: function (key, bitmapData) {
addBitmapData: function (key, bitmapData, frameData) {
this._bitmapDatas[key] = bitmapData;
bitmapData.key = key;
this._bitmapDatas[key] = { data: bitmapData, frameData: frameData };
return bitmapData;
@ -591,7 +594,7 @@ Phaser.Cache.prototype = {
if (this._bitmapDatas[key])
{
return this._bitmapDatas[key];
return this._bitmapDatas[key].data;
}
else
{
@ -904,13 +907,16 @@ Phaser.Cache.prototype = {
*
* @method Phaser.Cache#getFrameData
* @param {string} key - Asset key of the frame data to retrieve from the Cache.
* @param {string} [map=Phaser.Cache.IMAGE] - The asset map to get the frameData from, for example `Phaser.Cache.IMAGE`.
* @return {Phaser.FrameData} The frame data.
*/
getFrameData: function (key) {
getFrameData: function (key, map) {
if (this._images[key])
if (typeof map === 'undefined') { map = Phaser.Cache.IMAGE; }
if (this._cacheMap[map][key])
{
return this._images[key].frameData;
return this._cacheMap[map][key].frameData;
}
return null;