Thursday, December 26, 2013


The Qt5.2.0 is adding support for android and i couldn't be more excited. After fiddling around with the basic Qt based stuff, i realized that the QtQuick is the way to go for making interfaces for the mobile devices. The tutorial video about getting started with QtQuick is a good start for getting acquainted with the QtQuick.

The tutorial covers how to make scalable interfaces only the basic stuff though but it should be good enough to get you started.

Here is the URL:

With this as a starting point iv'e been able to create a dictionary app with just QtQuick framework. Well why a dictionary app?

1) I found a really cool minimalistic UI design
2) Had a couple of cool looking color schemes that i could pick
3) I didn't have to create an infinite scrolling list :D
4) Minimal requirements.

With these i've started designing the application. Most of the tutorials claim that the mobile version will just work if the desktop version is working. This is mostly true but as you might expect.. it's not totally true. There are a couple of quirks i had to deal with while developing the dictionary app.

Here are the screenShots of the app on phone

1) Input Line edit has some weird behavior. We should set inputMethodHints: Qt.ImhNoPredictiveText to be able to use it properly.
2) Do not use eval for converting Json string to object. Use JSON.parse instead.
3) Making ui for different Display Sizes is tricky but easy with QtQuick.

Here is the video of the app in action on Nexus5

This needs some more tweaks to be awesome .. ill' be uploading the src soon on github.

Sunday, December 08, 2013

Qt on Android

It's been a while since ive' looked at Qt. I used it extensively during my masters project and pretty much every project that i worked on in the college. I even made a 2D top down game using OpenGL and Qt along with a couple of my friends as a course project. I even taught a class how to get started with Qt using PyQt.

The most recent experience i've had with Qt was looking at PyQt being used for creating a DB access software at University of Groningen. It was written based on Qt3.0 and upgrading to Qt4.0 was causing all sorts of problem that is when i thought Qt probably lost it's way with all the Selling / Ownership transfer / Shift of focus on Platforms etc.

Now saying that i love the power of Qt for creating GUI's is an understatement. The documentation and the examples provided made it so easy to pick up the Toolkit. I was worried they might have misstepped too much and lost control of how awesome it used to be.

Recently i came across some article which mentioned that Qt was gonna be supporting Android. This was a god send for me. All the experience with making GUI using Qt and now i can finally make GUI on android using it.

Anyway i spent a couple of hours trying to figure how to get started and i came across this wonderful article about getting started with Qt for Android

And so I was able to create my de-facto gui test app the hello world app :)
Here are the requirements:

  • User enters text
  • Clicks Button
  • MEssageBox pops up with the text he/she entered
If you follow the instructions in the link above and know how to program in Qt you should be up in no time. Here are the screen shots .

So as you can see there is a big button and a big text entry thing and when you click on it a message box shows up. It was a fun exercise and i'm eager to make some interesting apps with this power :)

Saturday, December 07, 2013


With the advent of the ios/android/wp8 there has been a steady rise in the digital comics market. A very immersive experience with audio / animations and some times even gameplay.

This takes the already fun experience of reading comic books to a whole new level. Imagine the your favorite comics coming to life at least partially, with audio and animation effects. This idea has fascinated me and i decided to spend some time trying to figure out how best to do it.

Here are some of the goals that i wanted to achieve for this:

1) Ease of creating content
2) Ensure that only the data changes for putting out a new comic.
3) Be Cross Platform

Enter ComicNext 
A new framework that will make creating digitial interactive comics for mobile phones / tablets very easy. We were able to create a quick prototype of how a comic book would look, you can try it out yourself HERE

This is obviously in beginning stages and will take time to be widely available but,
If you are trying to make a digital comic or want to learn more about our framework drop a line in the comments.

Tuesday, November 19, 2013

Unity Plugin Android(Part2)

In my last post iv'e covered about how to write a plugin without actually over-riding the unity activities so you can peacefully co-exist with other unity plugins (for android).

The reality is that you will have to deal with people using Prime31 as one of their plugins. This can be a problem if you need to get callbacks for the android system event callbacks like:

void onCreate(Bundle Intent){

void onStart(){

void onStop(){

and so on. You get the idea. Fortunately the prime31 guys provide us a method for registering a class to get callbacks from these methods on the activity. The details of which are provided at the following url

This is pretty straight forward If you know how to use Android ADT/Eclipse for creating android projects. Here is how you go about it.

1) First create an Android Project. Mark it as a library project.
2) Add unity-classes.jar file to the libs directory of your project.
3)  Create a java class with the functions you want callbacks on.  Say you want callbacks for onCreate, onStop and onStart then here is the class you have to write:
Once we have written this class,  Right click on the class name and click on Copy Qualified Name. In this example the qualified name is "com.tms.shivaproject.AdRefActivity"

2) Edit the AndroidManifest.xml file to specify our class as the meta-data for the Prime31UnityProxyActivity with the following
3) The last part is to just build and launch. You should see the logs in the logCat.

Note: This tutorial assumes that you know how to create a jar file from an android project. 

Thursday, October 03, 2013

