mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
You can now set the Stage.backgroundColor using either hex or numeric values.
This commit is contained in:
parent
cfa2c96637
commit
d026f968de
4 changed files with 54 additions and 11 deletions
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue