AuthorJohannes Borchardt

Getting started with libgdx

This is a guest post by Alexander Fröhlich. Alexander is a freelance developer and is supporting ANDLABS at its libgdx-based development. 

 

libgdx is an open source, Open GL based, cross platform game development framework. It’s supporting Web, Desktop, Android and iOS. This step by step introduction will teach you how to get started with the initial setup and your very first hello world in libgdx.


1 Prerequisites


2 Setup a new libgdx project

  • Choose “CREATE” in order to create a new project and enter the following setup screen
  • ConfigurationTab lets you set names for projekt/package/mainGameClass and the destination folder
  • Library Selection lets you download all required libraries (libgdx as the core libs are always required)
  • Overview gives you an outlook on which projects will be created
  • Generation checks for a valid setup (green colored) and when read you can open the generation screen (launch window coming up)
  • Launch displays the log output while creating the project. Here just click “Launch” to finalize your setup and create all chosen libgdx projects

3 Import libgdx projects into eclipse

Now we need to import these project into eclipse (other IDE provide similar options -> wiki)
NOTE: iOS projects have to be imported with XCode only (apple-mac) -> wiki

 

4 Project launch configurations

You now should see four projects… YourGameName, YourGameName-Android, YourGameName-Desktop and YourGameName-html within eclipse’s package explorer. The first one being the core source project holding all your game logic and the latter being launcher projects holding only one starter class.


DESKTOP
Go to your newly imported desktop project and launch its Main.java (run as java application)
This should bring up this demo screen. As you can see libgdx already provides you with a small hello world application.

 

ANDROID
Your eclipse android project should have been marked with a red x (eclipse way of telling you something is wrong with your setup).
Go to project properties (ALT-ENTER) and select your available Android-SDK-version..
NOTE: on versions prior to 4.0 you might have to remove the line

android:configChanges=”keyboard|keyboardHidden|orientation|screenSize”>

from your AndroidManifest.xml as this option being unsupported

After this, refresh both your core source project and your android project and rebuild both projects.
Now right-click on your Android project and choose “Run as Android Application”.

A dialogue will come up showing all connected devices and you may either want to push it on one of these or use the emulator (which will automatically start without any registered devices).
Make a choice and the game will be transfered on started on your device.

HTML5
A red cross over your project might mean that you have to install GWT.
After having GWT set up correctly, right-click on your HTML5-project and choose “Run as Web Application”.
Double click on the provided link ( e.g. http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997)
A browser window will show up maybe requiring to install a GWT Developer Plugin
(Development Mode requires the Google Web Toolkit Developer Plugin).
If so, do restart the browser and you should see the libgdx logo screen.

Now you are up and ready to start building your own libgdx-based game. If you have any questions, please post them in the comments.
 

Update [2013-09-13], important links:

Starter Tutorial:
http://bitowl.de/day1/

Libgdx Wiki
https://code.google.com/p/libgdx-users/wiki/AAATopPaaage

Forum: (most problems have been solved already.. just learn to query it wisely like the web :-)
http://www.badlogicgames.com/forum/

New design and the Droid-Blog Newsletter

It’s been quite on this blog in the last months. That’s now over.

Droid-Blog is reincarnated with an all new, more flat and responsive design.

Moreover, from now on you can subscribe to the all new Droid-Blog Newsletter.

You will get:

  • News about ongoing topics in the Android world
  • Updates about recent publications and tutorials
  • Blog post summaries
  • And more

If you have any special topics you’d like me to cover, please fell free to share it in the comments.

If you are interested, just sign up with your email address here:

Startapp

This is a sponsored post.

While being sponsored, this content is not biased by money. While it is usually not my attitude to rant on products publicly, it is also not my attitude to say products are good if they aren’t. This also applies for this post.

 

Startapp – you might have heard of it or seen it on the top right banner of this blog. Startapp is an enabler of android monetization that offers an alternative to common banner ads by, in my opinion, a more intrusive way of advertisement.

Startapp is, according to AppBrain, number eight in the ranking of the most used ad networks on Android worldwide, with 1.84% of all apps. According to them, they are currently used by 19,000 apps with a total of ~600 million downloads.

