2

Note that this is my first crack at Andengine. I have been playing around with libGdx as a potential for Android game development, but it doesn't suit my needs as I want to only develop for Android and having a 3D engine doing 2D work seems like overkill. I now want to try Andengine and see if it has what I need. The biggest problem with Andengine seems to be the complex naming scheme (I am more prone to typos when engine keywords are umpteen characters long. LibGdx had a simple naming convention (Texture, TextureAtlas, etc..).

However there appears to be a bug with the screen class in the libGdx .jar and my libGdx project is unfortunately going to have to be put on hold. I saw that Andengine was another vastly popular engine and that it had a similar (but not exactly alike) class called a scene. Anyway, here I am.

My code:

private Camera camera;
private static final int CAM_WIDTH = 800;
private static final int CAM_HEIGHT = 480;
private ITexture texture;
private ITextureRegion textureRegion;

public int playerX = 300;
public int playerY = 300;

@Override
public EngineOptions onCreateEngineOptions()
{
    camera = new Camera(0, 0, CAM_WIDTH, CAM_HEIGHT);
    EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAM_WIDTH, CAM_HEIGHT), camera);
return engineOptions;

@Override
public void  onCreateResources()
{
    //Load textures
    try{
        this.texture = new AssetBitmapTexture(this.getTextureManager(), this.getAssets(), “europe.png”)
    } catch (IOException e){}
    this.texture.load();
}

@Override
public Scene onCreateScene()
{
    Scene scene = new Scene();
    scene.setBackground(0.09874f, 0.6274f, 0.8784f);
    Sprite player = new Sprite(playerX, playerY, this.textureRegion, this.getVertexBufferObjectManager());
    scene.attachChild(player);
    return scene;
    }
}

My problem:

Whenever I run the project the my map of Europe is only partially displayed in a triangular shape in the top right corner of my tablet. The map is also flipped upside down.

enter image description here

I cannot use a TextureAtlas because my main computer has broken down and Texture Packer was installed on it, reducing me to having to code on my tablet (using AIDE). I am also using an outdated .jar of Andengine. The reason being is that I cloned the git repo into my game and got a bunch of errors saying there was a corruption in the x86 .so file. I will eventually get it to work (even if I have to modify the blasted game engine myself!!!) but in the meantime I want to learn the basics of the engine.

Does anyone know how to fix my problem? Also, although not required any advice on using Andengine would be greatly appreciated. Thanks in advance!

Extra notes:

No matter what numbers I put into the Sprite player = new Sprite() constructor nothing changes.

Also note that the screen width is purposely set low.

IMPORTANT UPDATE!

I managed to get the cloned repo from GitHub to work with AIDE. I have an ARM Android device, and not a x86 one (I'm not entirely sure many people have a x86 Android). This might help others having this problem:

To fix the compilation errors I went into the android.mk script that initializes the building of the machine code for Andengine. I commented out the x86 and ran my app with a basic Andengine project and it worked. Apparently it was trying to build x86 machine code for my ARM device.

I now have access to the full power of Andengine and can finally trash that crappy, outdated .JAR I had been using until now. This opens up many tutorials for me to use, although I would still like an answer here.

In response to the comment below, I am posting in the question that I copied the code above from a tutorial website. I have determined that I need to learn the basics of Andengine before I start concocting my own messy code base :)

Community
  • 1
  • 1
Jax
  • 402
  • 7
  • 24
  • Looks like the texture coordinates are in the wrong sequence, can you show the code that initialises the textureregion – FunkTheMonk May 19 '15 at 08:35
  • @FunkTheMonk I found my code in one of the few valid examples online. I copied the entire code base. Just checked out a book on Andengine this morning. A "cookbook" by Packt pub. – Jax May 19 '15 at 12:42
  • your image is either bigger than your texture atlas, or you are starting your region off with x and y coords which means its trying to draw it in a space that doesn't exist. Increase the size of of your texture atlas or reduce the size of your image if its > 1024. – sij_a Mar 26 '16 at 19:07

0 Answers0