AndEngine Tutorials

1. Getting Started:

2. Entities:
  • Sprites.
  • Tiled Sprites and Animated Sprites.
  • Removing Entities.
  • Using Entities as a Layers.
  • Entity Modifiers.
  • Creating Background.
  • Handling touch events.
  • Scenes.
  • HUD.
  • Creating Menu Scene. 
  • Scenes management. 
  • Handling collisions between entities. 
  • How to create Text properly.

3. Handling Touch Events: 

  • Using Scene touch listener. 
  • Creating left/right game controller buttons. 
  • Handling native Android key events. 
  • Catching Continuous Touch. 
  • Catching Long Click. 

4. Basic Stuff:

  • "Hello World" - basic example.
  • Loading game resources (graphics, fonts and sounds) 
  • Sound and Music.
  • How to design your game? Useful concept 'pattern'.
  • Splash Screen - easy way + code template.
  • Chasing Camera.
  • Setting Camera bounds.
  • Moving Camera smoothly (from point A to B)
  • FPS Counters.
  • Handling onResume, onPause and onDestroy.

5. Physics:

  • Creating Physics World.
  • Differences between body types.
  • Creating Bodies.
  • Handling Collisions between bodies.
  • Removing Body completely.
  • Physics Debug Renderer.
  • Irregular Body Shapes.
  • Creating Sensors.
  • How to overcome gravity forces. 
  • Destroying physics world and all physics objects. 
  • Joints - introduction.
  • Revolute Joint. 
  • Distance joint. 
  • Prismatic joint. 
  • Weeld joint. 
  • Wheel joint.
  • Rope joint. 

6. Game Features:

  • Creating "coin"
  • Handling Jump Feature.
  • Creating Flying Enemy.
  • Creating Zone/Area.

7. Misc - useful:

  • Get cheap domains & web hosting (vouchers!)
  • Super fast emulator - record promo video easily! 
  • Data Storage.
  • SVG Extension - advantages & disadvantages.
  • What device should I buy?
  • Tips and tricks - how to improve performance.
  • Texture Packer - how to use. 
  • Texture Packer - load ITiledTextureRegion. 
  • Texture Packer - Get ride of Sprite Artifacts.
  • Dithering - improve gradient quality. 
  • Reduce memory usage with dithering. 
  • How to restart scene/level. NEW!

How can include external jar on Netbeans project

Hello friends today i am telling you how to include external jar into your Netbeans project.
One of my friend ask me a question :
When I run "clean and build" the .jar file that is being created only runs if the lib folder is at the same folder of the .jar file.
So if I move the jar file to the desktop and leave the lib folder in the dist folder, the jar file will give me an exception.
How can I deal with this problem?
How can include external jar on Netbeans project,include external jar on Netbeans project,external jar on Netbeans project,jar on Netbeans project,Netbeans project,

I solved this by creating just one jar file with all libraries inside, adding the following to my build.xml file in NetBeans:
<target name="-post-jar">
  <jar jarfile="dist/Combined-dist.jar">
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="lib/commons-io-1.4.jar" excludes="META-INF/*" />
    <zipfileset src="lib/ninja-utils-3.2.jar" excludes="META-INF/*" />
    <zipfileset src="lib/unicorn-1.0.jar" excludes="META-INF/*" />
        <attribute name="Main-Class" value="com.example.mypackage.Main"/>

This creates a jar file (Combined-dist.jar) which is the combination of the dist jar and the specified library jars (in this case, commons-io-1.4.jar,ninja-utils-3.2.jar and unicorn-1.0.jar). You have to be sure to specify your Main Class package for the new jar file or it won't run when you try to open it.

AndEngine - Core Terminology

In this article, I will try to cover description, of the most important engine concepts. Brief information, such as description of most frequently used classes and their extensions.
AndEngine - Core Terminology,Core Terminology,

  • Engine:

The Engine make the game proceed in small discrete steps of time. The Engine manages to synchronize a periodic drawing and updating of the Scene, which contains all the content that your game is currently handling actively. You can use also subclasses:
LimitedFPSEngine - tries to achieve a specific amount of updates per second.

  • IResolutionPolicy:

An implementation of the IResolutionPolicy interface is part of the EngineOptions. It tells AndEngine how to deal with the different screen-sizes of different devices. I.e. RatioResolutionPolicy will maximize the SurfaceView to the limiting size of the screen, while keeping a specific ratio. That means objects won't be distorted while the SurfaceView has the maximum size possible.

  1. RatioResolutionPolicy - keep everything scaled in in proper ratio (disadvantage - black lines might occur)
  2. FillResolutionPolicy - fill whole resolution (disadvantage - images might be stretched)

  • Camera:

