mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Added Text.destroy and BitmapText.destroy.
This commit is contained in:
@@ -123,6 +123,8 @@ Version 1.0.7 (in progress in the dev branch)
|
||||
* Fixed an issue where creating an animation with just one frame with an index of zero would cause a UUID error (thanks SYNYST3R1)
|
||||
* Fixed Rectangle.union (thanks andron77)
|
||||
* Debug.renderSpriteBody updated to use a the new Sprite.Body.screenX/Y properties.
|
||||
* Added Text.destroy() and BitmapText.destroy(), also updated Group.remove to make it more bullet-proof when an element doesn't have any events.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create });
|
||||
|
||||
function create() {
|
||||
@@ -19,8 +17,6 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$title = "Removing Text";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create });
|
||||
|
||||
var text;
|
||||
|
||||
function create() {
|
||||
|
||||
text = game.add.text(game.world.centerX, game.world.centerY, "- phaser -\nclick to remove", { font: "65px Arial", fill: "#ff0044", align: "center" });
|
||||
text.anchor.setTo(0.5, 0.5);
|
||||
|
||||
game.input.onDown.addOnce(removeText, this);
|
||||
|
||||
}
|
||||
|
||||
function removeText() {
|
||||
|
||||
// game.world.remove(text);
|
||||
text.destroy();
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
+6
-1
@@ -936,8 +936,13 @@ Phaser.Group.prototype = {
|
||||
*/
|
||||
remove: function (child) {
|
||||
|
||||
child.events.onRemovedFromGroup.dispatch(child, this);
|
||||
if (child.events)
|
||||
{
|
||||
child.events.onRemovedFromGroup.dispatch(child, this);
|
||||
}
|
||||
|
||||
this._container.removeChild(child);
|
||||
|
||||
child.group = null;
|
||||
|
||||
},
|
||||
|
||||
@@ -145,6 +145,32 @@ Phaser.BitmapText.prototype.update = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Phaser.Text.prototype.destroy
|
||||
*/
|
||||
Phaser.BitmapText.prototype.destroy = function() {
|
||||
|
||||
if (this.group)
|
||||
{
|
||||
this.group.remove(this);
|
||||
}
|
||||
|
||||
if (this.canvas.parentNode)
|
||||
{
|
||||
this.canvas.parentNode.removeChild(this.canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.canvas = null;
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
|
||||
this.group = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
|
||||
+26
-1
@@ -114,7 +114,6 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
|
||||
Phaser.Text.prototype.constructor = Phaser.Text;
|
||||
|
||||
|
||||
/**
|
||||
* Automatically called by World.update.
|
||||
* @method Phaser.Text.prototype.update
|
||||
@@ -140,6 +139,32 @@ Phaser.Text.prototype.update = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Phaser.Text.prototype.destroy
|
||||
*/
|
||||
Phaser.Text.prototype.destroy = function() {
|
||||
|
||||
if (this.group)
|
||||
{
|
||||
this.group.remove(this);
|
||||
}
|
||||
|
||||
if (this.canvas.parentNode)
|
||||
{
|
||||
this.canvas.parentNode.removeChild(this.canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.canvas = null;
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
|
||||
this.group = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
|
||||
Reference in New Issue
Block a user