mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 14:40:38 +00:00
* When a Sprite is destroyed any active filters are removed as well.
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
This commit is contained in:
parent
8f14483b60
commit
c5c754725a
4 changed files with 35 additions and 23 deletions
|
@ -50,14 +50,16 @@ New features:
|
||||||
|
|
||||||
Updates:
|
Updates:
|
||||||
|
|
||||||
* TBC
|
* When a Sprite is destroyed any active filters are removed as well.
|
||||||
|
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
|
||||||
|
* Phaser.Canvas.create updated to it can be given an ID as the 3rd parameter.
|
||||||
|
|
||||||
Bug Fixes:
|
Bug Fixes:
|
||||||
|
|
||||||
* Cache.getImageKeys returned __missing in the array, now excluded.
|
* Cache.getImageKeys returned __missing in the array, now excluded.
|
||||||
* Fixed Group.scale so you can now scale a Group directly.
|
* Fixed Group.scale so you can now scale a Group directly.
|
||||||
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
|
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
|
||||||
|
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
|
||||||
|
|
||||||
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ function preload() {
|
||||||
function create() {
|
function create() {
|
||||||
|
|
||||||
|
|
||||||
|
logo = game.add.sprite(game.world.centerX, game.world.centerY, 'phaser');
|
||||||
|
logo.anchor.setTo(0.5, 0.5);
|
||||||
|
|
||||||
background = game.add.sprite(0, 0);
|
background = game.add.sprite(0, 0);
|
||||||
background.width = 800;
|
background.width = 800;
|
||||||
background.height = 600;
|
background.height = 600;
|
||||||
|
@ -24,8 +27,6 @@ function create() {
|
||||||
|
|
||||||
background.filters = [filter];
|
background.filters = [filter];
|
||||||
|
|
||||||
logo = game.add.sprite(game.world.centerX, game.world.centerY, 'phaser');
|
|
||||||
logo.anchor.setTo(0.5, 0.5);
|
|
||||||
|
|
||||||
game.input.onDown.add(removeBackground, this);
|
game.input.onDown.add(removeBackground, this);
|
||||||
|
|
||||||
|
@ -41,7 +42,10 @@ function removeBackground() {
|
||||||
|
|
||||||
console.log('removeBackground');
|
console.log('removeBackground');
|
||||||
|
|
||||||
// background.destroy();
|
|
||||||
background.removeFilter(filter);
|
// background.filters = null;
|
||||||
|
background.destroy();
|
||||||
|
|
||||||
|
// console.log(background.filters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -840,6 +840,11 @@ Phaser.Sprite.prototype.kill = function() {
|
||||||
*/
|
*/
|
||||||
Phaser.Sprite.prototype.destroy = function() {
|
Phaser.Sprite.prototype.destroy = function() {
|
||||||
|
|
||||||
|
if (this.filters)
|
||||||
|
{
|
||||||
|
this.filters = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.group)
|
if (this.group)
|
||||||
{
|
{
|
||||||
this.group.remove(this);
|
this.group.remove(this);
|
||||||
|
@ -860,13 +865,6 @@ Phaser.Sprite.prototype.destroy = function() {
|
||||||
this.animations.destroy();
|
this.animations.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._filters)
|
|
||||||
{
|
|
||||||
console.log('removeFilter', this._filters);
|
|
||||||
this.removeFilter(this._filters);
|
|
||||||
console.log(this._filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.alive = false;
|
this.alive = false;
|
||||||
this.exists = false;
|
this.exists = false;
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
|
|
@ -13,21 +13,29 @@
|
||||||
Phaser.Canvas = {
|
Phaser.Canvas = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the <canvas> tag
|
* Creates a `canvas` DOM element. The element is not automatically added to the document.
|
||||||
*
|
*
|
||||||
* @method Phaser.Canvas.create
|
* @method Phaser.Canvas.create
|
||||||
* @param {number} width - The desired width.
|
* @param {number} [width=256] - The width of the canvas element.
|
||||||
* @param {number} height - The desired height.
|
* @param {number} [height=256] - The height of the canvas element..
|
||||||
* @return {HTMLCanvasElement} The newly created <canvas> tag.
|
* @param {string} [id=''] - If given this will be set as the ID of the canvas element, otherwise no ID will be set.
|
||||||
|
* @return {HTMLCanvasElement} The newly created canvas element.
|
||||||
*/
|
*/
|
||||||
create: function (width, height) {
|
create: function (width, height, id) {
|
||||||
|
|
||||||
width = width || 256;
|
width = width || 256;
|
||||||
height = height || 256;
|
height = height || 256;
|
||||||
|
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
|
|
||||||
|
if (typeof id === 'string')
|
||||||
|
{
|
||||||
|
canvas.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
canvas.width = width;
|
canvas.width = width;
|
||||||
canvas.height = height;
|
canvas.height = height;
|
||||||
|
|
||||||
canvas.style.display = 'block';
|
canvas.style.display = 'block';
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
|
@ -137,7 +145,7 @@ Phaser.Canvas = {
|
||||||
*
|
*
|
||||||
* @method Phaser.Canvas.addToDOM
|
* @method Phaser.Canvas.addToDOM
|
||||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||||
* @param {string|HTMLElement} parent - The DOM element to add the canvas to. Defaults to ''.
|
* @param {string|HTMLElement} parent - The DOM element to add the canvas to.
|
||||||
* @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
* @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||||
*/
|
*/
|
||||||
|
@ -149,14 +157,14 @@ Phaser.Canvas = {
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
{
|
{
|
||||||
// hopefully an element ID
|
|
||||||
if (typeof parent === 'string')
|
if (typeof parent === 'string')
|
||||||
{
|
{
|
||||||
|
// hopefully an element ID
|
||||||
target = document.getElementById(parent);
|
target = document.getElementById(parent);
|
||||||
}
|
}
|
||||||
// quick test for a HTMLelement
|
|
||||||
else if (typeof parent === 'object' && parent.nodeType === 1)
|
else if (typeof parent === 'object' && parent.nodeType === 1)
|
||||||
{
|
{
|
||||||
|
// quick test for a HTMLelement
|
||||||
target = parent;
|
target = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +174,8 @@ Phaser.Canvas = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback, covers an invalid ID and a none HTMLelement object
|
// Fallback, covers an invalid ID and a non HTMLelement object
|
||||||
if(!target)
|
if (!target)
|
||||||
{
|
{
|
||||||
target = document.body;
|
target = document.body;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue