Skip to content

Demens Deum

Soft & Games

  • Программы
  • Игры
  • О нас
  • Написать нам
  • Русский
    • English

Туториал: Demon’s Cave на GitHub

С днем победы!

Сегодня код Demon’s Cave для Android выходит на GitHub:
https://github.com/demensdeum/DemonsCaveAndroid

У меня сейчас нет времени для записи видео, поэтому здесь короткая текстовая версия туториала.
Вообще вы можете скачать код игры Demon’s Cave и собрать на своей машине.
Сегодня мы будет выводить лого компании Demens Deum на движке Rajawali (OpenGL-ES 2.0)

1. Скачайте Demens Deum лого
http://demensdeum.com/games/demonsCave/data/graphics/demensdeumLogo.png

2. Установите Gimp и поверните картинку по горизонтали

sudo apt-get install gimp

3. Добавляем вывод активити на полный экран девайса
Добавьте этот код в метод onCreate класса MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 requestWindowFeature(Window.FEATURE_NO_TITLE);

Добавьте/замените настройки res/values/styles.xml

<resources>


<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

<item name="colorPrimary">@color/colorPrimaryitem>
<item name="colorPrimaryDark">@color/colorPrimaryDarkitem>
<item name="colorAccent">@color/colorAccentitem>
<item name="android:windowNoTitle">trueitem>
<item name="android:windowActionBar">falseitem>
<item name="android:windowFullscreen">trueitem>
<item name="android:windowContentOverlay">@nullitem>
<style>

<resources>

4. Инициализируем двухмерную камеру Camera2D
Добавляем приватное поле Camera2D в класс Renderer.class

import org.rajawali3d.cameras.Camera2D;

Добавляем метод инициализации камеры Camera2d

    protected void initializeCamera() {
gameCamera = new Camera2D();

getCurrentScene().addCamera(gameCamera);
getCurrentScene().switchCamera(gameCamera);
}

5. Добавляем примитив плоскость (Plane) с картинкой demensdeum_logo.png
Добавляем приватное поле Plane в класс Renderer.java

    private Plane plane;

Добавляем метод инициализации Plane

    protected void initializePlane() {
Material material = new Material();
material.enableLighting(false);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setColor(0);

Texture earthTexture = new Texture("Earth", R.drawable.demensdeum_logo);
try{
material.addTexture(earthTexture);

} catch (ATexture.TextureException error){
Log.d("DEBUG", "TEXTURE ERROR");
}

plane = new Plane(1, 1, 2, 2);
plane.setPosition(0,0,0);
plane.setMaterial(material);
}

Меняем код инициализации сцены

@Override
protected void initScene() {
initializeCamera();
initializePlane();

getCurrentScene().addChild(plane);
getCurrentCamera().setZ(200.2f);
}

6. Добавляем demensdeum_logo.png в res/drawable папку
7. Собираем-проверяем на вашем Android девайсе

screenshots

Вы должны увидеть картинку – логотип компании Demens Deum, если она будет по горизонтали зеркальная – поверните ее в Gimp сначала.
Продвинутые пользователи могут ничего не зеркалить, вам стоит попробовать использовать самую последнюю версию Rajawali, некорректные текстурные координаты для Plane это известная проблема старых версий.

Спросите меня, если у вас есть вопросы, и если нет тоже.

Posted bydemensdeumMay 9, 2016August 26, 2016Posted inТуториалыTags:camera2d, Demens Deum, github, logo, rajawali, tutorial

Published by demensdeum

View all posts by demensdeum

Post navigation

Previous Post Previous post:
Туториал: Делаем игру на Андроид. Крутим землю. Rajawali
Next Post Next post:
Отчет о разработке Demon’s Cave для Андроида

Make Love Not War ☮️

Demens Deum, Proudly powered by WordPress.
We use cookies on our website. By clicking “Accept”, you consent to the use of ALL the cookies. Мы используем куки на сайте. Нажимая "ПРИНЯТЬ" вы соглашаетесь с этим.
Cookie settingsACCEPT/ПРИНЯТЬ
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT