FOR Video tutorial of libgdx AND BOX2D
This blog will take you on an exciting tour to show and teach you about game
development using the open source Libgdx framework. Actually, you have chosen
just the right time to read about game development as the game industry is in a
remarkable state of change.
Creating a libgdx project
Libgdx comes with a file called
To execute the JAR file at the command line:
java -jar gdx-setup.jar
gdx-setup.jar
which is an executable UI and command line tool. You can simply execute the JAR file which will open the setup UI.To execute the JAR file at the command line:
java -jar gdx-setup.jar
Download gdx-setup.jar
Specify your application name, your Java package name, the name of your main class, the output directory, and the path to your android sdk. Next, you can select what platforms you want to support. Note: once chosen, you'll have to add new platforms manually!. Finally, you can select extensions to be included in your app. Some may not work on all platforms, for which you'll get a warning. When you've set everything, click "Generate". Now you are ready to import the project into your IDE, run, debug and package it!
- Eclipse
Importing Your Project
Go to
File -> Import -> Gradle -> Gradle Project
, click Browse and navigate to the root folder of your project, then click Build Model
. After a while, you'll see a root project and subprojects (android, core, desktop, html, ios). Select all the projects and click Finish
. Note that this process can take a minute or two the first time you do it, as Gradle and some dependencies will be downloaded in the background.Running Your Project
- Desktop: Right click the desktop project,
Run As -> Java Application
. Select the desktop starter class (e.g. DesktopLauncher.java). - Android: make sure you have a device connected and that it shows up in DDMS (see Android Developer Guide). Right click your Android project,
Run As -> Android Application
. - iOS RoboVM: Right click the robovm project,
Run As -> iOS Device App
to run on a connected device, orRun As -> iOS Simulator App
to run on the iOS simulator. If you run on a device, you need to provision it to be able to deploy to it! - HTML5: Right click the html project,
Run As -> External Tools Configuration
. Create a new configuration by double clicking theProgram
entry in the left sidebar. Give the configuration a name, e.g. GWT SuperDev. Set the location field to thegradlew.bat
(Windows) orgradlew
(Linux, Mac) file. Set the working directory to the root folder of your project. Specifyhtml:superDev
as the Argument. Press 'Apply', then 'Run'. Wait until you see the messageThe code server is ready.
in the console view, then open the URL http://localhost:8080/html. You can leave the server running. If you change code or assets, simply click theSuperDev Refresh
button in the browser. This will recompile your app and reload the site.
Once this bug in the Gradle tooling API is fixed, we can simplify running the HTML5 by using the Gradle integration. At the moment, the Gradle process will run forever even if canceled.
Introduction to Libgdx
Libgdx is an open source, cross-platform development framework, which is designed mainly, but not exclusively, to create games using the Java programming language. Besides Java, Libgdx also makes heavy use of the C programming language for performance-critical tasks, to incorporate other C-based libraries and to enable cross-platform capabilities. Moreover, the framework abstracts the complex nature of all its supported target platforms by combining them into one common Application Programming Interface (API). One of the highlights of Libgdx is the ability to run and debug your code on the desktop as a native application. This enables you to use very comfortable functions of the Java Virtual Machine (JVM), such as Code Hot Swapping, which in turn lets you immediately see the effect of your changed code at runtime. Therefore, it will significantly reduce your time to iterate through different ideas or even to find and fix nasty bugs more quickly.
Another critical point is to understand that Libgdx is a framework and not a game engine that usually comes with lots of tools, such as a full-blown level editor and a completely predefined workflow. This might sound like a disadvantage at first but actually it turns out to be an advantage that enables you to freely define your own workflow for each project. For example, Libgdx allows you to go low-level so you could add your own OpenGL calls if that really became necessary at some point. However, most of the time it should be sufficient enough to stay high-level and use the already built-in functionalities of Libgdx to realize your ideas.
Goals and Features
Libgdx is a Java game development framework that provides a unified API that works across all supported platforms.
The framework provides an environment for rapid prototyping and fast iterations. Instead of deploying to Android/iOS/Javascript after each code change, you can run and debug your game on the desktop, natively. Desktop JVM features like code hotswapping reduce your iteration times considerably.
Libgdx tries not be the "end all, be all" solution. It does not force a specific design on you. Pick and choose from the features below.
Cross-Platform
A single API to target:
- Windows
- Linux
- Mac OS X
- Android (2.2+)
- BlackBerry
- iOS
- Java Applet (requires JVM to be installed)
- Javascript/WebGL (Chrome, Safari, Opera, Firefox, IE via Google Chrome Frame)
- Windows
- Linux
- Mac OS X
- Android (2.2+)
- BlackBerry
- iOS
- Java Applet (requires JVM to be installed)
- Javascript/WebGL (Chrome, Safari, Opera, Firefox, IE via Google Chrome Frame)
Graphics
- Rendering through OpenGL ES 2.0 on all platforms
- Custom OpenGL ES 2.0 bindings for Android 2.0 and above
- Low-Level OpenGL helpers:
- Vertex arrays and vertex buffer objects
- Meshes
- Textures
- Framebuffer objects (GLES 2.0 only)
- Shaders, integrating easily with meshes
- Immediate mode rendering emulation
- Simple shape rendering
- Automatic software or hardware mipmap generation
- ETC1 support (not available in Javascript backend)
- Automatic handling of OpenGL ES context loss. Restores all textures, shaders and other OpenGL resources
- High-level 2D APIs:
- Custom CPU side bitmap manipulation library
- Orthographic camera
- High-performance sprite batching and caching
- Texture atlases, with whitespace stripping support. Either generatedoffline or online
- Bitmap fonts (does not support complex scripts like Arabic or Chinese). Either generated offline or loaded from TTF files(unsupported in Javascript backend)
- 2D Particle system
- TMX tile map support
- 2D scene-graph API
- 2D UI library, based on scene-graph API, fully skinable
- High-Level 3D APIs:
- Perspective camera
- Decal batching, for 3D billboards or particle systems
- Basic loaders for Wavefront OBJ and MD5
- 3D rendering API with materials and lighting system and support for loading FBX models via fbx-conv
- Rendering through OpenGL ES 2.0 on all platforms
- Custom OpenGL ES 2.0 bindings for Android 2.0 and above
- Low-Level OpenGL helpers:
- Vertex arrays and vertex buffer objects
- Meshes
- Textures
- Framebuffer objects (GLES 2.0 only)
- Shaders, integrating easily with meshes
- Immediate mode rendering emulation
- Simple shape rendering
- Automatic software or hardware mipmap generation
- ETC1 support (not available in Javascript backend)
- Automatic handling of OpenGL ES context loss. Restores all textures, shaders and other OpenGL resources
- High-level 2D APIs:
- Custom CPU side bitmap manipulation library
- Orthographic camera
- High-performance sprite batching and caching
- Texture atlases, with whitespace stripping support. Either generatedoffline or online
- Bitmap fonts (does not support complex scripts like Arabic or Chinese). Either generated offline or loaded from TTF files(unsupported in Javascript backend)
- 2D Particle system
- TMX tile map support
- 2D scene-graph API
- 2D UI library, based on scene-graph API, fully skinable
- High-Level 3D APIs:
- Perspective camera
- Decal batching, for 3D billboards or particle systems
- Basic loaders for Wavefront OBJ and MD5
- 3D rendering API with materials and lighting system and support for loading FBX models via fbx-conv
Utilities
- Custom collections, with primitive support
- Json writer and reader, with POJO (de-)serialization support
- Xml writer and reader
- Custom collections, with primitive support
- Json writer and reader, with POJO (de-)serialization support
- Xml writer and reader
Tools
3rd Party Support
Libgdx can be integrated with many 3rd party tools. We love:
- Spine - 2D Skeletal Animation
- Nextpeer - Mobile multiplayer made easy
- Saikoa - makers of ProGuard and DexGuard
Libgdx can be integrated with many 3rd party tools. We love:
- Spine - 2D Skeletal Animation
- Nextpeer - Mobile multiplayer made easy
- Saikoa - makers of ProGuard and DexGuard
Audio
- Streaming music and sound effect playback for WAV, MP3 and OGG
- Direct access to audio device for PCM sample playback and recording(unsupported in Javascript backend)
- Streaming music and sound effect playback for WAV, MP3 and OGG
- Direct access to audio device for PCM sample playback and recording(unsupported in Javascript backend)
Input Handling
- Abstractions for mouse and touch-screen, keyboard, accelerometer andcompass
- Gesture detector, detects taps, panning, flinging and pinch zooming
- Abstractions for mouse and touch-screen, keyboard, accelerometer andcompass
- Gesture detector, detects taps, panning, flinging and pinch zooming
Math & Physics
- Matrix, vector and quaternion classes. Matrix and vector operations are accelerated via native C code where possible
- Bounding shapes and volumes
- Frustum class, for picking and culling
- Catmull-Rom splines
- Common interpolators
- Concave polygon triangulator
- Intersection and overlap testing
- JNI wrapper for Box2D physics. So awesome, other engines use it as well
- JNI Wrapper for bullet physics
- Matrix, vector and quaternion classes. Matrix and vector operations are accelerated via native C code where possible
- Bounding shapes and volumes
- Frustum class, for picking and culling
- Catmull-Rom splines
- Common interpolators
- Concave polygon triangulator
- Intersection and overlap testing
- JNI wrapper for Box2D physics. So awesome, other engines use it as well
- JNI Wrapper for bullet physics
File I/O & Storage
- File system abstraction for all platforms
- Read-only file system emulation for Javascript backend
- Binary file support for Javascript backend
- Preferences for lightweight setting storage
- FOR Video tutorial of libgdx AND BOX2D
- File system abstraction for all platforms
- Read-only file system emulation for Javascript backend
- Binary file support for Javascript backend
- Preferences for lightweight setting storage
- FOR Video tutorial of libgdx AND BOX2D
No comments:
Post a Comment