Startapp essentially offers three ways of monetization, by integrating their SDK into one’s apps, by referring other developers that then use their SDK and by exit ads.

Monetization, way 1: SDK integration

Integrating the Startapp SDK enables monetization on a pay-per-install base by advertising on the user’s device.

For this way of monetization, two options are offered:  Full and partial integration.

The partial Integration will setup a 1×1 widget on the user’s home screen, imitating an icon. Furthermore, the homepage of the phone’s browser will be set by the SDK. Both the icon and the browser homepage lead to online offer- or app-search walls, provided by Startapp.

The full integration additionally adds bookmarks to the native browser’s bookmarks list.

Regarding payment, the partial integration offers the following payments per download:

New user U.S $ 0.04
New user non U.S $ 0.008
Returning User U.S. $ 0.01
Returning User Non U.S. $ 0.005

The full integration offers the following payments:

New user U.S $ 0.055
New user non U.S $ 0.01
Returning User U.S. $ 0.01
Returning User Non U.S. $ 0.005

So if you have an app that generates a lot of downloads but does not have much display time, this monetization method may be for you. Also if you have an app that has a one-time usecase or if you just want to get a little extra to your traditional income.

Monetization, way 2: Referral Program

The second way of monetizing with Startapp is by referring other developers. One must be registered at Startapp but may not have an app with the integrated Startapp SDK to refer to another developer. Again, it is one-time-payment based and looks like this:

For the first 100 downloads a developer referred by you makes, you’ll get $10. For every other of the following download-levels he crosses, you’ll get an extra payment:

At 1,000 downloads + $25
At 10,000 downloads +150
At 100,000 downloads +$500
At 1,000,000 downloads +$1,500

All together summing up to up to $2,185 per referred developer.

If you know a lot of developers that may be willing to use Startapp, this is exactly the way to go. If their apps also have a lot of downloads, what are you waiting for?

Monetization, way 3: Exit ads (beta)

The third thing Startapp offers are exit ads. Exit ads are fullscreen ads that are shown once an application is closed. They are fullscreen ads for single apps. The interesting thing is that they are impression and not, like usually common, click based.

Currently exit ads are in a private beta phase but will be released to the public in about a week. Since I’m not in the group of beta testers, I unfortunately can’t tell you more about this option at the moment.

The Startapp SDK

Now that you are informed about the ways of monetization Startapp offers, some words on the SDK.

The integration of the SDK is a rather easy process. Since no banner ads are shown anywhere, there’s no need to manipulate layouts in any way. Adding one line of code to the Application object or to the applications launcher-Activity is all that needs to be done on the Java-side, at least for options one and two. In the Android manifest, some metadata must be provided and a Service and an Activity need to be registered.

The part that made breathe heavy is the number of permissions: To get the full integration running on a plain Android device (without custom launcher), eight permissions are needed, six of them for the partial integration.

Running a quick decompiler over the SDK shows: It is obfuscated, which is not unexpected, since it is a proprietary product. There was a discussion on why and whether it is useful for an ad network to make their SDKs open source with Startapp and Airpush on the Droidcon London. Of course there are pro and contra arguments,  I personally like the Open Source version better because I simply don’t like waiting for patches.

Looking over their code they seem to collect some data like the device’s manufacturer, brand, OS and display metrics. All in all nothing that would make me not use their SDK.

Intrusiveness and Play Store’s Content Policy Requirement

Startapp is a intrusive ad network in the way that it provides advertisements to the user outside of the actual app and modifies the phones environment. Looking at it the other way it is a non-intrusive ad network that keeps one’s application free from ads. I’m not entirely sure which is the preferred way of the gros of users, in the end the decision whether or not to give Startapp a try is on you.

When integrating Startapp, I have to say, I was heavily reminded of the old browser days in which you suddenly had a totally different starting page which you, in the most cases, weren’t able to remove.

Looking closer it is visible that Google and Startapp put a little more emphasis on the user’s acceptance:

The Startapp opt-in dialog

