@Override public void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawBitmap(background, null, backgroundRect, textPaint); magicCloud.doDraw(canvas); Rect rect = new Rect( (int) (SCREEN_WIDTH * 0.1), (int) (SCREEN_HEIGHT * 0.2), (int) (SCREEN_WIDTH * 0.9), (int) (SCREEN_HEIGHT * 0.8)); // 绘制矩形 canvas.drawRect(rect, rectPaint); // 绘制文本内容 textPaint.setTextSize(16); textPaint.setColor(Color.GREEN); textPaint.setTextAlign(Align.RIGHT); canvas.drawText("时间:", (int) (SCREEN_WIDTH * 0.4), (int) (SCREEN_HEIGHT * 0.33), textPaint); canvas.drawText("分数:", (int) (SCREEN_WIDTH * 0.4), (int) (SCREEN_HEIGHT * 0.40), textPaint); canvas.drawText("最高连击:", (int) (SCREEN_WIDTH * 0.4), (int) (SCREEN_HEIGHT * 0.47), textPaint); canvas.drawText("最长连接:", (int) (SCREEN_WIDTH * 0.4), (int) (SCREEN_HEIGHT * 0.54), textPaint); canvas.drawText("错误次数:", (int) (SCREEN_WIDTH * 0.4), (int) (SCREEN_HEIGHT * 0.61), textPaint); textPaint.setTextSize(28); textPaint.setTextAlign(Align.CENTER); textPaint.setColor(Color.RED); canvas.drawText( "第" + mainActivity.gameView.level.getLevel() + "关完成", (int) (SCREEN_WIDTH * 0.5), (int) (SCREEN_HEIGHT * 0.26), textPaint); if (mainActivity.gameCount != null) { textPaint.setTextAlign(Align.LEFT); textPaint.setTextSize(16); textPaint.setColor(Color.GREEN); canvas.drawText( mainActivity.gameCount.getGameTime(), (int) (SCREEN_WIDTH * 0.42), (int) (SCREEN_HEIGHT * 0.33), textPaint); canvas.drawText( String.valueOf(mainActivity.gameCount.getScore()), (int) (SCREEN_WIDTH * 0.42), (int) (SCREEN_HEIGHT * 0.40), textPaint); canvas.drawText( String.valueOf(mainActivity.gameCount.getMaxHitCount()), (int) (SCREEN_WIDTH * 0.42), (int) (SCREEN_HEIGHT * 0.47), textPaint); canvas.drawText( String.valueOf(mainActivity.gameCount.getMaxLinkLength()), (int) (SCREEN_WIDTH * 0.42), (int) (SCREEN_HEIGHT * 0.54), textPaint); canvas.drawText( String.valueOf(mainActivity.gameCount.getWrongCount()), (int) (SCREEN_WIDTH * 0.42), (int) (SCREEN_HEIGHT * 0.61), textPaint); } // 绘制点击屏幕开始游戏文字 bottomPaint.setAlpha(bottomAlpha); canvas.drawText( "点击屏幕开始游戏", (int) (SCREEN_WIDTH * 0.5), (int) (SCREEN_HEIGHT * 0.9), bottomPaint); if (bottomAlphaGrow) { bottomAlpha += 20; if (bottomAlpha >= 255) { bottomAlphaGrow = false; } } else { bottomAlpha -= 20; if (bottomAlpha <= 0) { bottomAlphaGrow = true; } } }