I have set this that when the player hits the coin, a point should be added (in fact I can see it is added trough the trace) but the textField is not updating. Did I do somthing wrong? Btw the text field is already Dynamic and I have incorporated the font.
coin.addEventListener(Event.ENTER_FRAME, addScore);
var score:Number = 0;
scoreCounter.text = "0";
function addScore (e) {
if (objPlayer.hitTestObject(coin)) {
updateScore();
trace("Score: " + score);
coin.x = - 1 - coin.width/2;
}
}
function updateScore() {
score++;
scoreCounter.text = String(score);
}
I’ve also tried with this approach:
coin.addEventListener(Event.ENTER_FRAME, addScore);
var score:int = 0;
function addScore (e) {
if (objPlayer.hitTestObject(coin)) {
score++;
updateScore();
trace("Score: " + score);
coin.x = - 1 - coin.width/2;
}
}
function updateScore():void {
scoreCounter.text = ("Score: " + score);
}
Looks like your code is fine. Your using a specific font (Arial), so you need to embed that font. Or, use the _sans font instead. Then it should work for you.