mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
bmd tweaks
This commit is contained in:
parent
38bd00b4ed
commit
ba6863bdf5
3 changed files with 41 additions and 12 deletions
|
@ -21,7 +21,7 @@ function create() {
|
|||
// And apply it to 100 randomly positioned sprites
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
bmd.setPixel(game.world.randomX, game.world.randomY, Math.random() * 255, Math.random() * 255, 255);
|
||||
//bmd.setPixel(game.world.randomX, game.world.randomY, 100 + Math.random() * 155, 100 + Math.random() * 155, 255);
|
||||
}
|
||||
|
||||
bmd.context.fillStyle = '#ffffff';
|
||||
|
@ -33,15 +33,20 @@ function create() {
|
|||
|
||||
function update() {
|
||||
|
||||
// bmd.clear();
|
||||
// bmd.context.fillRect(game.world.randomX,game.world.randomY,4,4);
|
||||
|
||||
// updateWobblyBall();
|
||||
//console.log('b');
|
||||
|
||||
|
||||
// bmd.setPixel(game.world.randomX, game.world.randomY, 250, 250, 250);
|
||||
|
||||
bmd.setPixel(game.input.x, game.input.y, 255, 255, 255);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function render() {
|
||||
|
||||
// bmd.render();
|
||||
bmd.render();
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,17 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the BitmapData isn't updated by the core game loop.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Group} group - The parent Group of this BitmapData.
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - The name of the BitmapData.
|
||||
*/
|
||||
|
@ -120,6 +131,8 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
*/
|
||||
this.globalCompositeOperation = null;
|
||||
|
||||
this._dirty = false;
|
||||
|
||||
}
|
||||
|
||||
Phaser.BitmapData.prototype = {
|
||||
|
@ -127,6 +140,8 @@ Phaser.BitmapData.prototype = {
|
|||
clear: function () {
|
||||
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
|
||||
this._dirty = true;
|
||||
|
||||
},
|
||||
|
||||
|
@ -157,6 +172,8 @@ Phaser.BitmapData.prototype = {
|
|||
this.imageData.data.set(this.data8);
|
||||
|
||||
this.context.putImageData(this.imageData, 0, 0);
|
||||
|
||||
this._dirty = true;
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -229,13 +246,18 @@ Phaser.BitmapData.prototype = {
|
|||
|
||||
},
|
||||
|
||||
render: function () {
|
||||
postUpdate: function () {
|
||||
|
||||
// Only needed if running in WebGL, otherwise this array will never get cleared down I don't think!
|
||||
if (this.game.renderType == Phaser.WEBGL)
|
||||
{
|
||||
PIXI.texturesToUpdate.push(this.baseTexture);
|
||||
}
|
||||
if (this._dirty)
|
||||
{
|
||||
// Only needed if running in WebGL, otherwise this array will never get cleared down I don't think!
|
||||
if (this.game.renderType == Phaser.WEBGL)
|
||||
{
|
||||
PIXI.texturesToUpdate.push(this.baseTexture);
|
||||
}
|
||||
|
||||
this._dirty = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -287,9 +287,11 @@ Phaser.GameObjectFactory.prototype = {
|
|||
*/
|
||||
bitmapData: function (key, width, height) {
|
||||
|
||||
var bmd = new Phaser.BitmapData(this.game, key, width, height);
|
||||
// var bmd = new Phaser.BitmapData(this.game, key, width, height);
|
||||
|
||||
return this.game.cache.addBitmapData(bmd.name, bmd);
|
||||
// return this.game.cache.addBitmapData(bmd.name, bmd);
|
||||
|
||||
return this.world.add(new Phaser.BitmapData(this.game, x, y, width, height, tileset, tilemap, layer));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue