AndEngine #1 – Getting Started!

First: Download Library here

Next: Extract the archive and find “andengine.jar“. Add this Library file to your android project, If you don’t know how to add a JAR, watch the video below:

Waiting for the gradle is built successfully.

Next: On your mainActivity, extends “BaseGameActivity” and delete all method. Just like below:

 

public class MainActivity extends BaseGameActivity {
private static final int CAMERA_WIDTH = 480; // the width of the screen
private static final int CAMERA_HEIGHT = 800; // height

// initialize
@Override
public Engine onLoadEngine() {
final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
final EngineOptions engineOptions = new EngineOptions(
true, EngineOptions.ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera
);
engineOptions.getTouchOptions().setRunOnUpdateThread(true);
return new Engine(engineOptions);
}

// where we load resource (sound, images...)
@Override
public void onLoadResources() {

}

// start a scene
@Override
public Scene onLoadScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
final Scene scene = new Scene(2);
scene.setBackground(new ColorBackground(0, 0, 1));
return scene;
}

@Override
public void onLoadComplete() {

}
}

 

Finally: Run it!

A blue screen appeared? ALL OK !

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s