A Camera defines the rectangle of the scene that is drawn on the screen, as not the whole scene is visible all the time. Usually there is one Camera per Scene. There are subclasses with more functions, example:

  1. BoundCamera - you might specify bounds for your scene.
  2. ZoomCamera - you might enable zooming, pinch zoom, and scrolling camera.

  • Scene:

The Scene class is the root container for all objects to be drawn on the screen. A Scene has a specific amount of Layers, which themselves can contain a (fixed or dynamic) amount of Entities. There are subclasses, like the CameraScene/HUD/MenuScene that are drawing themselves to the same position of the Scene no matter where the camera is positioned to.
HUD - usage for example for score (it has to be all the time in the same position, follow camera changes)

  • Entity:

An Entitiy is an object that can be drawn, like Sprites, Rectangles, Text or Lines. An Entity has a position/rotation/scale/color/etc.

  1. Sprite - entity with texture
  2. TiledSprite - entity with tiled texture, you may switch between tiles.
  3. AnimatedSprite - extension of the TiledSprite, you may animate tiles in specified intervals.

  • Texture:

A Texture is a 'image' in the memory of the graphics chip. On Android the width and height of a Texture has to be a power of 2 (in latest GLES2 this rule is not required, so its really useful to reduce memory usage) Therefore AndEngine assembles a Texture from a couple of ITextureSources, so the space can be used better.

  • TextureRegion:

A TextureRegion defines a rectangle on the Texture. A TextureRegion is used by Sprites to let the system know what part of the big Texture the Sprite is showing.

How to Setup AndEngine for android game development

If you wish to know how to setup the latest AndEngine, please check the video made by RealMayo. It is a detailed tutorial about how to setup Eclipse, Android SDK, download and install the latest AndEngine and how to run the AndEngine examples.
How to Setup AndEngine for android game development,Setup AndEngine for android game development,AndEngine for android game development,android game development,

This videos show how to install the latest version of the engine (which is the GLES2 version).
 You can get it from this github (official from andengine creator) - just make sure to use proper branch - LINK.

What is AndEngine android game framework

AndEngine is a free open source OpenGL android game engine, developed by  Nicolas Gramlich. It covers the most important OpenGL aspects, which means even if you don't have experience with OpenGL - you can still create great games/applications using this engine, the most important thing obviously is proper Java programming experience.
Introduction to the AndEngine,to the AndEngine,AndEngine,AndEngine, tutorials,AndEngine game development

Most important features of the engine:

  • Scaling across various devices (different resolutions)
  • Multi touch support.
  • Physics extension - Box2D (the one used by for example AngryBirds)
  • TiledMaps in TMX format support.
  • Particle Systems.
  • Live Wallpaper extension.

Benefits from using AndEngine:

  • Free and open source.
  • Most important aspects of every game are covered already by the engine.
  • You don't really need OpenGL experience (but it might be useful, obviously)
  • Fast, well designed and organized engine.
  • Relatively big, active and helpful community.
  • Great engine extensions.
  • Plenty of examples, showing off engine capabilities.

Major drawbacks:

  • There is almost no code documentation.
  • Sometimes slower in comparison to other engines.
  • Lack of documentation is the main difficulty while starting (hard to understand every parameter etc)

But instead of documentation, this engine has great example projects, showing most  every engine capability, it's a great way to check and understand how it work, hopeful while developing your own application. Also as mentioned, the engine community is very helpful, so you can always expect help from different developers. Hopefully this website will also help newcomers (as well as more experienced people) to understand how it works and improve the quality of your games!

Important Links :

What is reflection and use in real life

Hello java developer today i am telling you what is reflection and use of reflection in real life.
Reflection is one of those things like multi-threading where everyone with experience of it says “Don’t use it unless you absolutely have to
 Above quote is absolutely true for all for us alike. This immediately back-fired me with lots of requests to come up with some real life "good" examples of reflection, and possible scenarios where a developer will be needing it. I promised to come up with my leanings/thoughts on this specific topic, and so here in this post, I will discuss the same i.e. real life practical examples of reflection in java.

