分数是可绘制的图像
private Bitmap Scores;
private boolean running =true;
private SurfaceView mySurfaceHolder;
Scores.decodeResource(myContext.getResource(), R.drawable.score);
//this is just the run procedure
@Override
public void onRun()
{
while(running){
Canvas c = null;
try{
c = mySurfaceHolder.lockCanvas(null);
synchronize(mySurfaceHolder){
drawScore(c); //here is where i call my method..
}
}finally{
mySurfaceHolder.unlockCanvasAndPost(c);
}
}
//the pontsGain and onTitle are both boolean variables so please don't get confuse
//and pointScoreAtY is an integer that will allocate my specific position in screen
private void drawScore(Canvas c)
{
try{
if(pointsGain && !onTitle)
{
pointScoreAtY = (int)(FingerY -(Scores.getHeight()/2)-100);
int i=100;
do{
try{
c.drawBitmap(Scores, (FingerX -(Scores.getWidth()/2))+200,pointScoreAtY, null);
invalidate();
pointScoreAtY -=i;
}catch(Exception e){}
}while(i-->0);
pointsGain = false;
}
}catch(Exception e){}
}
这个特定的功能是在当前位置在屏幕上绘制一个位图,但这不是我想要做的......例如,我的主要目标是当我的游戏中的一个角色被击中时,我想显示一个 scorePoint 并对其进行动画处理它可以上升并从屏幕上消失。