如何在发动机中显示时间

时间:2014-03-15 08:31:02

标签: android timer andengine

我使用的是发动机GLES1。我希望在我的节目中显示时间但是时间没有显示。

   TimerHandler mTimerHandler = new TimerHandler(0.1f, true, new ITimerCallback() {

            public void onTimePassed(TimerHandler pTimerHandler) {
                 Scene scene = SG3Activity.this.mEngine.getScene();
                TIME_REMAINING --;

                final ChangeableText Text = new ChangeableText(34, 35, mFont, "time:"+TIME_REMAINING);


                scene.getFirstChild().attachChild(Text);



            }
        });

1 个答案:

答案 0 :(得分:1)

    Text record = new Text(0, 0, gScene.mFont, ""+ recordScore, 50, new TextOptions(HorizontalAlign.CENTER), gameActivity.getVertexBufferObjectManager());
    record.setPosition(scoreBoardSprite.getWidth() * 0.7f, scoreBoardSprite.getHeight()* 0.35f);
    record.setColor(235.0f/255.0f, 70.0f/255.0f, 7.0f/255.0f, 1);
    scoreBoardSprite.attachChild(record);


TimerHandler timerHandler = new TimerHandler(0.1f, true,new ITimerCallback() {
            @Override
            public void onTimePassed(final TimerHandler pTimerHandler) {
                    if(counter < gameScore){
                        counter++;
                        record.setText(""+counter);
                    }else{
                        unregisterUpdateHandler(pTimerHandler); 
                    }
            }
        });
        registerUpdateHandler(timerHandler);
    }

这里我正在创建文本并更新计时器中的文本&#34; setText()&#34;方法