What is reflection and use in real life,reflection and use in real life,use in real life, real life practical examples of reflection in java,life practical examples of reflection in java,practical examples of reflection in java,examples of reflection in java,reflection in java,reflection java,reflection in java

Q. When somebody would need Reflection?

Having said that in one sentence, let me elaborate it further. Java is strongly typed language with all the "good" features of OOPs. In practical, if you know the classes you are dealing with in your application, you may never ever come across a situation where you will need reflection. “Never ever”. You can accomplish any task, fulfill any requirement without reflection when you know the classes you are going to use.

But as soon as, you are told to deal with classes which you don’t know at time of writing the code, and you must write code in too general way such that it can handle any class type then you will need reflection to do the job.
For example, you are told to write a code analyzer which is able to look inside any class; and list down it’s all private method then you can do this only by reflection. Generally, It is said that whenever you don’t know, at compile time, the type that should be instantiated or the method that should invoked, you will need reflection.
Some Example which i discussed with you on reflection :

Having talked about need of reflection in real life application programming, it’s time to list down some instances where reflection is used to accomplish certain objectives.

  • Code analyzer tools

Code analyzers tools do lots of different things with your code. They do static analysis of syntax, show optimization tips and even report error conditions, and many more such things. They are written in a way such that they can analyze any class file passed to them to analyze. How can they do it without looking inside the class. Clearly, they use reflection to this analysis.

  • Eclipse (Other IDEs) auto completion of method names

Ever stressed your mind, how eclipse is able to provide you method suggestions whenever you hit CTRL+SPACE, even when you are not finished with writing that class. Reflection does this magic.

I have worked in a team which developed an eclipse plugin for generating REST API sourcecode, for methods defined in some interfaces. It used to create one REST API per interface method, and using wizard you can specify the other REST specific things such as HTTP method (GET, PUT, POST, DELETE), query parameters, path parameters and return values. Return value was a JAXB annotated class which was also generated by plugin. And almost 90% of the logic for code generation was written around reflection only.

In fact, reflection is heavily used in plugins for these kind of IDEs; be it eclipse, or IntelliJ or any other IDE for that matter.
  • Marshalling and unmarshalling
JAXB/Jattison and other marshalling/unmarshaling libraries heavily use reflection for XML (or JSON) to/from java beans code. They look up all annotated attributes in java bean, analyze their overall attributes and generate XML tags for them. The same is valid for unmarshaling as well.
  • Spring Framework for creating the beans
Spring framework uses dependency injection (DI) to populate the dependencies into beans defined in config files. DI framework actually heavily uses reflection for injecting these bean dependencies.

Spring 3 onwards, you can define the dependencies using annotations as well, using autowiring. Annotations are analyzed for dependencies injection using reflection only.
  • Parsing annotations by ORMs like hibernate entity
ORMs like hibernate use the config files (not they use annotations) for defining the relationship between entities and relationship between entity and database schemas. All this information is processed using java reflection capability.
  • Junit Testcases
If you remember the previous versions of Junit, then to run a testcase all you cad to do, was name a method starting with test e.g. testMethod1(), testCode2() etc. Junit processor was using reflection to iterate over all methods in class, and find-out methods starting with test and run this as testcase.

Use Notification Tray in Java Application

Hello friends we're see the notification tray of software at bottom right side. And at-least one time you'll also think how it work and can i make it for me.
Today i am teaching you how to use notification tray in java application.
Since Java SE 6, we can add an icon for our applications in the system tray area of the operating system.

The following example is a basic implementation of SystemTray class.
import java.awt.*;
import java.awt.TrayIcon.MessageType;
import javax.swing.ImageIcon;
public class TrayNotification {
    public static void main(String[] args) throws AWTException  {
     TrayNotification td = new TrayNotification();
    public void displayTray() throws AWTException{
        //Obtain only one instance of the SystemTray object
        SystemTray tray = SystemTray.getSystemTray();
        //Creating a tray icon
        ImageIcon icon = new ImageIcon(getClass().getResource("notify.jpg"));
        Image image = icon.getImage();
        TrayIcon trayIcon = new TrayIcon(image, "Tray Demo");
        //Let the system resizes the image if needed
        //Set tooltip text for the tray icon
        trayIcon.setToolTip("System tray icon demo");
        trayIcon.displayMessage("Hello, World", "This is demo from GeekOnJava", MessageType.INFO);
You can use any image which you want to show at bottom. Here notify.jpg is a image file which place at where .class file exist.
Run and enjoy hopefully it work well for you.