使用canvas.drawText显示整数

时间:2015-05-03 00:26:50

标签: java android canvas

目前我有一个整数,每次触摸精灵时都会递增,我想要做的就是在画布上显示。目前我喜欢这样:

public void doDraw(Canvas canvas) {
    canvas.drawBitmap(mBackgroundImage, 0, 0, null);
    sprite.draw(canvas); 
    //Draw all the objects on the canvas
    canvas.drawText("Number of hits: ",  5,25, paint);
    canvas.drawText(displayTime,  5,250, paint);
}

我要做的是在它说出命中次数后,它会显示用名为hitCount的整数来触摸精灵的次数

1 个答案:

答案 0 :(得分:0)

canvas.drawText("Number of hits: " + String.valueOf(hitCount),  5,25, paint);