Huge update to Phaser.Text. Much more lean, but loads of great new options added including drop shadows, gradient fills, fonts with spaces in the name, etc.

This commit is contained in:
photonstorm
2014-02-09 13:36:02 +00:00
parent 4aa945f991
commit bca64c2adb
10 changed files with 682 additions and 170 deletions
+49
View File
@@ -0,0 +1,49 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }, false);
function preload() {
game.load.image('pic', 'assets/pics/backscroll.png');
}
var sprite;
var sprite2;
var g;
var p;
function create() {
game.stage.backgroundColor = '#ff5500';
game.renderer.useFillRect = false;
sprite = game.add.sprite(0.5, 0, 'pic');
sprite2 = game.add.sprite(0, 300, 'pic');
game.input.onDown.add(tint, this);
// game.add.tween(sprite).to({y: 500}, 3000, Phaser.Easing.Linear.None, true);
// p = new PIXI.Point(43, 45);
}
function tint() {
sprite.destroy();
// sprite.tint = Math.random() * 0xFFFFFF;
// sprite2.tint = Math.random() * 0xFFFFFF;
}
function update() {
}
function render() {
// game.debug.renderText(sprite.position.y, 32, 32);
}
+4 -2
View File
@@ -14,7 +14,9 @@ var p;
function create() {
// game.stage.backgroundColor = '#ff5500';
game.stage.backgroundColor = '#ff5500';
game.renderer.useFillRect = false;
sprite = game.add.sprite(0.5, 0, 'pic');
@@ -29,7 +31,7 @@ function create() {
// game.input.onDown.add(tint, this);
// game.add.tween(sprite).to({y: 500}, 3000, Phaser.Easing.Linear.None, true);
game.add.tween(sprite).to({y: 500}, 3000, Phaser.Easing.Linear.None, true);
p = new PIXI.Point(43, 45);
+60
View File
@@ -0,0 +1,60 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }, false);
// var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create, update: update, render: render }, false);
function preload() {
game.load.image('pic', 'assets/pics/backscroll.png');
}
var text;
function create() {
game.stage.backgroundColor = '#c48844';
text = game.add.text(game.world.centerX, game.world.centerY, "- phaser -\nwith a sprinkle of\npixi dust");
text.anchor.setTo(0.5);
text.font = 'Art of Fighting 2';
// text.font = 'Arial';
text.fontSize = 40;
// text.fontWeight = 'bold italic';
// x0, y0 - x1, y1
var grd = text.context.createLinearGradient(0, 0, 0, text.canvas.height);
grd.addColorStop(0, '#8ED6FF');
grd.addColorStop(1, '#004CB3');
// text.fill = '#ff0044';
// text.lineSpacing = 16;
text.fill = grd;
text.align = 'center';
text.stroke = '#ff00ff';
text.strokeThickness = 2;
text.setShadow(5, 5, 'rgba(0,0,0,0.5)', 5);
game.input.onDown.add(change, this);
}
function change() {
text.tint = Math.random() * 0xFFFFFF;
}
function update() {
}
function render() {
// game.debug.renderText(sprite.position.y, 32, 32);
}