Sign in to follow this  

How to add a text value

Recommended Posts


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 (){
    menus: function (){

thats my code pls help me thank you! 

Share this post

Link to post
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. 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.