Jump to content

Update Score


Americkan
 Share

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

Link to comment
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

 

Link to comment
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

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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