0
我正在尋找一個倒計時教程使用Andengine.This是我需要做的應用程序即我需要計數,直到具體日期,當它達到該日期,它必須顯示一些消息,當通過它的日期必須再次顯示倒計時,直到明年的這一天。如何實現this.i搜索各種教程,但無法找到。希望有人會幫助我。 clock)= new Text(CAMERA_WIDTH/4.4f,CAMERA_HEIGHT/3.6f,this.mFont,「Hello AndEngine!」,this.getVertexBufferObjectManager());倒計時日期/天使用Andengine
Calendar thatDay = Calendar.getInstance();
thatDay.set(Calendar.DAY_OF_MONTH,30);
thatDay.set(Calendar.MONTH,9); // 0-11 so 1 less
thatDay.set(Calendar.YEAR, 2014);
Calendar today = Calendar.getInstance();
//long diff = today.getTimeInMillis() - thatDay.getTimeInMillis(); //result in millis
long diff = thatDay.getTimeInMillis()-today.getTimeInMillis(); //result in millis
long days = diff/(24 * 60 * 60 * 1000);
this.remain = days;
if(remain<0){
clocktext = new Text(CAMERA_WIDTH/9.8f, CAMERA_HEIGHT/1.4f,this.mFont, remain + "", this.getVertexBufferObjectManager());
}if(remain==0){
clocktext = new Text(CAMERA_WIDTH/9.8f, CAMERA_HEIGHT/1.4f,this.mFont, "HAPPY HALLOWEEN", this.getVertexBufferObjectManager());
}if(remain>0){
clocktext = new Text(CAMERA_WIDTH/9.8f, CAMERA_HEIGHT/1.4f,this.mFont, remain + "", this.getVertexBufferObjectManager());
}
只是一個替代方案:在andengine也ü可以實現簡單的Java或Android countDown方法Timeer,或者更確切地說,u可以使用chrometer太.. – KOTIOS 2014-10-07 13:25:58
@mtetno感謝答案。如何設置確切日期從日曆和當前日期說30/10 /年,我想得到的差異,即Days.And到達那天我想顯示一條消息,當日期通過我想反櫃開始顯示剩餘的日子,直到明年。 – 2014-10-07 13:31:33
@mtetno更新了我試過的代碼。 – 2014-10-07 13:35:06