I have tried a lot of tutorials and they are fairly complicated to follow or partly irrelevant now. How do I make a Hello World for Android using andEngine and Android Studio on a Mac?
Asked
Active
Viewed 373 times
1 Answers
1
This is my experience as of Android Studio v1.0 on a Macintosh to setup a Hello World example. (Although it's a blue background.)
- Goto https://github.com/nicolasgramlich/AndEngine and clone in desktop.
- Create a new library by going to File -> Project Structure (⌘;) then selecting the + button on the upper left hand corner. Under "more modules select "Android Library." Change the application/library name to "AndEngine", the Module name to "AndEngine", and the Package Name to "org.andengine". On the next screen don't select an activity and click finish.
- Make your default module ("app" is what it was called in my project) dependent on AndEngine by clicking on the module in the project structure, then clicking the dependencies tab, then pressing the + icon on the bottom center and selecting "3. Module dependency" then select your newly created AndEngine module.
- Goto your cloned AndEngine folder and open the src/org/andengine folder and then select all and copy all of it into your project's AndEngine/src/main/java/org/andengine folder.
Copy the android manifest file from the root of the AndEngine cloned folder into your project's AndEngine/src/main/ folder by REPLACING the old one.
Copy the excerpt code below and replace the code in your MainActivity with it.
package com.mycompany.myapplication;
//package being your own, do not replace the line above
import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
import org.andengine.ui.activity.SimpleBaseGameActivity;
public class MainActivity extends SimpleBaseGameActivity {
private Camera camera;
private static final int CAMERA_WIDTH = 800;
private static final int CAMERA_HEIGHT = 480;
@Override public EngineOptions onCreateEngineOptions() {
camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
new FillResolutionPolicy(), camera);
return engineOptions;
}
@Override protected Scene onCreateScene() {
Scene scene = new Scene();
scene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
return scene;
}
@Override protected void onCreateResources() {
}
}
Sources:
http://www.matim-dev.com/hello-world---basic-example.html
http://geq-i.blogspot.com/2014/02/how-to-setup-andengine-in-android-studio.html
@RafaelSkubisz answer from Unable to add AndEngine to Android Studio