Americkan

Update Score

Recommended Posts

Hey guys.

I am making a little quiz form and I ran into some trouble.

 

I would like the score to be updated depending on whether they got the question right or wrong.

I am new to phaser and would like guidance as to how to do so.

 

Ty.

QUESTION.PNG

Share this post


Link to post
Share on other sites
var score = null// move score outside of create

function create() {
  ...
  score = game.add.text(...)
}

function firstResponse() {
  ...
  // on good answer
  count += 1;
  score.text = "Score:" + count;
}

function secondResponse() {
  ...
  // on bad answer
  count -= 1;
  score.text = "Score:" + count;
}

You need some global accessible label so you can update its content after clicking anwser

 

Share this post


Link to post
Share on other sites
2 hours ago, Xesenix said:

var score = null// move score outside of create

function create() {
  ...
  score = game.add.text(...)
}

function firstResponse() {
  ...
  // on good answer
  count += 1;
  score.text = "Score:" + count;
}

function secondResponse() {
  ...
  // on bad answer
  count -= 1;
  score.text = "Score:" + count;
}

You need some global accessible label so you can update its content after clicking anwser

 

Thank you very much for the help! :) It worked and you've helped me greatly. +1

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


  • Recently Browsing   0 members

    No registered users viewing this page.