当前位置:网站首页>Libgdx learning path 01: libgdx introduction and running tutorial
Libgdx learning path 01: libgdx introduction and running tutorial
2022-07-28 19:18:00 【TDSSS】
One 、 Introduce libGDX
libGDX It's an open source, cross platform 2D/3D Game development framework for , It consists of Java/C/C++ Written in language . compatible (Windows/Linux/Android/IOS/HTML) Wait for multiple platforms .
Code is hosted in GitHub:libGDX_GitHubDesktop/Android/HTML5/iOS Java game development framework - GitHub - libgdx/libgdx: Desktop/Android/HTML5/iOS Java game development framework
https://github.com/libgdx/libgdx
framework
The main composition is shown in the figure below ( From Baidu Encyclopedia , Invasion and deletion )

Libgdx from audio、files、graphics、math、physics、scenes、utils These main modules consist of , They correspond to Libgdx Medium Audio operation , File read ,2D/3D Rendering ,Libgdx Drawing related operations ,Box2D encapsulation ,2D/3D Game components , as well as Libgdx Built in tool class .
It provides a clear framework for designing games
The game design architecture is shown in the figure below

Two 、 Generate and import a libGDX project
1、 preparation
- IDE(Android Studio、Eclipse、IDEA All right ) I used Eclipse and Android Studio.
- JDK11+ Although the official say is 8 That's all , But the latest version of project generation requires JDK11 above .
- Maven Prepare the domestic image address
- Android SDK build tools 31.0.0.0+ * Not necessary Only when Android is needed for the project
- RoboVM OSS* Not necessary Project needs IOS You need to prepare when you end
After finishing the preparatory work , We can start the next step , Prepare to build the project
2、 Generating project
The official has prepared a project generation tool gdx-setup
gdx-setup
https://libgdx-nightlies.s3.eu-central-1.amazonaws.com/libgdx-runnables/gdx-setup.jar After downloading, you can directly double-click to open , If it can't be opened, you can also input the command to open
java -jar gdx-setup.jar
Open it as shown in the figure

From top to bottom is
- Project name Project name
- Package name Project package name
- Game class Game main class name
- Output folder Generate project storage address
- Android SDK * Not necessary If I check that Android You need to specify SDK
recommend : Click on Advanced stay Maven Mirror URL Enter the Alibaba cloud image address in

Click on save After saving the settings, click Generate Start building project
The first time you build a project, it will be very slow , Wait a few minutes .
After completion, a success prompt as shown in the following figure will appear , Congratulations on your successful project generation !

3、 Import the project
Preparation before import
Use gdx-setup Project generation , Will automatically download gradle To C:\Users\{ Current computer user name }\.gradle\wrapper\dists
Then configure gradle To system variables and so on , You can refer to
stay Eclipse Import
First, let eclipse Support gradle, stay Window -> Preferences -> Gradle -> Choose Gradle wrapper It can be applied

And then in eclipse in , Click on the top left corner File -> import -> Gradle -> Existing Gradle Project -> Select the folder where the project is located -> Gradle wrapper -> finish You can start importing the project

After successful import, the project structure is shown in the figure
stay Android studio Import
open AS after , Click on Open, Open build.gradle file

Then wait for the project to be imported , After successful import, the project structure is shown in the figure

3、 ... and 、 Run the project
1、 Desktop Project (desktop)
Eclipse
Right click the item name -desktop modular -> Run As -> Run Configurations ->Java Application -> Create a new form
-> stay ② Enter the project name in stay ③ Enter the main class of the project desktop module ->Run


After success, as shown in the figure below

2、 Andrews end project (Android)
Android Studio
Select virtual machine device or real machine , Click on the run , It will be automatically packaged and generated APK And install and run

3、 Web side project (HTML)
Find the project folder under the build project path

Open in this folder DOS window or stay DOS Window into the folder ( Tips : Press and hold... In the folder shift Right click here to open Powershell window )
File path Reference resources (D:\Project\libgdx\gdx-demo2), Enter the following code on the command line
./gradlew html:superDevBegan to run
![]()
After running successfully, it will display

Open the url http://localhost:8080/index.html You can see the game
4、iOS End operation
See this article for specific operations
5、 Command line run ( Expand )
In addition to using tools , In fact, all terminals can be run from the command line
Desktop:
./gradlew desktop:run
Android:
./gradlew android:installDebug android:run
notes : When running with Android command ,ANDROID_HOME Need to point to a valid Android SDK
iOS:
./gradlew ios:launchIPhoneSimulator
HTML:
./gradlew html:superDev
Four 、 A simple little game ( Expand ) * Not necessary
According to the guidance of official documents , The official will teach you how to play a little game of catching raindrops with a bucket , The address is as follows
A simple little game ( The bucket catches raindrops )Before diving into the APIs provided by libGDX, let’s create a very simple “game”, that touches each module provided by the framework, to get a feeling for things. We’ll introduce...
https://libgdx.com/wiki/start/a-simple-game besides , Another document has benefited me a lot , A blogger guides how to use libGDX Make a small game prototype of playing bricks , Very interesting , The address is as follows
LibGDX beginner tutorial( Brick making )
https://colourtann.github.io/HelloLibgdx/index.html
边栏推荐
- pytest 自定义HOOK函数
- 软件测试开发基础|测开中的几个工具开发实战
- 1、 My first wechat applet
- What if the content of software testing is too simple?
- Live broadcast platform software development, JS implementation by alphabetical order
- 【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码
- A priori, a posteriori, likelihood
- SRS4.0安装步骤
- unity CS1513
- Can I get employed after two months of software testing training?
猜你喜欢

Win11系统svchost.exe一直在下载怎么办?

BM11 链表相加(二)

Module 8 of the construction camp

1、 My first wechat applet

Win11电脑摄像头打开看不见,显示黑屏如何解决?

It is the best tool to evaluate six kinds of map visualization software in three categories

QT widget promoted to QWidget
![[R language - basic drawing]](/img/1e/aebf1cbe02c4574671bac6dc2c9171.png)
[R language - basic drawing]

From Bayesian filter to Kalman filter (zero)

Creating new projects and adding your own programs
随机推荐
Software testing dry goods
直播平台软件开发,js实现按照首字母排序
QT with line encoding output cout
Pyg builds heterogeneous graph attention network han to realize DBLP node prediction
uwb模块实现人员精确定位,超宽带脉冲技术方案,实时厘米级定位应用
C and SQL mixed programming, vs need to download what things
Qt: 一个SIGNAL绑定多个SLOT
QT user defined control user guide (flying Qingyun)
Special Lecture 6 tree DP learning experience (long-term update)
【雷达】基于核聚类实现雷达信号在线分选附matlab代码
CTR click through rate prediction practice project of advertising recommendation!
2022杭电多校第二场1011 DOS Card(线段树)
【物理应用】水下浮动风力涡轮机的尾流诱导动态模拟风场附matlab代码
BM14 链表的奇偶重排
How to write a JMeter script common to the test team
2022年最火的十大测试工具,你掌握了几个
unity CS1513
[operation] differences between Oracle, MySQL and sqlserver
2022 Niuke multi School Game 2 J. link with arithmetic progress (three points + enumeration)
Pytest custom hook function