The Startapp opt-in dialog

  1. It is not hidden: The app’s description on the Play Store has to include a standartised text explaining that the app can add bookmarks, a new homepage and an icon to the phone.
  2. It is opt-in: Whenever a Startapp-Application is first started, a Dialog is shown that clearly lists what the will get when he is accepting  to use Startapp. This dialog is not shown if only the exit ad option has been chosen.
  3. It is back-trackable: Whenever the Startapp search is shown, the app that is responsible for the install is mentioned on the page.
If you know a bit about the topic, you probably already realized that by this steps, Startapp is compliant to the Play Store’s Content Policy Requirement.

Conclusion

Startapp is, undoubtedly, offering an alternative monetization solution to conventional banner ads. It may be seen as intrusive, and there are reasons for that. Still, there also are reasons why Startapp is where it is today. So if you are an android developer, feel free to try take a look at it.

Also, please feel invited to share your opinion on Startapp and similar networks. I’m sure they will read your comments.

Introduction to AndEngine – Getting the code

In this series I will tell you how to use one of my favorite Android 2D Game Engines, AndEngine. We will go step by step through the processes, starting at simply getting the code, continuing with drawing sprites, using cameras, physics and so on.

AndEngine was started by Nicolas Gramlich as part of his Bachelor’s thesis in the beginning of 2010. It is an engine that provides lots of powerful features while hiding more advanced things like Open GL calls from the developer. It provides lots of extensions like a  Robotium extension, a Box2D extension, which is mostly written and maintained by badlogicgames‘ Mario Zechner for his libGDX-project, a SVG extension or a TMX tiled maps extension.

It has been used in various featured games like Greedy Spiders, Noogra Nuts or Zynga’s Dream Zoo.

Let’s get started.

 

Getting the code

At the very beginning you’ll need to download the most recent version of AndEngine. To do that, open your console, go to the directory of your choice and do a git clone of the engine by typing

git clone git://github.com/nicolasgramlich/AndEngine.git

That’s all. You now have a powerful game engine, ready to be used on your computer or mobile device.

Now here’s a story: When AndEngine was written, the author had to make a choice: did he want to write lots of useful code or lots of useful documentation? He chose the more fun part and that’s why AndEngine provides little to no documentation, which is one of its most frequent points of criticism. However, the source is all open, you can read it, change it, do whatever you like with it. There are the AndEngine forums and Nicolas tries to write the code in a way that it’s documenting itself.

In order to provide the developers an idea of what AndEngine can do, the AndEngine samples were created. You can get them by also cloning the git repository:

git clone git://github.com/nicolasgramlich/AndEngineExamples.git

As you can now see there are a lot of dependencies to the different extensions. Go ahead and clone them:

git clone git://github.com/nicolasgramlich/AndEngineAugmentedRealityExtension.git
git clone git://github.com/nicolasgramlich/AndEngineLiveWallpaperExtension.git
git clone git://github.com/nicolasgramlich/AndEngineMODPlayerExtension.git
git clone https://github.com/nicolasgramlich/AndEngineMultiplayerExtension
git clone https://github.com/nicolasgramlich/AndEnginePhysicsBox2DExtension
git clone https://github.com/nicolasgramlich/AndEngineSVGTextureRegionExtension
git clone https://github.com/nicolasgramlich/AndEngineTexturePackerExtension
git clone https://github.com/nicolasgramlich/AndEngineTMXTiledMapExtension

Now you have a lot of code. Import them into your IDE of choice. Your workspace should now look something like this:

Let’s start a look at the examples. Connect your device or start an emulator with GPU emulation and run the AndEngineExamples on it.

AndEngine physics example

AndEngine physics example

What you will find is an overview over AndEngine’s many features.

There are two important branches of AndEngine: The GLES2-branch and the GLES2-AnchorCenter branch. Since the latter will become the main branch soon, it is recommended to pull its code too. To do so, just go into each of your AndEngine-projects using your shell and execute

git pull origin GLES2-AnchorCenter

You might want to switch to this branch now by executing

git checkout -b GLES2-AnchorCenter origin/GLES2-AnchorCenter

Now take your time to play, take a look into the code and look forward to the next part of this series in which we will go through the basic parts of the engine.

 

If you are having problems compiling any of AndEngine’s code or issues cloning the repositories, please post a comment.

© 2024 Droid-Blog

Theme by Anders NorenUp ↑