You can now set the Stage.backgroundColor using either hex or numeric values.

This commit is contained in:
photonstorm
2014-02-16 14:54:04 +00:00
parent cfa2c96637
commit d026f968de
4 changed files with 54 additions and 11 deletions
+22 -1
View File
@@ -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;
+12 -4
View File
@@ -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,