1.0.3 release - fixed Text and Bitmap Fonts, Animation documentation and more examples

This commit is contained in:
Richard Davey
2013-09-17 16:28:59 +01:00
parent f4734b1143
commit 3c5ea01e09
29 changed files with 1253 additions and 392 deletions
+5 -3
View File
@@ -19,10 +19,13 @@ Phaser.BitmapText = function (game, x, y, text, style) {
PIXI.BitmapText.call(this, text, style);
this.type = Phaser.BITMAPTEXT;
this.position.x = x;
this.position.y = y;
// Replaces the PIXI.Point with a slightly more flexible one
this.anchor = new Phaser.Point();
this.scale = new Phaser.Point(1, 1);
// Influence of camera movement upon the position
@@ -51,11 +54,10 @@ Phaser.BitmapText = function (game, x, y, text, style) {
};
Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
// Add our own custom methods
/**
* Automatically called by World.update
*/
+100 -19
View File
@@ -5,31 +5,112 @@ Phaser.Text = function (game, x, y, text, style) {
text = text || '';
style = style || '';
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
this.exists = true;
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
this.alive = true;
this.group = null;
this.name = '';
this.game = game;
PIXI.Text.call(this, text, style);
/*
this.canvas = document.createElement("canvas");
this.context = this.canvas.getContext("2d");
var canvasID = game.rnd.uuid();
PIXI.TextureCache[canvasID] = new PIXI.Texture(new PIXI.BaseTexture(this.canvas));
Phaser.Sprite.call(this, game, x, y, canvasID);
this.type = Phaser.TEXT;
this.setText(text);
this.setStyle(style);
this.updateText();
this.dirty = false;
*/
this.position.x = x;
this.position.y = y;
// Replaces the PIXI.Point with a slightly more flexible one
this.anchor = new Phaser.Point();
this.scale = new Phaser.Point(1, 1);
// Influence of camera movement upon the position
this.scrollFactor = new Phaser.Point(1, 1);
// A mini cache for storing all of the calculated values
this._cache = {
dirty: false,
// Transform cache
a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
// The previous calculated position inc. camera x/y and scrollFactor
x: -1, y: -1,
// The actual scale values based on the worldTransform
scaleX: 1, scaleY: 1
};
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
this.renderable = true;
};
// Phaser.Text.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Text.prototype);
Phaser.Text.prototype = Phaser.Utils.extend(true, PIXI.Text.prototype);
Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
Phaser.Text.prototype.constructor = Phaser.Text;
// Add our own custom methods
// Automatically called by World.update
Phaser.Text.prototype.update = function() {
if (!this.exists)
{
return;
}
this._cache.dirty = false;
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
if (this.position.x != this._cache.x || this.position.y != this._cache.y)
{
this.position.x = this._cache.x;
this.position.y = this._cache.y;
this._cache.dirty = true;
}
}
Object.defineProperty(Phaser.Text.prototype, 'angle', {
get: function() {
return Phaser.Math.radToDeg(this.rotation);
},
set: function(value) {
this.rotation = Phaser.Math.degToRad(value);
}
});
Object.defineProperty(Phaser.Text.prototype, 'x', {
get: function() {
return this.position.x;
},
set: function(value) {
this.position.x = value;
}
});
Object.defineProperty(Phaser.Text.prototype, 'y', {
get: function() {
return this.position.y;
},
set: function(value) {
this.position.y = value;
}
});