Added Phaser.Filter and started moving the shaders over into their own filter classes, so they won't all get bundled in unless needed.

This commit is contained in:
photonstorm
2013-11-21 05:00:07 +00:00
parent e32c127a97
commit 496639ff25
39 changed files with 985 additions and 344 deletions
+20
View File
@@ -288,6 +288,26 @@ Phaser.GameObjectFactory.prototype = {
return new Phaser.BitmapData(this.game, width, height);
},
/**
* A WebGL shader/filter that can be applied to Sprites.
*
* @method Phaser.GameObjectFactory#filter
* @param {string} filter - The name of the filter you wish to create, for example "HueRotate" or "SineWave"
* @param {...} - Whatever parameters are needed to be passed to the filter init function.
* @return {Phaser.Filter} The newly created Phaser.Filter object.
*/
filter: function (filter) {
var args = Array.prototype.splice.call(arguments, 1);
var f = new Phaser.Filter[filter](this.game);
f.init.apply(f, args);
return f;
}
};
+6 -1
View File
@@ -118,11 +118,16 @@ Phaser.Sprite = function (game, x, y, key, frame) {
}
else
{
if (key == null || this.game.cache.checkImageKey(key) == false)
if (key === null || typeof key === 'undefined')
{
key = '__default';
this.key = key;
}
else if (typeof key === 'string' && this.game.cache.checkImageKey(key) == false)
{
key = '__missing';
this.key = key;
}
PIXI.Sprite.call(this, PIXI.TextureCache[key]);