WARNING: This is an outdated tutorial for the old AndEngine GLES1.0, if you want a tutorial for the new GLES2.0 then Check my Jimvaders tutorial ..
After playing around with the Android SDK , I thought that I should give game development a test drive. After giving Cocos2D a test, I faced the problem of online support, almost all the tutorials I found online were for the iOS version.. so I looked for other Engines made for Android.
AndEngine is an awesome game engine I found, but I couldn’t find a whole game tutorial.. so I thought that I’d port Dan’s simple Android Game tutorial (that’s actually ported from Ray’s iPhone cocos2D tutorial)
This tutorial will cover:
– Adding/Removing sprites
– Using timeHandlers
– Moving sprites
– Using Sound/Music
– Pausing/Resuming your game
– Simple collision detection
Preparing your tools
Before we start coding, we need to make sure that you have Eclipse and Android SDK installed, if not then use google’s guide for that. You should also give this Hello World example a go to make sure that the SDK installed correctly. You also need need a real Android device, the emulator is far too slow to test on .
Java is essential, if you don’t know Java you may get lost in the middle, also take a look at Android’s Activity life cycle just to have an idea about the order of stuff in there.
If you wanna make sure you are using the latest version of AndEngine, follow this tutorial to build your own jar file AndEngine has moved from Google Code, thus the tutorial linked won’t work anymore you can just download the one I’m using from here, or you can follow my tutorial of getting GLES2.0 but chose master instead [you won’t be using a jar file in that case though].
Let’s get started !
Create a new Android project, I chose Android 1.6 [SDK 4] but this should work on any version.
place the andengine.jar file inside the lib folder (if it doesn’t exist, then create it) and right click on it (from inside eclipse) and select build path -> add to build path.
create a new class, make it extends BaseGameActivity. [Eclipse hint: type BaseGame in the superclass field then ctrl+space for auto complete]
now you should have a class with 4 methods in it
declare those global variables
private Camera mCamera; private Scene mMainScene;
and this is onLoadEngine()
public Engine onLoadEngine() { final Display display = getWindowManager().getDefaultDisplay(); int cameraWidth = display.getWidth(); int cameraHeight = display.getHeight(); mCamera = new Camera(0, 0, cameraWidth, cameraHeight); return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(cameraWidth, cameraHeight), mCamera)); }
what we did here is that we prepared the Engine by giving it the proper resolution for the device we are using, the camera represents the the rectangular viewable part of the scene, basically it’s what you see on the screen.
and onLoadScene()
public Scene onLoadScene() { mEngine.registerUpdateHandler(new FPSLogger()); mMainScene = new Scene(); mMainScene .setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f)); return mMainScene; }
also add these permissions in the manifest
<uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.CAMERA"/>
then run, you should see a blue screen like this
which means that the engine is working fine
Sprites ? we has them (Adding a sprite)
Sprites are 2D images that represents the stuff you see on the screen, they can be characters, bullets, or a background image.
in our game, we’ll need 3 main sprites: Player, target, projectiles(bullets). Aat first we’d need to have images for those, you can use your own images .. or use the ones provided by Ray’s wife Player, Projectile, Target. Go to your assets folder in the project , create a new folder and name it “gfx” and place them inside.
now let’s add the Player’s sprite, we will have it at the left side of the screen, in the middle .. let’s do that !
let’s declare those object :
private BitmapTextureAtlas mBitmapTextureAtlas; private TextureRegion mPlayerTextureRegion; private Sprite player;
and this will be our onLoadResources()
public void onLoadResources() { mBitmapTextureAtlas = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA); BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "Player.png", 0, 0); mEngine.getTextureManager().loadTexture(mBitmapTextureAtlas); }
imagine the BitmapTextureAtlas as a board where you stick pictures on it, we defined it’s resolution to be 512 x 512 pixels and it needs to be a power of 2 (we will need those other areas later).We then set the assets path to be in “gfx/”, you can skip that line but when defining the mPlayerTextureRegion, you’d have to define a full path to the image.
we add more stuff to onLoadScene(), at first we calculate the position of the sprite and create a new player sprite
final int PlayerX = this.mPlayerTextureRegion.getWidth() / 2; final int PlayerY = (int) ((mCamera.getHeight() - mPlayerTextureRegion .getHeight()) / 2); player = new Sprite(PlayerX, PlayerY, mPlayerTextureRegion);
The Sprite looks kinda small on my screen, so I added this
player.setScale(2);
and then we attach the sprite to our main scene
mMainScene.attachChild(player);
And test it , w00t we have our mighty ninja waiting for stuff to kill [Ninjas are cool regardless of what they are doing]
Any challengers ? (Moving sprites)
Our ninja is bored, he needs some action and we are gonna provide that. we’ll have some moving targets coming from the right side to the left side of the screen.
we’ll need more objects, so declare those
private TextureRegion mTargetTextureRegion; private LinkedList targetLL; private LinkedList TargetsToBeAdded;
and add this to the onLoadResources()before loading texture in the engine
mTargetTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "Target.png", 128, 0);
and inside onLoadScene(), append the following after mMainScene.attachChild(player)
targetLL = new LinkedList(); TargetsToBeAdded = new LinkedList();
then add this method to the class:
public void addTarget() { Random rand = new Random(); int x = (int) mCamera.getWidth() + mTargetTextureRegion.getWidth(); int minY = mTargetTextureRegion.getHeight(); int maxY = (int) (mCamera.getHeight() - mTargetTextureRegion .getHeight()); int rangeY = maxY - minY; int y = rand.nextInt(rangeY) + minY; Sprite target = new Sprite(x, y, mTargetTextureRegion.deepCopy()); mMainScene.attachChild(target); int minDuration = 2; int maxDuration = 4; int rangeDuration = maxDuration - minDuration; int actualDuration = rand.nextInt(rangeDuration) + minDuration; MoveXModifier mod = new MoveXModifier(actualDuration, target.getX(), -target.getWidth()); target.registerEntityModifier(mod.deepCopy()); TargetsToBeAdded.add(target); }
I kind of copied this method from Dan’s tutorial and modified it a li’l bit, so basically we are determining the minimum and maximum y position for the targets to appear at then use the Random() class to generate a random number so the value of y is still on the screen while the x value places the sprite just before the right side of the screen.
The targets also have a random speed between 2 to 4 seconds to cross the screen, so this won’t be affected by the size of the screen to make the game easier.
MoveXModifier is a modifier that makes the targets move horizontally (across the x-axis). [note: if eclipse complained about deepCopy(), change it to clone() .. deepCopy() was introduced later in AndEngine]
we’ll talk about those linked lists later on.
Now we need to periodically call the addTarget() function, we do this by using this TimeHandler
private void createSpriteSpawnTimeHandler() { TimerHandler spriteTimerHandler; float mEffectSpawnDelay = 1f; spriteTimerHandler = new TimerHandler(mEffectSpawnDelay, true, new ITimerCallback() { @Override public void onTimePassed(TimerHandler pTimerHandler) { addTarget(); } }); getEngine().registerUpdateHandler(spriteTimerHandler); }
This will be recalled every 1 second.
Call it at the end of onLoadScene()
createSpriteSpawnTimeHandler();
Test, you’ll have targets coming from the right side of the screen and disappearing in the left side .. our Ninja got company!
Can I kill them now ? (removing sprites)
Not quite yet, we are missing something. The targets move from the right side to the left side, but when they leave the screen [the camera] they stop just outside, they still exist [in the scene] but just outside .. we gotta fix that.
At first, let’s create a new method to delete a sprite safely
public void removeSprite(final Sprite _sprite, Iterator it) { runOnUpdateThread(new Runnable() { @Override public void run() { mMainScene.detachChild(_sprite); } }); it.remove(); }
That way, we won’t interrupt the work of the engine drawing when we remove the sprites
Now let’s check all targets every frame, we’ll use this
IUpdateHandler detect = new IUpdateHandler() { @Override public void reset() { } @Override public void onUpdate(float pSecondsElapsed) { Iterator<Sprite> targets = targetLL.iterator(); Sprite _target; while (targets.hasNext()) { _target = targets.next(); if (_target.getX() <= -_target.getWidth()) { removeSprite(_target, targets); } } targetLL.addAll(TargetsToBeAdded); TargetsToBeAdded.clear(); } };
We used an iterator as it seems the safest way to modify a linked list using the remove() method, and if the target left the screen , we simply call removeSprite to delete it. We iterate over targetLL, and then we add everything from the TargetsToBeAdded and clear it, I did this as a workaround cause I was getting ConcurrentModificationException, this way we won’t interrupt the work of spawning targets.
Now let’s register the update handler, append this to the end of onLoadScene()
mMainScene.registerUpdateHandler(detect);
What about now ? (handling touch input)
We first gotta equip our ninja with a weapon, did I hear shurikens ?
add this to our objects
private LinkedList projectileLL; private LinkedList projectilesToBeAdded; private TextureRegion mProjectileTextureRegion;
And in onLoadResources()
mProjectileTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "Projectile.png", 64, 0);
onLoadScene
projectileLL = new LinkedList(); projectilesToBeAdded = new LinkedList();
Then we’ll need this method to shoot targets
private void shootProjectile(final float pX, final float pY) { int offX = (int) (pX - player.getX()); int offY = (int) (pY - player.getY()); if (offX <= 0) return; final Sprite projectile; projectile = new Sprite(player.getX(), player.getY(), mProjectileTextureRegion.deepCopy()); mMainScene.attachChild(projectile, 1); int realX = (int) (mCamera.getWidth() + projectile.getWidth() / 2.0f); float ratio = (float) offY / (float) offX; int realY = (int) ((realX * ratio) + projectile.getY()); int offRealX = (int) (realX - projectile.getX()); int offRealY = (int) (realY - projectile.getY()); float length = (float) Math.sqrt((offRealX * offRealX) + (offRealY * offRealY)); float velocity = 480.0f / 1.0f; // 480 pixels / 1 sec float realMoveDuration = length / velocity; MoveModifier mod = new MoveModifier(realMoveDuration, projectile.getX(), realX, projectile.getY(), realY); projectile.registerEntityModifier(mod.deepCopy()); projectilesToBeAdded.add(projectile); }
The method would bail out if we shot backward..
Am kinda too lazy to explain this , so I’ll just “borrow” [read:steal] from Dan’s tutorial
This should look familiar to anyone who didn’t fall asleep in maths class – Pythagoras! Now before we fall asleep with yet more theory, let’s start coding. In the constructor add the following line:
We create the sprite and position it over the ninja. We then work out where the projectile should move to by extending the tap off the screen. This is done by getting the X and Y offset of the tap to the projectile’s starting position. We then get the ratio of Y to X, and simply scale the touch Y coordinate to match the scaled up X coordinate (which is just off the screen).
After working out the destination, we need to work out the duration of the movement – we can’t have projectiles taking different amounts of time just because of the angle they’re shot at. To solve this problem we use Pythagoras to work out the distance the projectile needs to travel, then divide that by the velocity we want. This is because velocity = distance over time, or by re-arranging: time = distance over velocity.
Got it ? 😛
Now we’ll need to receive touch events, that will be done by having our main class implement IOnSceneTouchListener
Assuming your activity is called AndEngineSimpleGame, it should be like this
public class AndEngineSimpleGame extends BaseGameActivity implements IOnSceneTouchListener {
Which will add the method onSceneTouchEvent, that goes like
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) { if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) { final float touchX = pSceneTouchEvent.getX(); final float touchY = pSceneTouchEvent.getY(); shootProjectile(touchX, touchY); return true; } return false; }
We are only tracking tapping events. Next we put this at the end of onLoadScene()
mMainScene.setOnSceneTouchListener(this);
Run and tap on the screen, our Ninja is a shuriken master !
But .. But .. They are not dying ! (collision detection)
Oh right ! about that we’ll get to that now..
As you should’ve already noticed , we didn’t clean up after the projectiles , they are just leaving the screen and staying there .. we’ll do that with our basic collision detection.
Just update your detect IUpdateHandler to this one:
IUpdateHandler detect = new IUpdateHandler() { @Override public void reset() { } @Override public void onUpdate(float pSecondsElapsed) { Iterator<Sprite> targets = targetLL.iterator(); Sprite _target; boolean hit = false; while (targets.hasNext()) { _target = targets.next(); if (_target.getX() <= -_target.getWidth()) { removeSprite(_target, targets); break; } Iterator<Sprite> projectiles = projectileLL.iterator(); Sprite _projectile; while (projectiles.hasNext()) { _projectile = projectiles.next(); if (_projectile.getX() >= mCamera.getWidth() || _projectile.getY() >= mCamera.getHeight() + _projectile.getHeight() || _projectile.getY() <= -_projectile.getHeight()) { removeSprite(_projectile, projectiles); continue; } if (_target.collidesWith(_projectile)) { removeSprite(_projectile, projectiles); hit = true; break; } } if (hit) { removeSprite(_target, targets); hit = false; } } projectileLL.addAll(projectilesToBeAdded); projectilesToBeAdded.clear(); targetLL.addAll(TargetsToBeAdded); TargetsToBeAdded.clear(); } };
We Loop over all projectiles for every loop over targets, at first we check if the projectile left the screen , if it did then we remove it and continue to the next projectile, if not then we check if they collide or not.
We are assuming here that if a projectile did hit a target, it’d hit one and only one target that’s why we break out of the loop after the collision, we remove the target after the loop.
Using the same technique we used for targets, we avoided the exception [and used more resources]
Give it a test now and let our Ninja enjoy killing those ghosts thingies.
I Have Ears ! (Sound/Music)
Oh, you want some sounds ? ok then .. you shall be given.
We’ll add two sounds, an effect for shooting and a background music, you can use your own audio files or use the ones provided by Ray [and taken from Dan’s site] background music, , pew pew sound effect [note: apparently AndEngine better uses .ogg files, but those wav files worked fine for me].
Place those files in “assets/mfx/” after extracting them , and let’s start editing our code ! [I renamed the “background_music_aac.wav” file to “background_music.wav” do so or make sure you fix that in the code unless you like clicking the famous Force Close button]
In onLoadEngine(), replace the return statement with this one
return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(cameraWidth, cameraHeight), mCamera) .setNeedsMusic(true).setNeedsSound(true));
Declare those
private Sound shootingSound; private Music backgroundMusic;
Then add this to onLoadResources()
SoundFactory.setAssetBasePath("mfx/"); try { shootingSound = SoundFactory.createSoundFromAsset(mEngine .getSoundManager(), this, "pew_pew_lei.wav"); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } MusicFactory.setAssetBasePath("mfx/"); try { backgroundMusic = MusicFactory.createMusicFromAsset(mEngine .getMusicManager(), this, "background_music.wav"); backgroundMusic.setLooping(true); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
Notice that backgroundMusic is set to be looping
Add backgroundMusic.play() before the return statement of onLoadScene() and shootingSound.play() at the end of shootProjectile(), test and hear the wrath of the ninja .. or the pew pew of the ninja.
Hold on a sec ! (Pausing)
Before you continue, let’s pause the game first .. umm .. guess we need to implement that, here goes nothing.
[note: pausing the game is entirely copied from the AndEngine Eamples].
First , let’s download the pause image from the AndEngine Example and place it in the “assets/gfx/” then declare those
private TextureRegion mPausedTextureRegion; private CameraScene mPauseScene;
A CameraScene from my understanding is a scene that only appears on the current camera, imagine it as a layer above the current scene.
Add this to onLoadResources()
mPausedTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "paused.png", 0, 64);
onLoadScene() now have this
mPauseScene = new CameraScene(mCamera); final int x = (int) (mCamera.getWidth() / 2 - mPausedTextureRegion .getWidth() / 2); final int y = (int) (mCamera.getHeight() / 2 - mPausedTextureRegion .getHeight() / 2); final Sprite pausedSprite = new Sprite(x, y, mPausedTextureRegion); mPauseScene.attachChild(pausedSprite); mPauseScene.setBackgroundEnabled(false);
We initialized the mPauseScene by having a sprite that says “paused” in the middle, and made it transparent by disabling the background
Create a new methods
public void pauseGame() { mMainScene.setChildScene(mPauseScene, false, true, true); mEngine.stop(); } public void unPauseGame() { mMainScene.clearChildScene(); mEngine.start(); } public void pauseMusic() { if (backgroundMusic.isPlaying()) backgroundMusic.pause(); } public void resumeMusic() { if (!backgroundMusic.isPlaying()) backgroundMusic.resume(); }
Having these as a methods would come in handy later on, they are self explanatory you can figure out what they do yourself.
Then add this method overriding
@Override public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) { if (pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) { if (mEngine.isRunning()) { pauseMusic(); pauseGame(); Toast.makeText(this, "Menu button to resume", Toast.LENGTH_SHORT).show(); } else { unPauseGame(); resumeMusic(); } return true; } return super.onKeyDown(pKeyCode, pEvent); }
If the Menu button is clicked while the engine is running, pause the game [and show that toast] , else resume the game .. give it a try
PWND ! (Win/Fail and Finishing touches)
Game is boring if you can’t win (or lose) , let’s add those aspects to our li’l game, first download those images for Win/Fail that my friend Mazyod created [and place them in “assets/gfx/”] , then declare those
private CameraScene mResultScene; private boolean runningFlag = false; private boolean pauseFlag = false; private BitmapTextureAtlas mFontTexture; private Font mFont; private ChangeableText score; private int hitCount; private final int maxScore = 10; private Sprite winSprite; private Sprite failSprite; private TextureRegion mWinTextureRegion; private TextureRegion mFailTextureRegion;
Changeabletext and Font are used to display your current score, you already know the rest.
Inside onLoadResources(), let’s add this
mWinTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "win.png", 0, 128); mFailTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "fail.png", 0, 256); mEngine.getTextureManager().loadTexture(mBitmapTextureAtlas); mFontTexture = new BitmapTextureAtlas(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); mFont = new Font(mFontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 40, true, Color.BLACK); mEngine.getTextureManager().loadTexture(mFontTexture); mEngine.getFontManager().loadFont(mFont);
onLoadScene() gets this
mResultScene = new CameraScene(mCamera); winSprite = new Sprite(x, y, mWinTextureRegion); failSprite = new Sprite(x, y, mFailTextureRegion); mResultScene.attachChild(winSprite); mResultScene.attachChild(failSprite); mResultScene.setBackgroundEnabled(false); winSprite.setVisible(false); failSprite.setVisible(false); score = new ChangeableText(0, 0, mFont, String.valueOf(maxScore)); score.setPosition(mCamera.getWidth() - score.getWidth() - 5, 5);
Add this method to reset everything to default
public void restart() { runOnUpdateThread(new Runnable() { @Override public void run() { mMainScene.detachChildren(); mMainScene.attachChild(player, 0); mMainScene.attachChild(score); } }); hitCount = 0; score.setText(String.valueOf(hitCount)); projectileLL.clear(); projectilesToBeAdded.clear(); TargetsToBeAdded.clear(); targetLL.clear(); }
Make sure you call it before the return statement of onLoadScene() so the score shows.
Your win/fail methods would be something like this
public void fail() { if (mEngine.isRunning()) { winSprite.setVisible(false); failSprite.setVisible(true); mMainScene.setChildScene(mResultScene, false, true, true); mEngine.stop(); } } public void win() { if (mEngine.isRunning()) { failSprite.setVisible(false); winSprite.setVisible(true); mMainScene.setChildScene(mResultScene, false, true, true); mEngine.stop(); } }
In the detect updateHandler add this inside the if(hit)
hitCount++; score.setText(String.valueOf(hitCount));
And this at the end of the while loop
if (hitCount >= maxScore) { win(); }
Make sure you also call fail() in the “if (_target.getX() <= -_target.getWidth())” method before the break
Check for runningFlag when pausing and resuming music
public void pauseMusic() { if (runningFlag) if (backgroundMusic.isPlaying()) backgroundMusic.pause(); } public void resumeMusic() { if (runningFlag) if (!backgroundMusic.isPlaying()) backgroundMusic.resume(); }
Your onKeyDown override should be changed to this
@Override public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) { if (pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) { if (mEngine.isRunning() && backgroundMusic.isPlaying()) { pauseMusic(); pauseGame(); Toast.makeText(this, "Menu button to resume", Toast.LENGTH_SHORT).show(); } else { if (!backgroundMusic.isPlaying()) { resumeMusic(); mEngine.start(); } return true; } } else if (pKeyCode == KeyEvent.KEYCODE_BACK && pEvent.getAction() == KeyEvent.ACTION_DOWN) { if (!mEngine.isRunning() && backgroundMusic.isPlaying()) { mMainScene.clearChildScene(); mEngine.start(); restart(); return true; } return super.onKeyDown(pKeyCode, pEvent); } return super.onKeyDown(pKeyCode, pEvent); }
Notice we are changing the function of the back key to resume game you get a win/fail scene.
Now you should be able to win/fail the game and make your ninja happy [not really for the happy part]
After Finishing Touches
Well .. I noticed that the game was behaving weird when you click on the home button .. so here’s some stuff regarding AndEngine’s lifecycle taken from the forums
launch game
1) onLoadEngine()
2) onResume()
3) onLoadResources()
4) onLoadScene()
5) onLoadComplete()
6) onResumeGame()during game, go to homescreen
1) onPause()return to game
1) onResume()
2) onResumeGame()exit game with this.finish()
1) onPause()
2) onDestroy()
So we need to mess around with onResumeGame() and onPause()
onResumeGame() would be this
@Override public void onResumeGame() { super.onResumeGame(); if (runningFlag) { if (pauseFlag) { pauseFlag = false; Toast.makeText(this, "Menu button to resume", Toast.LENGTH_SHORT).show(); } else { resumeMusic(); mEngine.stop(); } } else { runningFlag = true; } }
Apparently , super.onResumeGame() changes the state of mEngine to running , so we had to stop it again in here
And onPause()
@Override protected void onPause() { if (runningFlag) { pauseMusic(); if (mEngine.isRunning()) { pauseGame(); pauseFlag = true; } } super.onPause(); }
And onKeyDown gets changed a li’l bit again, set the pauseFlag to true after you call pauseGame(), and to false after you unPauseGame() it, which will be
@Override public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) { if (pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) { if (mEngine.isRunning() && backgroundMusic.isPlaying()) { pauseMusic(); pauseFlag = true; pauseGame(); Toast.makeText(this, "Menu button to resume", Toast.LENGTH_SHORT).show(); } else { if (!backgroundMusic.isPlaying()) { unPauseGame(); pauseFlag = false; resumeMusic(); mEngine.start(); } return true; } } else if (pKeyCode == KeyEvent.KEYCODE_BACK && pEvent.getAction() == KeyEvent.ACTION_DOWN) { if (!mEngine.isRunning() && backgroundMusic.isPlaying()) { mMainScene.clearChildScene(); mEngine.start(); restart(); return true; } return super.onKeyDown(pKeyCode, pEvent); } return super.onKeyDown(pKeyCode, pEvent); }
That should clear it for you, everything should be working fine and your ninja should be happy [even if he doesn’t smile] killing those nasty ghosts.
tl;dr gimme the source code !
Ok fine >_> [even though I did spend quite a lot of time writing this ..]
here you go , the whole project with comments
Now what ?
Well .. you broke the barrier of creating games, that’s something [and you have a happy frowning ninja too] , check out the other examples by AndEngine and hit the forums for help.
This was my first tutorial and first blog post too [and was actually my first AndEngine project too XD], I hope you have enjoyed it. If you noticed any mistake or know of a way to do stuff in a better way leave a comment !
you can also follow up with the second post about using pools
Awesome tutorial! Keep up the good work 🙂
مأساء الله
وأيد حلوه.
I will do !!! ;p
this is awesome imho the best andengine tutorial out there
and one more thing i don’t think dan would you hotlinking his photo http://dan.clarke.name/wp-content/uploads/2011/04/direction.png
Fixed, I quoted him so the pic was included
now it’s hosted on the blog
Thanks a lot it is really helpful ! i began today to use andengine and your tutorial is just legen -wait for it – dary ! 🙂
XD those are they type of comments that makes me go 😀
glad it helped !
Hey ! Just a fix I had to do.
When we add the font texture for the score, you forgot to show the mFontTexture creatiobn. I had an error because of that , in the loadRessources() :
add this :
mFontTexture = new Texture(512, 512,
TextureOptions.BILINEAR_PREMULTIPLYALPHA);
( i put the same number of the other but i m not sure!)
if not, there is a bug because of that because mFontTexture doesn’t contain anything :
mFont = new Font(mFontTexture, Typeface.create(Typeface.DEFAULT,
Typeface.BOLD), 40, true, Color.BLACK);
mEngine.getTextureManager().loadTexture(mFontTexture);
mEngine.getFontManager().loadFont(mFont);
oops, you are correct
I just fixed it .. sorry for that 😀
🙂 I have an other problem and I don’t know where it comes this time
I created the onResume ( onREsumeGame seems to doesn’t exist anymore) and then the onPause and then game crashe directly at the beginning ><
Without onPause it works… I am quite lost here
you are probably using an older version of the libraries ? [or maybe they changed it in the new one]
try to download the library [the .jar file] that I provided in the tutorial and use it
Hi. I’m from Brasil and i really liked your tutorial, it’s help me a lot. Keep up the goooooo0d Work, dude !
Jimmar, Brother. I’m starting now with Android and i really like if you indicate me some kinds of tutorials of games in Android. Tks again !
sorry but if you want to a step by step tutorial , I’m afraid I didn’t find any other .. that’s why I created mine
This is very nice. I started with AndEngine today, and I think that you’ve created very nice intro to get started. Thanks!
Thank you very much from a French 🙂 , I’m beginner so I’m not sure! But I think there are little mistakes like :
two -> return super.onKeyDown(pKeyCode, pEvent); in onKeyDown
and we need to add :
mMainScene.attachChild(score);
before
return mMainScene;
in onLoadScene()
but it’s easy to find thanks to your great explanations on andengine
yeah , because of the structure of the way I handled it .. I kinda had to have two return statements .. feel free to do it in another way
and for the score, you are already doing that inside the method “restart()” 😉
oh and change :
if (!backgroundMusic.isPlaying()) {
resumeMusic();
mEngine.start();
}
to
if (!backgroundMusic.isPlaying()) {
resumeMusic();
unPauseGame();
mEngine.start();
}
in onKeyDown
already mentioned that later on in the tutorial “And onKeyDown gets changed a li’l bit again, set the pauseFlag to true after you call pauseGame(), and to false after you unPauseGame() it”
well .. no harm into editing it again
sorry I confess I read diagonally
we all do 😛
good job ! , thank you,,
Hi,
trying to show your png files on the screen an error occurs: “the application has stopped unexpectedly.”
Are your images right? it works if I try woth other png files.
thanks!
Sorry, I just realized I created a new “gfx” folder… stupid mistake…
Hi (again :P), I think there is a mistake. You declare the variable “targetLL” twice (for shurikens and for enemies)
oh right !
thanx for mentioning that , got it fixed 😀
hello I’ve been trying to work off your example here, and have not been able to get the sprite to display at all. scene.attachchild() seems to be giving me the trouble, eclipse says it throws and illegal state exception and Logcat gives me an error claiming “Error while generating scanline”
I would love to get this running, but I’m at a road block if I can’t get sprites onscreen.
umm.. I can’t really figure out what’s exactly wrong with only this info
paste what you have so far here pastebin.com
and post the link , maybe you missed a li’l part or something
Just freakin’ awesome!! Thanks a ton for this! Before this one I was trying to create my own game engine and do all the stuff myself. While that was good for learning, it was taking too much time and I wasn’t able to concentrate on the business part of game development (ahem!). AndEngine is great and greater is this tutorial for starters!
Thanks and a beer when we meet! 🙂
Hi!
Been trying to understand andengine for a couple of days now and your tutorial is the most useful and easiest I have come across.
I just began following it, but found a problem at the very beginning, when it is supposed to show the blue screen, all the emulator outputs is a landscape screen showing “Hello World, GameTestActivity!” (Being GameTestActivity the name of my class). What am I doing wrong?
Thanks!
when you create the class [GameTestActivity] make it extend BaseGameActivity in the create window [or just delete the oncreate() method], your class should not have onCreate() method in it , I’ve updated the post with a screenshot
That was it, now works perfectly.
Thanks once again!
What is this statement if: if (_target.getX() removeSprite(_target, targets);
in:
01 IUpdateHandler detect = new IUpdateHandler() {
02 @Override
03 public void reset() {
04 }
05
06 @Override
07 public void onUpdate(float pSecondsElapsed) {
08
09 Iterator targets = targetLL.iterator();
10 Sprite _target;
11
12 while (targets.hasNext()) {
13 _target = targets.next();
14 if (_target.getX() removeSprite(_target, targets);
15 }
16 }
17 targetLL.addAll(TargetsToBeAdded);
18 TargetsToBeAdded.clear();
19 }
20 };
I got the error
got no idea what happened , parts of my codes got deleted :S
I fixed it now , sorry for that
Extremely beautiful. The code is simple, understandable, and covers a lot of the basics. I cannot thank you enough for your work.
Just one note, the project worked perfectly on the emulator. Later wanted to test it on my galaxy i9000, and the app crashed on the first attempt to launch. Worked perfectly on the following attempts though.
Thank you for the amazing work again!
Glad you enjoyed it !
I own the same phone [high 5 ?] and sometimes eclipse doesn’t get updated with all the assets when deploying the app , or it could be a random problem … inform me if it happens again [with the log (stacktrace) from logcat]
and you are welcome 😀
Very Nice tutorial I have never found tutorial good like this , Thank you.
But I didn’t understand linkedlist part can you explain what is linkedlist ?
a linkedlist is a data structure to save data dynamically , it’s size changes as you put more nodes in it, you can get more info from this wikipedia page https://secure.wikimedia.org/wikipedia/en/wiki/Linked_list
like a pointers ? I am new on java but I have experience on c++, it is similar to pointer vectors. Thanks.
even though this is out of the scope of the tutorial [and I gave you a wikipedia page] but here’s a brief
the idea of the linked list is to have a node that points to another node, each node would be a class (or struct) that contains the data and a pointer to the next node i.e.
class node{
string data;
node* next;
}
whenever you need to add a new element, you’d create a new node and make the last node point to this new one , you end up with a list of nodes that are linked to eachothers , and to access a node in the middle you’d have to go from the head and iterate over the pointers till you reach the one you need.
here I used a ready made linkedlist provided by java, you can create your own if you need it
you may need to look up more data structures tutorials to get the hang of it
First thanks for this great and clear tutorial. All is fine untill i got stuck on the part ‘But .. But .. They are not dying ! (collision detection)’. When i update my detect IUpdateHandler to yours i get all sorts of misconstruct errors. Am i doing something wrong or is the code damaged?
urgh , wordpress omitted a small part from code >_<
I changed it back and should be fixed now .. if you have any other issues please post the stack trace you get from logcat [DDMS] (assuming you are not getting compile errors) and your code on http://pastebin.com/ and post the link here
I'll check it for you
HI, i think there is always a mistake in this part with collisions…. I have a lot of mistakes when i’m adding this code.
thx
I’m pretty sure that I fixed everything :S .. could you give more info about what errors are you getting from this ?
also .. go to the bottom of the tutorial and download the whole project then check if you can figure out what’s the difference .. I can’t exactly pin point what’s wrong in there
if you need help getting the difference , check my previous comment on how to let me know
This is wrong in the blog: (IUpdateHandler::public void onUpdate)
if (_projectile.getX() >= mCamera.getWidth()
|| _projectile.getY() >= mCamera.getHeight()
+ _projectile.getHeight()
|| _projectile.getY() removeSprite(_projectile, projectiles);
continue;
}
should be (from downloaded source):
if (_projectile.getX() >= mCamera.getWidth()
|| _projectile.getY() >= mCamera.getHeight() + _projectile.getHeight()
|| _projectile.getY() <= -_projectile.getHeight()) {
removeSprite(_projectile, projectiles);
continue;
}
and big thanks for the great tutorial 🙂
Thank you for reporting that !
I got no idea what’s happening here .. guess wordpress made some changes or something is getting parsed as HTML tags
tell me if you found any others
and glad you liked it 😀
only a small thing:
backgroundMusic = MusicFactory.createMusicFromAsset(mEngine
.getMusicManager(), this, “background_music.wav”);
the file from Dan (the one you linked) is named “background_music_aac.wav”
small but leads to a exception/force close 🙂
added a notice about it, I forgot that I renamed it >_<
Hi again, I want you ask simple basic java question 🙂
On this function . removeSprite(_target, targets); How Can it removing sprite I didn’t get it…
public void removeSprite(final Sprite _sprite, Iterator it) {
runOnUpdateThread(new Runnable() {
@Override
public void run() {
mMainScene.detachChild(_sprite);
}
});
it.remove();
}
How is this removing targets from program.
while (targets.hasNext()) {
14
_target = targets.next();
15
16
if (_target.getX() <= -_target.getWidth()) {
17
removeSprite(_target, targets);
18
break;
19
}
can you explain a bit ? because on c++ we can't delete other variables which is not in functions. without pointers but here we are deleting…
from the Java docs , the descriptor for the iterator remove() method is
“Removes from the underlying collection the last element returned by the iterator (optional operation).”
the removeSprite() method takes 2 arguments , the _target object which is the target we wanna remove, and the iterator.
the iterator goes over the linkedlist objects (it just goes over them , doesn’t copy the contents) so when you remove using the iterator remove() method you are actually also removing from the linked list, and it removes the last object it reached
if you removed directly from the linked list , it’ll throw an exception cause the size of the linked list changed , but if you are using the iterator it’ll be handled properly
[almost] everything in Java is an object, so you may consider the iterator as a pointer going over the linked list
Thanks Again I understood object part. Have I understood Correct( iterator part )?
we are using targets.next() it is skipping to next item in the list and when we use targets.remove() it is removing item where it stopped.
yups , that’s correct !
Great!
Thank you very much for your effort, it helps a lot. I followed instructions with any problem 😀
This is great! Though I have to ask…how would you add a background image? If you added another image, wouldn’t that cover the animation?
if you add another sprite behind everything else, then it won’t cover anything, you can try that yourself or just wait for my next tutorial
😉 Thank you!! my will be uploaded to android in few days using this Engine and will be next big thing i hope!! 😀 very good tut never got lost 😀 like in most tut in books or websites :P, thank you!!!!!!!!!!!!!
Cool , let me know when you upload yours !
I wanna check it out 😀
I am pretty sure I am doing something wrong but I have no idea what. I have gone through the code several times. My problem is in the onLoadResources(). Where you initialize the texture regions.
It appears to draw the images on the screen right then and there. For example, when i play the game, I have the “fail” image, “win image”, “ninjas”, “shuriken”, “enemies” and every single image i initialize already drawn.
My fix for it was to change the coordinates when I initalize them too off the screen. i used “mCamera.getWidth()” for the x value instead of the one you used and i changed up the Y value too. So now my game works like yours but I would still like to know the cause of the problem.
Any ideas on what I did wrong?
maybe you are attaching the children when you are not supposed to do so
can you post your code here http://pastebin.com/
and give me the link so I take a look at it ?
Thnx for this excelente tutorial…..Suscribed and looking forward to the next entry.
Regards,
Diego!
Thanks a lot, exactly what I was looking for ! 🙂
Jimmar, i have added different enemies. But i want to remove them only when the user touch in enemy in the screen. The problem is: how i do this ? Thank you for help !
you should make every enemy a touch area, and when touched you remove them
making a sprite a touch area is covered in the 2nd tutorial [V2.0]
OMG, Jimmar !!! I love you man, seriously. You made more two awesome tutorials !!!
Hi ! i am new in AndEngine… and your tutorial helped me a lot! However after i did everything you did and its done good, now i am messing with how to do the image background (another image that i add)
I know i need to do sprite first off all, but when i add the sprite to between mMainScene = new Scene(); and return mMainScene; he just give me ann error (Force close) but for example if i add the sprite to mPauseScene or mResultScene its show up without problem, cant understand… 😦
So waiting for answer, thank you soo much 🙂
I’m not exactly sure how you are putting the background image , but if you are adding it as a big sprite then you can’t add it inside onLoadScene cause you are adding the image to the scene when the scene is not ready
if you wanna add it as a normal sprite then attach it inside onLoadResources().
if it’s still not fixed I’d appreciate if you paste your code on http://pastebin.com/ and gave me the link
also if you checked the DMMS/Logcat , it should give you a stack trace of the error and why it happened [the exception name] provide that too as just saying “ForceClose” is not helpful
you might wanna continue with the tutorials series too, it includes some neat background and animations later on 😛
Tnx for answer! Well from now i have the source code that you give with the tutorial (I wrote everything step by step and everything was good but after some mess with the code he gave me alot of errors so i downloaded the source code )
and of course i add it in onLoadResources(). to…
Can you tell me how can i add big sprite (Or is it the same as normal Sprite function ?) again thank you !
adding a big sprite is the same, just make sure you understand how BitmapTextureAtlas works and that you have enough space to add that
and again, if you continued with the tutorials series [there are 2 more tutorials that continue on this one, the next one got a link in the last section of this one] you would see how to add a big sprite
Cool but what is the command to touch up and down in the player sprite?
am sorry but I didn’t exactly understand what you mean , I explained everything clearly in the tutorial but if there is an issue please provide more info
Nice tutorial. Just looking for some help with an issue I’m having with installing the extensions for the game engine. There are no errors in the code for the game engine itself, but as far as the extensions are concerned, they’re registering a ton of source code errors. Any idea on how to fix this? Thanks in advance.
See ya on the flipside,
Tempest Desh
are you talking about extensions like multiTouch and box2d ?
in tutorial V2.0 I show you how to install multiTouch extension [more or less :P] but it appeared that the multitouch source code actually includes the andEngine source code too so you’d have to get rid of that .. at least that was how the case was with me
if you are talkin about something else, then would you give me more info about what are you talkin about ?
Great Thanks for Super Tutorial, starting understand what for what!!
Hello Jimmar,
How are you? The tutorial is awesome and helped very much.
i want to take ur opinion about something, Is it better to make one IUpdateHandler to detect all events or to make 2 or more handlers (one for sprites, one for bullets,,..etc)?
Waiting for ur reply
Regards
glad you liked the tutorial
I’m not quite sure , but I think that it’d be better to have one update handler [main game loop] unless it doesn’t work well [if it lags or some actions needs priority] then use multiple
Hello Jimmar,
Thanks for your reply,
Please i need your help with something strange. i need the .jar extension files of multiTouch and other extensions but i failed to get them. i tried to clone the extensions from google.code but i failed 😦
if u have them or know how to get them, please tell me.
Thanks again,
Hossam
check the last tutorial in this series , it’s available there
I don’t know how to Thank you, really you are the best. you always save me 🙂
Thanks again,
Hossam
Hello Jimmar,
i have put a pause in my game as u teaches us in ur tutorial, but i have a problem. i put sprites in the pause scene and touch listener on them, (ex: restart images when the player pause the game i put a sprite with restart image) but it doesn’t respond!!!
i have enabled the touch in the scene :
pauseScene.setTouchAreaBindingEnabled(true);
and register to the sprite :
pauseScene.registerTouchArea(go_btn);
the image of restart appeared but no touch. Could u tell me why this issue? i guess it is because the mEngine.stop() ?
waiting for ur reply
you might wanna check this example
https://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/SubMenuExample.java
Very good tutorial and helped my understand the basic concepts of the andengine examples and how to build the basic game, I actually was able to add some personal touch such as sound upon hitting the target ad sound when loosing / wining the game. This was very helpful indeed.
Great tutorial for newbies like me!
Thanks!!!
Great Tutorials…..Help me a lot .
Thanks….
Hi, I’m beginning with AndEngine and was having an hard time finding a good game tutorial. Yours is really great, it helped me a lot understanding how it works and how to do in futurs projects.
Thank you very much and keep going 🙂
Hi, thx a lot! this example was so useful
Hey Jimmar,
Great! Great tutorial! I’m loving it. As a starter on game development, this is big to me. I just found out about AndEngine few days ago and dying to find good tutorials. Yours is great!
Quick basic question though as I am getting myself familiar with the engine. Is mEngine one if the class in BaseGameActivity? I have seen few tutorials using mEngine without any explanation.
mEngine is an object of type Engine inside the BaseGameActivity class , you can view the class in here https://github.com/nicolasgramlich/AndEngine/blob/master/src/org/anddev/andengine/ui/activity/BaseGameActivity.java
Excellent tutorial!
Anyone know how to change the background to an image instead of the blue?
I have answered this in a previous comment .. but oh well
you can put a sprite with the same size as the screen on the back ..
you can also continue with the tutorials to see how to make a moving background
Hey, seems to be a very great tutorial!
But why do i get error messages all the time about the code in eclipse, i follow tutorials but all these errors are coming up. Why is that? Maybe if you know… thanks
I can’t figure out what’s wrong with those info only , could you at least tell me what kind of errors are you getting ?
keep in mind that this is done on AndEngine GLES1.0 not GLES2.0 , if you are using GLES2.0 this won’t work without modifications
try using the jar file that I provided and see if that solves the problems
I did use your jar file in /lib, i’m not that good at coding but when i follow every tutorial i do as people write it and still get all these errors on every line? Maybe i have installed eclipse and so on wrong, if i write some lines of codes that is being used here. It will give X dots everywhere and tell me to maybe create a class or they have another quick fix for it. Every god damn line, if you know anything about it i would be very greatful! Thanks.
Try cleaning the project [project -> clean]
also , are you sure you installed andEngine properly ? have you managed to run your code till the blue screen ? [if this didn’t work then you might not have added the jar file to your build path, go to it in eclipse and right click on it -> build path -> add to build path]
and before that , did you run an android hello world program to make sure that the android sdk is installed properly ? [you may wanna follow an android beginner tutorial first to make sure it’s working]
and don’t copy and paste code , write it on your own 😀
der zabardast tutor dy yar manam dy(in pashto) means
this is awsome tutorial for beginners
Very good tutorial for a beginner and thank you for making it it!
I’m trying to make the part with the blue screen to test if the engine works but some code lines have errors (the x dot). I added those two permisons to the manifest and installed andEngine.jar ( right click on it -> build path -> add to build path ). Also I made a few Hello World android apps in eclipse and it worked so I don’t have a problem with eclipse. If you know what is wrong is please tell me!
Try restarting eclipse, but are you sure that you put andEngine.jar file in the correct place ?
try this too
great tutorial as i read it and basing from all the comments! but the thing, i haven’t tried it yet since i am really newbie in using andengine. Just need a little help Jimmar, can you help me how to install andengine /GLES1.0? i already have my androidSDK and eclpise up and running. also done with hello world tutorial, and it works just fine. your reply would be much appreciated! thank you again and God bless!
you can use the tutorial I linked to that installs GLES2.0, just chose “master” instead of GLES2.0
or you could just use the andengine.jar file that I provided in this tutorial
you could also skip this whole tutorial and jump to my jimvaders tutorial on AndEngine GLES2
Yes, i’ll do that! thank you again Jimmar! 🙂
hello, I am following your tutorial and place of testing to see if the blue screen appears, the game does not open. The engine is in the Build-path correctly.
are you getting any errors ?
I’ve fix the errors, thanks =)
very very very very good tutorial
Thank you….
how to add background with scroll, i work in strategic game,
help how to change splash to activity menu no workme,
ps.good good good tutorial.
if you want to automatically scroll the background use parallax Background.
and that’s out of the scope of this tutorial anyway , I suggest you ask your question at the AndEngine forums
Hi JiMMaR,
First, sorry for my poor English =S
Second, thks for this incredible tutorial!!! =D
And to finish… I try the game in the Eclipses Android Emulator (android 2.2 version) and it runs right but when i try it in a real mobile phone (with android 2.3) it crashes when i try to execute.
Thks for all and continue with this tutorials, they are rly ussefull!!!!
Those Info are not enough , you need to check what the catLog says regarding the crash [the cause of the crash]
if you couldn’t figure it out , use http://pastebin.com/ to paste the output and put the link here
DO NOT POST THE WHOLE LOG AS A COMMENT OR I’LL DELETE IT !!
Thanks for a nice tutorial,
really was helpfull.
🙂
Sir i have no word to saying Thank you for sharing this tutorial.
please send me important links for study of android engine.
I am Beginner to Android.. started developing applications now.. this tutorial is useful for me.. thanks a lot… 🙂
That was it, now works perfectly.
Thanks once again!
Thanks, very nice tutorial.
I was excited to find this great site. I need to to thank you for your time for this fantastic read!! I definitely really liked every bit of it and i also have you book-marked to look at new information on your blog.
Hi Jimmar.
Thanks for this great tutorial! It has definitely helped me understand the things that I was struggling with. Nice site too dude 🙂
Hi Jim,
imported your project into my workspace, it was complied well, but I had a run-time error (COPY FROM LOGCAT):
FATAL Exception : GLThread 11
java.lang.IllegalArgumentException : No EGLConfig found !
…. …..
Any ideas what is missing?
err .. This tutorial was meant to be followed , and not imported as a whole
also , this is for GLES1.0 , you should go to the other tutorial called jimvaders for GLES2.0 tutorial
I don’t really know exactly what’s wrong with your project
hey so i have been looking true the tutorial and like like it vary much but i can’t get it to work if im importing is as a git hub project in any why 😦 and the download link is down
as I told the other guy , this tutorial is mainly meant to be followed not imported
also .. I think you posted on the wrong thread .. I didn’t provide a github link for this tutorial
Nice tutorial.
I was asking my self how to implement different levels. I was thinking to use the CameraScene object and do something similar as you do to pause the game. Do you think this is the right way? Do you know any tutorial for creating different levels in the game?
Thamks
I have 3 solutions that are coming to my mind
1- have each level implemented as a different scene, you get to have full control over what happens in each level [add a camerascene for a loading page to appear at the end of each level and a similar one to be attached at the start of the level to mimic a transition]
2- if your levels only have different enemies , just change the enemy layer, attach different enemies to a new enemy layer and replace the one you already have with the new one [easiest solution :P]
3- if the game grows big , it’d be easier for the long run to be able to design your levels by reading from external xml/txt file where you design the levels there
Brilliant! Im a beginner to Android. I had to make an Android game as part of my school project. This has really helped me a lot. Thanks!
Looking forward to much more from you. 🙂
You are awesome. I hope to see more tutorials from you. Many Thanks.
Awesome work.!!!!.
Excellent Tutorial!!!
I can’t seem to recycle anything? Bullet, and targets both aren’t being recycled. I’ve added the Iupdatehandler, registered it on createscene, and targets are being added, and so are bullets.
Is this because I’m not using GLES 1.0? I’m using 2.0, and I know you made a new tutorial, but I just find this a little better. Can someone help me out? I’ve created 3 projects files already in case if I had made any mistake, but nothing seems to be working. It still shows in Logcat that target, and bullets are not being recycled.
okay.. weird enough, I just booted eclipse today, and everyone is working fine. sometimes.. i just feel like setting eclipse on fire. :> Thank you so much for the tutorial! :] We all really appreciate the time and effort you put into them. keep it up, mate.
very good lesson …
sir can you please help me, I want to make the player on the right side of the screen, which makes the bullets go right to left, please help me with the formula, thanks
hi ,your tutorial is nice,very helpful to me.
i have one doubt ,how to give 3 chances to user the objcet is crossing the screen width.
hi, jimmar
sorry in advance if my english bad .. 🙂
I tried to make a RPG game in android and using a background image. I build it in android version 2.3.1 (gingerbread) but still error projectku … is there a tutorial for the game with a background image?? thanks for the advice ..
if you continue with this series of tutorials, you should see how to create a moving background image in the 3rd tutorial [in Simple Android Game Tutorial V2.0]
but if you want a static image , just put a sprite that covers the whole thing
don’t use the background functions, a simple sprite would do fine
it’s aawwsommmee tutorial.. 🙂
Tutorial doesn’t seem to work for me…is this for an older version of andEngine? Is it possible to get this working for latest code?
Please read the first line of the tutorial
Hi there.. !
That was an awesome tutuorial and it helped me a lot. I created my own first android game and the credit goes to you ! !
https://play.google.com/store/apps/details?id=com.devurapp.retro.racing&hl=en
I would like try playing this ninja game.. Could you please provide me with the link ?
Reblogged this on Tech Trendzy and commented:
Here I go taking on Android Game Development with AndEngine.
This is a detailed simple blog post to help get started with Android Game Development.
Aw, this was a very good post. Taking the time and actual effort to make
a really good article… but what can I say… I procrastinate a whole lot and don’t manage to get nearly anything done.
Thank you, I have just been searching for info about this subject for a long time and yours is the greatest I’ve found out so far. However, what about the bottom line? Are you positive concerning the supply? dkeebfbdeefk