android - Display Score In A Different Way in a Game -
i making game , display score in such fashion if score 0 , increased 10, score should increment through of numbers 0 10. after reaching new score should stop, @ least small pause.
if, again, score increased 10, scoreboard should increment through every number 10 20 , stop again.
i have tried using handlers unsuccessful in getting them pause or stop, in way.
the example in video demonstrates trying accomplish. if @ scoreboard in top right, see score incrementing. here url in case above link not work: http://www.youtube.com/watch?v=ndz8yupmema&feature=fvwrel
this code runnable increment score.
final handler mhandler=new handler(); mrunnable=new runnable() { public void run() { string s = null; ++i; s= new integer(i).tostring(); tv.settext(s); mhandler.postdelayed(mrunnable,1000); } /*protected void onstop() { mhandler.removecallbacks(mrunnable); }*/ }; mhandler.postdelayed(mrunnable,1000);
what need how code stop counting.
you can print numbers between 2 end points. say:
int counter = 0; while(counter%10 != 0) { textview.settext(counter.tostring()); counter++; }
and again continue loop, start 11 time,not 0.
i'm not sure it'll work want, in temple run example. want add little sleep()
of small amount, yesterday advised not use sleep()
method in android development.
edit:
ok. this tutorial seems pretty easy handle. can apply same logic score display mechanism using handler
(as guessed).
Comments
Post a Comment