Jump to content

How to add a text value


newbie11
 Share

Recommended Posts

Hi!

can anyone tell me how to put some value on my "score" i already use 

if (playState.score <= 3){
        game.add.text(20, 20, "practice more",{font: '50px Sports World', fill: '#b7e2fe'});

but it doenst work 

 

var winState = {
    
    create: function () {
        
     game.add.tileSprite( 0, 0, 1000, 490, "background3")

        
  if (playState.score >= loadState.hiscore) {
    loadState.hiscore = playState.score;
}
    
var hiscoreLabel = game.add.text(473, 155, loadState.hiscore, {font: '50px Sports World', fill: '#fdf59e'});   
    var scoreLabel = game.add.text(473, 243, playState.score, {font: '50px Sports World', fill: '#b7e2fe'});; 
    

    var spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
    spaceKey.onDown.addOnce (this.restart, this);
    var escKey = game.input.keyboard.addKey(Phaser.Keyboard.ESC)
    escKey.onDown.addOnce (this.menus, this);
        
    },
    restart: function (){
        game.state.start('play');
    },
    
    menus: function (){
        
        game.state.start('menu');
    },
    
    
    
    }

thats my code pls help me thank you! 

Link to comment
Share on other sites

Can you explain again what you're trying to do? I don't understand your question. 

If you're trying to do what I think you are, first a textfield  and then just update/change it depending on the score. Right now you're trying to add a text field without associating it with a variable. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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