如何使A"的Hello World"与Android Studio中andEngine在Mac上 [英] How do I make a "Hello World" with andEngine inside Android Studio on a Mac

查看:298
本文介绍了如何使A"的Hello World"与Android Studio中andEngine在Mac上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了很多教程,他们都相当复杂,现在要遵循或部分无关。怎样使一个Hello World使用andEngine和Android工作室在Mac上的Andr​​oid?


解决方案

这是我作为Android的工作室V1.0的经验,在Macintosh上设置一个Hello World的例子。 (虽然这是一个蓝色的背景。)


  1. https://github.com/nicolasgramlich/AndEngine ,并在桌面克隆。

  2. 通过转到文件创建新库 - >项目结构(⌘)然后选择在左上角的+按钮。在更多的模块选择的An​​dr​​oid库。更改应用程序/库名称为AndEngine,模块名称为AndEngine,并且包名称为org.andengine。在接下来的屏幕没有选择活动并点击完成。

  3. 请您的默认模块(应用程序是它在我的项目被称为)依赖于AndEngine通过点击项目结构模块上,然后单击依存关系选项卡,然后pressing底部的+图标中心并选择3.模块依赖,然后选择您的新创建AndEngine模块。

  4. 转到您的克隆AndEngine文件夹,打开SRC /组织/ andengine文件夹,然后选择所有和它的所有复制到项目的AndEngine / src目录/主/ JAVA /组织/ andengine文件夹中。

  5. 由新人换旧人/主/文件夹从AndEngine克隆文件夹的根目录下的Andr​​oid清单文件复制到项目的AndEngine / src目录。


  6. 复制下面的摘录code和用它替换您的MainActivity code。



 包com.mycompany.myapplication;
//包是你自己的,不用更换上面的行进口org.andengine.engine.camera.Camera;
进口org.andengine.entity.scene.Scene;
进口org.andengine.entity.scene.background.Background;
进口org.andengine.engine.options.EngineOptions;
进口org.andengine.engine.options.ScreenOrientation;
进口org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
进口org.andengine.ui.activity.SimpleBaseGameActivity;公共类MainActivity扩展SimpleBaseGameActivity {    私人相机拍照;
    私有静态最终诠释CAMERA_WIDTH = 800;
    私有静态最终诠释CAMERA_HEIGHT = 480;    @覆盖公共EngineOptions onCreateEngineOptions(){
        相机=新照相机(0,0,CAMERA_WIDTH,CAMERA_HEIGHT);
        EngineOptions engineOptions =新EngineOptions(真实的,ScreenOrientation.LANDSCAPE_FIXED,
        新FillResolutionPolicy(),摄像头);
        返回engineOptions;
    }    @覆盖保护场景onCreateScene(){
        一幕一幕=新场景();
        scene.setBackground(新背景(0.09804f,0.6274f,0.8784f));
        返回现场;
    }    @覆盖保护无效onCreateResources(){
    }
}

来源:

http://www.matim-dev.com/你好世界---基本-example.html的

http://geq-i.blogspot.com/2014/02/how-to-setup-andengine-in-android-studio.html

@RafaelSkubisz从无法AndEngine添加到Android工作室答案

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?

解决方案

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.)

  1. Goto https://github.com/nicolasgramlich/AndEngine and clone in desktop.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

  6. 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

这篇关于如何使A"的Hello World"与Android Studio中andEngine在Mac上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