Jump to content

A count with timer that reduce heal


xun
 Share

Recommended Posts

Hello everybody,

 

I just learn phaser and i decide to create a virtual pet to test and learn.

For the moment i need to create a count that decrease pet's life using time. But i didn't really understand  Mhhm i just found i think ;)

 

I try to screen the count loop but it seems to not clear the number before. I put the exemple if you need to test:

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>pet prototype</title><script src="js/phaser.min.js"></script></head><body><script type="text/javascript">var game = new Phaser.Game(320, 480, Phaser.AUTO, "pet", { preload: preload, create: create, update: update });mam=100;var pet = function (petname, heal) {        this.petname = petname;        this.heal = heal;                this.screen_stats = function() {            var style = { font: "30px Arial", fill: "#FFFFFF", align: "center" };            var text = this.petname + " " + this.heal;            game.add.text(game.world.centerX-144, 0, text, style);                    }    }// testreduceStats = function () {        mam = mam-1;        tamagotest.heal = tamagotest.heal -1;        this.screen = function() {            var style = { font: "30px Arial", fill: "#FFFFFF", align: "center" };            game.add.text(game.world.centerX-144, 50, mam, style);            }}var tamagotest = new pet ("tamagotest","100","80")var reduceStatstest = new reduceStats ()// ---function preload() {}//End preloadfunction create() {    game.stage.backgroundColor = '#BAC4CD';    reduce_life = game.time.events.loop(Phaser.Timer.SECOND , reduceStats, this);    reduce_life.timer.start();    }//End createfunction update() {        tamagotest.screen_stats();    reduceStatstest.screen();}// End update</script></body></html>

Any idea ? Thanks for your response.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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