Unity Plugin (Android)

I've been working on creating a plugin for unity(Android). The latest versions of unity (4.x) provide clean way of accessing the java side of things on android.

If you want access to the android activity from android,  all you have to do is call the following..

AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic("currentActivity");

This doesn't give us much of a head way... i.e, if you want to add any functionality you will have to extend the UnityPlayerActivity and add the functions you want and call them. But there is a more elegant way of doing it. You can just create a jar file from your android library and access its' functionality like so..

AndroidJavaClass _pluginClass = new AndroidJavaClass("com.vkgamedev.MyTestLib.MyTestLib");
_pluginClass.CallStatic("setGoogleProjectId", googleProjectId);

If your  library needs access to the android activity that's running, you can just send it in as a parameter to the java side as a AndroidJavaObject. You will need to create a static function that takes in a generic Object and sets the activity reference.

_pluginClass.CallStatic("initGamesSDK", activity,"yes");

The java side of things is pretty straight forward, just a singleton class with static functions to initialize and expose the functionality that your library provides, access them from unity using the JNI calls. 
If you want to send info back to unity from Android/java, just use the following function:

//this requires that you add unity-class.jar to your library project.
UnityPlayer.UnitySendMessage("GamesSDK", "onLogin", "Fail"); 

Java File for the Library

C# side of things for accessing the library (MyTest.cs)
If we want to be able to call unity functions from java side, we need to send the message to a particular object. So we have to create  a prefab that listens to these events and handles these messages.
Here is the code for plugin handler that has to be attached to an empty object that needs to be dragged into a scene to enable the plugin.

Be sure to name the Empty object as "GamesSDK" since that is the object we are sending the message to from the Java library code.
As you can see we have been able to create a basic flow for an android plugin without over riding the default activity provided by unity.

Saturday, September 28, 2013


GloBall Icon
I've been drafting various ideas for a while and been thinking about getting to actually making them for a while now. Ever since i've started working in the games industry i've started thinking about bigger projects which are obviously going to take longer to develop.

But I decided that should not be stopping me from making something quickly like i used to and put it up just for the heck of it. Its' one of those times when im' just eager to finish something and put it up.

Here is the text i put down for this game a while ago:
Neon Defender2D Shooting game where you user cubes vs spheres style gameplay to select the type of bullet being shot. The enemies will be of different behaviors like in geometry wars and those from cubes vs spheres.
So I called it Neon Defender because i was sure i wanted to go the Geometry Wars art style. Any way from that point it's moved through some hoops. I added the Upgrade mechanics for "loot Drop", "loot drop duration" and "Health". The interesting thing i tried with this game was bringing the inventory right into the game. Let me explain

In Cubes Vs Spheres, you have in game currency that you get and you buy the bullets in the main screen, during gameplay if you run out of that particular sphere you are pretty much stuck, even though you had the currency to buy more. So to avoid this i put the price for each bullet right below the icon and when you fire each one of those you know how many credits you spend.

So there you go, as you can see the visuals are very similar to my other game "MuCap". I really hope to bring that game to android some day. It would be awesome to play on tablets.
Oh and if you are wondering what engine i used.. look no further .. cocos2d-x, All the art assets made using InkScape and Gimp.

Sunday, July 21, 2013

Cocos2D-X for Android LiveWallpaper

Today i saw a question on the forum at asking about how to get the cocos2d-x application to run as a live wallpaper.

Most of the basics come from the sample application provided by google, but since cocos2d-x is designed under the assumption that its' always used as an application you will have to change a few things here and there.

So ive' quickly made some dirty adjustments to the code pasted on the forum to get the sample code running as a live wallpaper. Here is the screenshot of the default one running.
Sample Cocos2D-x app as Live Wallpaper
Im' excited to see what the cocos2d-x app devs can do once they start developing the live wallpapers. ..

Here are the steps you should follow:

1) Open the .java file created in packagename/*.java
2) Modify it based on the java file embedded below.
3) Modify the AndroidManifest.xml file to make it behave like a wallpaper.

Build and deploy the app just like any other cocos2d-x application. If everything went right you should see your app listed among the liveWallpapers section in your phone.

AndroidManifest.xml has to be modified. Then the code in your java file should be changed to this.

Cocos2D-X Memory Management

The last couple of days i have been trying to squash all the memory leaks in our game, this gave me a better understanding about the memory management used by cocos2d-x. It's a little different but with a little care you can get it right.

Here are a few facts you should know

  •  Every CCObject has a reference count of 1 when it is created.
  •  If you call autorelease() and dont' retain the CCObject you don't have to call release()
  •  CCNode's destructor calls release() on all its' children once(because it calls retain() in addChild())
  •  If you call retain() or new on a CCObject you have to call release() 

This is all straight forward, in fact this is all mentioned in the wiki on website.
It gets' tricky when you start using CCTouchDispatcher's targeted delegate and the CCBReader.

When you load a ".ccbi" file the following happens:

  • CCBAnimationManager calls retain() on RootNode of the "ccb"
  • RootNode of the "ccb" calls retain() on CCBAnimationManager (it is set as userObject()).

so if the RootNode has to be deleted, CCBAnimationManager has to call release() on RootNode, but the CCBAnimationManager will be deleted only when RootNode calls release() on CCBAnimationManager. This is the cyclic dependency because of which both the RootNode and the AnimationManager stay in memory.

To counter this we have to create a wrapper class which keeps track of the CCBAnimationManager. Set the userObject in RootNode to NULL so that the CCBAnimationManager is no longer dependent on RootNodes's deletion. Check out the following link for full discussion.

The other most important thing is that, when you use CCB_MEMBERVARIABLEASSIGNER_GLUE(...) for accessing the children in the "ccb" files, it calls retain() on the member you get access to. So it's crucial to call release() on it in the destructor().

Sunday, April 14, 2013

Gameplay3D on Android

I've experimented with the Gameplay3d engine by the good folks at blackberry and found it really fun to work with. There are still some kinks to be worked out about the workflow for the materials but over all the experience has been good.

Today i've managed to get them some demos running on my device.. here are the screen shots..
Here are the steps to get the apps on to the device..

cd /android
$ANDROID_SDK_ROOT/toos/android update project -t "android-10" -p . -s
ant debug install

Space Ship Sample from Gameplay src

A Sample 3D application ive' developed using Gameplay
The takeaway would be that.. if you are looking for a good free 3D engine to start off something Gameplay might be a good place to start, especially if you are familiar with OpenGL and GLSL shaders.

Saturday, March 23, 2013

GamePlay Engine

I came across GamePlay engine a while ago. It claims to be easy to pickup for people who have worked on cocos2d-x or similar libraries. I doubted that claim and was too full of myself to give it a go. After all i already have a class for loading 3D models in cocos2D-x.

Over the weekend i wanted to give it a go just to get a feel for how things work in GamePlay engine. Im' happy to report that It was pretty awesome and would definitely give it a go if i had to pick up a free 3D engine to work on a game.

There were a few things that threw me off though, took me a while to figure out what was going on..
my first hurdle was to fix the Xcode projects..

The missing Frameworks?
So the projects were all the basic stuff required for an app but the xcode projects from GamePlay were showing them as missing... so basically i just had to drag drop them from finder window to the project tree. Easy but lost a lot of time trying to figure this out, Basically lack of documentation / troubleshooting documents.

The best thing about the engine is that you can directly import collada(.dae) files to the scene by converting them to ".gpb" gameplay binary. This is done using "gameplay-encoder" tool. The thing is you have to spend some time trying to understand the samples provided with the source code. I quickly realized that i had to look at the samples and analyze the code rather than searching online with weird questions. I have really not checked the forums but i would definitely look at the samples before even looking elsewhere.

The UI can be created in a pretty straightforward way, just specify the control type, location, alignment etc. The usage is simple once you figure out the syntax and get used to the Framework. The one thing i struggled for in this mini project was figuring how to set the light and the material of objects.

The awesome Rotating Cube
The scene is easy to setup, accessing different nodes in the scene based on their name is easy and so is setting their properties. Importing material data is one painful thing right now, which i hope will be fixed soon. As per actual game to be made, with the default physics integration it should be easy but i can imagine it not being as easy as say.. using unity for doing the same. The engine does support lua scripting .. which im' still yet to try.

Saturday, February 16, 2013

Cut Thy Polygon

Fruit Ninja is an awesome game.. very addictive.. and fun to play.. but if you observe carefully you will see that where ever you slash the fruit.. it is always cut in half.. It is a simple trick to keep things nice and fast. But imagine if you could cut and slice a fruit every which way you wanted precisely the way you wanted.. this is an idea i had for a while..

  • Slicing enemies into pieces based on slashes.
  • Slicing fruits based on the slashs
  • Creating predefined shapes from a starting shape 
and the list goes on.. and it all starts with a line intersecting a polygon and the polygon being cut into two polygons. Before we go any further here are the screens of how the result will look.

After 1 cut
After two cuts
After 3 Cuts

Now lets get to the most important part.. Cutting a polygon into two pieces.

For each Edge in the polygon:
      if Cut bisects Edge
          Find point of intersection of Cut line and Edge of polygon.
         Add V0 of Edge to left polygon or right polygon based on whether it lies to left / right of Cut line.
         Add V1 of Edge to left polygon or right polygon based on which side it lies on to the Cut line.
         Add the Intersection Point to Left and Right polygons' vertex list.
        Find which side the Edge lies on to the Cut.
        Add the V0 and V1 of Edge to the corresponding polygon's vertex list.

Once you have done this we have two vertex lists one for the polygon to the right of the Cut and one to the left of the Cut. All we have to do now is to create polygon objects from the new vertices so they can be cut further.
I've been working a lot with Cocos2d-x recently so i've implemented it the same.. here is the archive of classes directory for the cocos2d-x project.

Screenshots of what you get when you run it..

The initial polygon in white, you can draw arbitrary lines to cut the polygon along that line. The newly created polygons are drawn in red and yellow.