Ciele
- Vygenerovanie projektu
- Nastavenie projektu
Úvod
-
V tomto úvodnom cvičení vygenerujeme nový LibGDX projekt a nastavíme potrebné knižnice
Postup
-
Stiahnite si zip archív resources/lines.zip kde sa nachádzajú všetky potrebné súbory a knižnice, ktoré budeme využívaťÚloha: Vygenerujte nový projekt pomocou LibGDX generátora podľa návodu:Obr.: Setup 1Poznámka: Vyberte si cestu kam vygenerujete projekt, a cestu k Android SDKObr.: Setup 2Poznámka: Po úspešnom vygenerovaní môžete projekt otvoriť v prostredí IntelliJ IDEA (File->Open build.gradle v hlavnom adresári projektu)
-
Pre úspešné nastavenie projektu potrebujeme splniť nasledovné kroky:Úloha: Nastavte projctSDK pre android modul (budeme potrebovať Android SDK)Poznámka: Tento krok môžeme dočasne vynechať, avšak ak ho vynecháme, budeme potrebovať pozmeniť build.gradle skript pre cely projekt tak, aby sa android modul nekompilovalÚloha: Nastavte working directory pre desktop launcher na adresár assets z modulu AndroidÚloha: Nakopírujte knižnice z adresára lib_desktop z archívu, ktorý ste stiahli do adresára lib v module desktop. To isté spravte pre moduly android a core (lib_android, lib_core). Pridajte príkazy na kompiláciu týchto knižníc do build.gradle nasledovne:
project(":desktop") { apply plugin: "java" dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" compile files('./lib/antlr-2.7.7.jar') compile files('./lib/dom4j-1.6.1.jar') compile files('./lib/hibernate-commons-annotations-4.0.2.Final.jar') compile files('./lib/hibernate-core-4.2.2.Final.jar') compile files('./lib/hibernate-jpa-2.0-api-1.0.1.Final.jar') compile files('./lib/javassist-3.15.0-GA.jar') compile files('./lib/jboss-logging-3.1.0.GA.jar') compile files('./lib/lib/jboss-transaction-api_1.1_spec-1.0.1.Final.jar') compile 'mysql:mysql-connector-java:5.1.6' compile files ('./lib/javax.persistence.jar') compile files ('./lib/javax.annotation.jar') compile files ('./lib/javax.ejb.jar') compile files ('./lib/javax.jms.jar') compile files ('./lib/javax.resource.jar') compile files ('./lib/javax.servlet.jar') compile files ('./lib/javax.servlet.jsp.jar') compile files ('./lib/javax.servlet.jsp.jstl.jar') compile files ('./lib/javax.transaction.jar') } } project(":android") { apply plugin: "android" configurations { natives } dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" compile files('./libs/robospring-1.0.5.jar') } } project(":core") { apply plugin: "java" dependencies { compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" compile files('./libs/robospring-1.0.5.jar') compile files('./libs/commons-logging-1.2.jar') } }