我已经设置了当玩家击中硬币时,应该添加一个点(实际上我可以看到它是通过跟踪添加的)但是 textField 没有更新。我做错了吗?顺便说一句,文本字段已经是动态的,我已经合并了字体。
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);
}
我也尝试过这种方法:
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);
}