createjs动态文本重叠

createjs dynamic text over lapping

本文关键字:重叠 文本 动态 createjs      更新时间:2023-09-26

我正在使用flash cc-createjs导出。我也嵌入了flash字体。但它并没有解决这个问题。我在这里附上了链接。只需单击矩形即可。它将创建10如果你再次点击,它将是20。但是20与10重叠。10不会消失。http://graphicscoder.org/stackover/score/scoring.html

/* js 
var score=0;

this.movieClip_1.addEventListener('click', fl_MouseOverHandler_2);
function fl_MouseOverHandler_2(e)
{
    text1 = new createjs.Text("LIVES: " + score, "40px Arial");
text1.textAlign = 'right';
text1.y = 30;
text1.x = stage.canvas.width - 10;
stage.addChild(text1);
    score=score+10;
  text1.text=String(score);

}
*/

每次单击按钮,都会添加一个新的Text。如果你只想更改号码:

  1. 最初创建一次文本
  2. 单击时更新值

示例:

/* js 
var score=0;
this.movieClip_1.addEventListener('click', fl_MouseOverHandler_2);
// Moved out of the mouse handler
text1 = new createjs.Text("LIVES: " + score, "40px Arial");
text1.textAlign = 'right';
text1.y = 30;
text1.x = stage.canvas.width - 10;
stage.addChild(text1);
function fl_MouseOverHandler_2(e)
{
    score=score+10;
    text1.text=String(score);
}
*/