Jump to content

Blinking Tile


fubeca6
 Share

Recommended Posts

Good Evening,

 

I'm trying to create a blinking tile. Here's what I have so far:

function create() {	this.timer = game.time.create(false);	this.timer.loop(1000, updateCounter, this);	this.timer.start();}function updateCounter() {	if (this.burn) {		this.burn.kill();	} else {		createBurn();	}}function createBurn() {	this.burn = game.add.sprite(224, 352, 'burn');	game.physics.enable(this.burn, Phaser.Physics.ARCADE);	this.burn.body.immovable = true;}

However, when I run this, it simply creates the tile over and over without ever killing it  -____-   I've toyed around a lot with the Phaser Timer examples, etc. but haven't been able to get it quite right.

 

Any help would be greatly appreciated!

 

Thanks

Link to comment
Share on other sites

Thanks Dumtard, that did it!  My overall code looks like this now (for anyone else with a similar problem):

function create() {	this.burn = game.add.sprite(224, 352, 'burn');	game.physics.enable(this.burn, Phaser.Physics.ARCADE);	this.burn.body.immovable = true;	this.timer = game.time.create(false);	this.timer.loop(1000, updateCounter, this);	this.timer.start();} function updateCounter() {	if (this.burn.exists) {		this.burn.kill();	} else {		this.burn.revive();	}}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...