e3roid example: Score handling – displaying the score

Something nearly every classic game needs, is the display of a score. A simple text doesn’t look “game like” – so a normal “textsprite” wasn’t my choice for displaying the score.

In this article you find my implementation a score-display class for e3roid based on animated sprites. I could also have used “TiledSprites”, but I still have the vision of letting the numbers change with animation – but I haven’t started implementing this yet.

To use the source code below you first need a e3roid body. Best is to extend the code of the Tutorial “Handle touch events” on the e3roid-page. If you follow the instructions below, the course will be increased with each touch-action.

Here you see how a sample coding could look like:

And here you see the graphic I use as resource:

import java.util.ArrayList;
import com.e3roid.drawable.Layer;
import com.e3roid.drawable.sprite.AnimatedSprite;
import com.e3roid.drawable.texture.TiledTexture;
public class Score {
	private int scoreCount;
	private TiledTexture aniTexture;
	private ArrayList numbers = new ArrayList();
	private AnimatedSprite oneNumber;
	private StoneSetter context;
	private static final int STARTX=364,STARTY=0;
	private static final int TILEWIDTH=24,TILEHIGHT=31;
	public Score( StoneSetter context) {
		aniTexture = new TiledTexture("gfx/numbers.png", TILEWIDTH, TILEHIGHT, context);
		this.context = context;
		for (int i=6;i>=0;i--){
			oneNumber = new AnimatedSprite(aniTexture,STARTX+ i*TILEWIDTH ,STARTY);
			if (i frames = new ArrayList();
		        frames.add(new AnimatedSprite.Frame(0, 0));
		        oneNumber.animate(500, frames);
		scoreCount = 0;
	public void add(Layer layer){
		for (AnimatedSprite number : numbers ){
	public int scoreAdd(int add){
		return (setScore(scoreCount+add));
	public int setScore(int scoreCount){
		this.scoreCount = scoreCount;
		int dmyScore = this.scoreCount;
		int res;
		int i = 0;
		ArrayList frames;
		while (dmyScore >= 0 & i ();
		  frames.add(new AnimatedSprite.Frame(res, 0));
		return (scoreCount);
	public int getScore(){
		return scoreCount;

Here you see the sections where you have to modify the Tutorial-Code

        protected Score score;
	public E3Scene onLoadScene() {
                score = new Score(this);
       public boolean onSceneTouchEvent(E3Scene scene, MotionEvent motionEvent) {

  • My Android Apps

    I download e3roid few weeks ago and used eclispe to develop by first Android Game.. you can see game on google play by searching “Death Mill” , it is nice game engine …

  • Abanoub Erian

    Thanks a lot for this awesome tutorial and i would ask you if you can help me because i ‘m a beginner game developer and i need some help in game development using e3roid engine . i will be very thankful and very happy if you accepted to help me in the beginning of my way . Thanks in advance
    To contact me send me a message on this E-mail : the-evil-dragon@hotmail.com