diff --git a/examples/wip/anim1.js b/examples/wip/anim1.js index 04c438e0c..1262f3983 100644 --- a/examples/wip/anim1.js +++ b/examples/wip/anim1.js @@ -9,6 +9,9 @@ function preload() { function create() { + // game.stage.backgroundColor = '#239923'; + game.stage.backgroundColor = 0xff8855; + var mummy = game.add.sprite(300, 200, 'mummy', 5); mummy.animations.add('walk'); diff --git a/examples/wip/text tilesprite.js b/examples/wip/text tilesprite.js index 15ff31500..ebe3bb899 100644 --- a/examples/wip/text tilesprite.js +++ b/examples/wip/text tilesprite.js @@ -1,6 +1,6 @@ -// var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); -var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); +// var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); function preload() { @@ -13,6 +13,7 @@ var font; var i; var background; var filter; +var count = 0; function create() { @@ -27,16 +28,25 @@ function create() { background.filters = [filter]; font = game.add.bitmapFont('knightHawks', 31, 25, Phaser.BitmapFont.TEXT_SET6, 10, 1, 1); - font.text = 'phaser was here'; + font.text = 'phaser '; - i = game.add.image(0, 0, font); + // i = game.add.image(0, 0, font); - // sprite = game.add.tileSprite(0, 0, 800, 600, font); + sprite = game.add.tileSprite(0, 0, 800, 600, font); } function update() { + count += 0.005 + + sprite.tileScale.x = 2 + Math.sin(count); + sprite.tileScale.y = 2 + Math.cos(count); + + sprite.tilePosition.x += 1; + sprite.tilePosition.y += 1; + + // game.camera.view.x++; filter.update(); @@ -44,6 +54,7 @@ function update() { // Uncomment for coolness :) // filter.blueShift -= 0.001; - // font.text = "phaser x: " + game.input.x + " y: " + game.input.y; + font.text = " phaser x: " + game.input.x + " y: " + game.input.y; + sprite.refreshTexture = true; } diff --git a/src/core/Stage.js b/src/core/Stage.js index 7bdd84d38..350d12937 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -61,6 +61,12 @@ Phaser.Stage = function (game, width, height) { */ this._nextOffsetCheck = 0; + /** + * @property {number} _backgroundColor - Stage background color. + * @private + */ + this._backgroundColor; + if (game.config) { this.parseConfig(game.config); @@ -275,11 +281,26 @@ Phaser.Stage.prototype.visibilityChange = function (event) { } +/** +* Sets the background color for the stage. +* +* @name Phaser.Stage#setBackgroundColor +* @param {number} backgroundColor - The color of the background, easiest way to pass this in is in hex format like: 0xFFFFFF for white. +*/ +Phaser.Stage.prototype.setBackgroundColor = function(backgroundColor) +{ + this._backgroundColor = backgroundColor || 0x000000; + this.backgroundColorSplit = PIXI.hex2rgb(this.backgroundColor); + var hex = this._backgroundColor.toString(16); + hex = '000000'.substr(0, 6 - hex.length) + hex; + this.backgroundColorString = '#' + hex; +} + /** * @name Phaser.Stage#backgroundColor * @property {number|string} backgroundColor - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000' */ -Object.defineProperty(Phaser.Stage.prototype, "NEWbackgroundColor", { +Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { get: function () { return this._backgroundColor; diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index 91e10ec72..daeed234d 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -408,9 +408,17 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo) { if(isFrame) { - targetWidth = frame.width; - targetHeight = frame.height; - + if (texture.trim) + { + targetWidth = texture.trim.width; + targetHeight = texture.trim.height; + } + else + { + targetWidth = frame.width; + targetHeight = frame.height; + } + newTextureRequired = true; } @@ -443,7 +451,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo) this.tilingTexture.isTiling = true; } - + canvasBuffer.context.drawImage(texture.baseTexture.source, frame.x, frame.y,