Mittwoch, 26. Dezember 2012

Corona SDK and Lua: Creating a rotating obstacle with a physics joint

Android app on Google Play

As you might have seen in our game Cookie Billiard, we created some rotating elements that are used as obstacles for the cue or as levers for the cookie. This kind of element can be created by using the standard physics joints that corona sdk offers ( However, there is no physics joint that is specifically indended for such a purpose. We realised it by using the standard pivot joint that is also used to create ragdoll figures.

physics.newJoint( "pivot", object1, object2, 200,300 )

The pivot joint in general connects two display objects by creating an imaginary line that starts at the center of the first object and ends at the center of the second object (resp. vise versa). The coordinates (here 200,300) specifiy a point where the lines, and the objects that are connected to it, can rotate around.

The movements of the two objects are now controlled by the joint and its break point. They can't rotate around the origin of its connecting line. But now a precularity of corona sdk comes into play: when the two obects lie on top of each other, the last restriction does not hold anymore and they can rotate around the origin of its connecting line.

 So we just created the circle first and made it static so that it can't move:

myCircle = display.newCircle(100, 100, 10 )    
physics.addBody (myCircle, "static", {radius = 10, bounce = 0.5,  friction = 0.65})

Then we created a rectangle that lies on top of the rectangle as illustrated in the picture. Important is that you do not set its physics body to "static" sinse it should be able to move:
       physics.addBody (myRotator, {density = 4, bounce = 0.5,  friction = 0.65})

Eventually, we added a pivot joint that connected the circle and the rectangle:
       physics.newJoint ("pivot", myCircle, myRotator, myCircle.x, myCircle.y)

An important  property here is the desity (in this case set to 4) of the physics body of the rectangle. If it set to low and the cue later on hits the rectangle, it might happen that the rectangle and the circle move slightly away from its origin which looks strange and leads to strange rebounds of the cue. It seems to be a bug of corona sdk that has not been solved yet. I found some other users in different forums also complaining about this problem. 

I hope this post was helpful for you.

Your MOCCA GAMES team.

Android app on Google Play

Corona SDK: removing standard permissions from AndroidManifest.xml

Android app on Google Play Hey,

now i want to dig into a topic that was really annoying to us in the development of Cookie Billiard. For some reason Corona SDK ALWAYS includes the following permissions in the androidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

There is no easy way to remove them from within corona. The settings file is not able to remove those permissions. Corona itself, does not provide an official solution to that. So here I'm explaining it to you:

1) Download the APK manager. I used version 5.0.2
In order for the APK-Manager to work properly you need to have your JDK (Java Development Kit) "bin" folder added to your PATH environment variable

2) Put the .apk that needs to be changed in the folder "place-apk-here-for-modding"
3) run the script and choose option 9 for decompiling

4) Go into the projects folder of the APK Manager and change the androidManifest.xml to your likings
5) Run option 11 (compile) in the APK Manager script, then you will be confronted with two questions: answer them both with "2". Then the following question pops up:
Now go into the "keep" folder and just delete androidManifest.xml and resources.arsc and then hit enter in the script (or any other key)

6) Now you have successfully compiled your .apk without the permissions in the androidManifest.xml. However thats not enough for the android market. Now you still need the sign the .apk with your certificate and you need to run zipalign in order to align your package structure according to the google standards.

7) Signing the app with jarsigner.
Jarsigner is a standard cmd-application that comes witht the JDK. If you don't have that download it and add the bin folder of the JDK to your Path environment variable.

Then perform the following command in your console according to your own folders:

jarsigner -verbose -keystore C:\...\releaseKey.keystore C:\...\Apk_Manager_5.0.2\place-apk-here-for-modding\unsignedCookieBilliard.apk moccagames

You will then be asked for the password of your keystore-file. enter it and all your files should successfully be signed.

8) Now you need to zipalign you signed .apk:

zipalign is a cmd-tool that comes with the Android Development Kit. You already needed it in order to run the APK-manager. However for the APK-Manager you just needed to add the "platform-tools" folder to your PATH environment variable. The zipalign tool resides within the "tools" folder of the Android SDK. If not already done add it to your PATH-variable.

Perform the following command in your console according to your own folders
zipalign -f -v 4 C:\...\CookieBilliard.apk C:\...\CookieBilliardZipAlign.apk

If everything was successfull a "Verifiaction successfull" message should appear at the end.
Now you have the same .apk like in the beginning, just without the permissions that you removed, ready to be uploaded to the android market :)

Hope the tutorial is helpful. If there are any questions please post them in the comments.


!!!IMPORTANT: Do never try to change .apks that are not yours!!! We are not responsible for any legal issues that may arise from that!!! Android app on Google Play

Montag, 24. Dezember 2012

Corona SDK lua tutorial: Callback functions

Hey guys,

during development we've realized that so called callback function are a very usefull system to create reusable code that makes life easier. We've used that system in our slide-View that we've implemented as our game selection menu in Cookie Billiard  Android app on Google Play .

The idea and purpose of callback functions:

A callback function atually is nearly the same as an EventListener. You specifiy which method should be called in case a certain event occures. In the context of the slide view a certain method should be called if a user clicks on a specific slide. In order to make it reusable the method is not allowed to be located within the slide view module, but outside of it. You pass a certain function into the slide view module.

Have a look at the new function of our slidev view module:

function slideView:new( svTop, svLeft, images, keys, callback )

Here we pass the distance to the top, to the left, all images, their keys and a function that should be called whenever a slide was clicked (tapped in corona terms).

To use the passed callback function you can use the following listener:

function onImageTap( touchEvent )
        callback( { key = } )
        return true

Our callback function than looks like this:

This function is not part of the slide view module but resides outside!

local function onSelectSlideViewItem( slideViewItem )
        print( "Clicked " .. slideViewItem.key )

        if (slideViewItem.key == "minigames") then
            director:changeScene( "", "moveFromTop" )
        elseif (slideViewItem.key == "gameCrispy") then
            director:changeScene( "scripts.levels.crispy.levelSelectionCrispy", "moveFromTop" )
        elseif (slideViewItem.key == "introduction") then
            director:changeScene( "scripts.levels.introduction.introduction", "moveFromTop" )
        elseif (slideViewItem.key == "gameCrunchy") then
            director:changeScene( "scripts.levels.crunchy.levelSelectionCrunchy", "moveFromTop" )

The callback function receives a certain item that was clicked and can decide upon that what action has to follow.

Our System of a slideview makes it perfectly reusable. W can use it for any other game. We just have to pass all the required parameters and thats it for the slideview.

Android app on Google Play

Cookie Billiard: removed unsave permissions

Hey folks,

due to some feedback we received, we removed all unnecessary permissions. The free version now just needs INTERNET ACCESS and the full version doesn't need any permissions :).

Have fun playing our game:
New Android Release

Your MOCCA GAME team

Sonntag, 23. Dezember 2012

Freitag, 21. Dezember 2012

Mittwoch, 19. Dezember 2012

Cookie Billiard was finally released for Android

What a Day :),

we finally made Cookie Billiard available on the Android Market:

We will soon release versions for iOS and maybe even Amazon Kindle.

We are really looking forward to any comments on our new game :)

During the process of releasing it to the Android market we encountered some issues concerned with signing your app with RSA encryption. I'll probably gonna write a post about that in the next days.

Your Mocca Game Team

Dienstag, 18. Dezember 2012

Designing grafical mobile game assets with Open Source tools

Hello together,

how do you design a mobile game if you are not a designer and you want to use Open Source tools to save money?

I can't describe the perfect solution for everyone, but this is how we did it:

At first we tried to get a feeling for the typical quality of game assets. So we downloaded lots of games and investigated the google play market exensively. Thereby you also learned what kind of game concepts are popular at the moment. So once we had a feeling for the design quality we had to reach, we had to decide for the tools to use.

Since we wanted to stay flexible, concerning changing and scaling the assets, we decided to mainly use vector based applications. For that purpose we chose InkScape: It has a good performance and I really like the menu concept. Its easy and fast to use. At some point you always need raster based image applications. In this area we chose Gimp:

Now that we had the tools at hand we could start practising. And means lots of hours and days practising. We gathered inspiration by using the image search of google and using the appendix "vector". We practised to draw similar characters and learned the creation process. For example at first we had no clue of how to create good looking eyes. After a while we succeded in creating really nice looking and vivid eyes. We kept on practising and created all sorts of grafical stuff.

At some point we had enough experience to create our own game design concept. This also included which colors to use. There are a lot of sites that help you with creating an appealing color scheme. E.g.

To organize all of our image files we are using Dropbox: Dropbox is really smoothly integrated into your windows explorer. All files are automatically synchronized.

Hope this helps other developers to get a handle on the designing process, if one does not have a comprehensive design education ;)

Your Moccagame-team

OOP (Object Oriented Programming) with lua in Corona SDK

Android app on Google Play

I stumbled over a OOP test that I've made while learning the concepts of lua. I've created a class game and tried to use OOP ideas. That for example means that I could create several unique game instaces that do not share the same variable values. The example is pretty simple, but it may give you an insight in how lua can be used in a OOP manner:

For further details, check the lua documentation:

The code is not perfect since it was just for testing purposes, but I think it shows quite comprehensively how lua can be in a OOP way

best wishes,

Android app on Google Play

First Experiences with MGD


as promised we will now start to write about our experiences with Mobile Game Development, especially with the help of Corona SDK.

Well, we were new to this field, but we had experiences with 3D-Game development. So our first thought was: "lets use Unity3D". It's actually a very easy to use 3D-game development environment and is easily able to work together with Open Source 3D-Modeling applications like Blender 3D ( Another advantage ist, that you can use c# as the programming language for your game logic. C# is one of the best object oriented programming languages that I know and we had a lot experience with it. However, after a while of comparing development costs we had to admit that Unity 3D ist just too expensive for students like us. Even the student pricing was way to high for us. If I remenber it right, we would have to pay more than 1500$ for 2 licences and the required plugin to delevop for Android devices. iOS would have cost additional 250$. Still we development a little demo app to test the performance and the workflow. It was fastly created, but as we were aiming at targeting standard smart phones the handling of 3D applications seemed too confusing and just not appropriate for a small mobile device screen.

So at first, we were a bit disillusioned, since we really wanted to develop 3D games. There we would be able to apply our cumbersome aquired 3D game knowledge. So what should we do? After a while, we tried to identify appropritate 2D development environments. After some research on sites like these we encountered Corona SDK. Of course every vendor claimes to have the best solution ;). But this had to be verified! So we downloaded corona sdk. The first problem that we encountered was that there was no standard IDE (Integrated Development Environment). Included with Corona SDK is the so called Corona Project Manager. The tool is usable, but very low level concerning functionality: no code folding, no code completion, no subversion support for teamwork, no detailed code analysis, no refactoring. Some simple issue that we didn't like was that standard variables were not highlighted. That makes it really difficult to effecieantly scan your code for error or to understand code from others easily. Still, for just trying to get familiar the Corona Project Manager is a good choice. It fast and easy to use, since there are just a few options. Nevertheless, we are now using another free soltion, which is way better. But this will be covered in another post.

After 2 weeks of playing around we decided to use Corona SDK. Not only because it's 2D, but especially because the documentation is extremly good ( I've never seen a documentation that makes it so easy to digg into a foreign API (Application Programming Interface). A further pro were the costs. We were able to develop for Android, iOS, Kindle and nook for around 300$. That's a fair price, considering the possibilities it offeres.

The programming language of Corona is called lua and enables cross plattform development since you are not developing in a specific platform dependend language. The lua code is translated for each platform automatically when deploying.

After two Month of developing with lua I can already draw the conclusion that it's negative sides, but also has atvantages. For me, as a educated object oriented programmer it was really unpleasent to work with the NOT object oriented lua. For some reasons some people claim lua to be OO. But it's definitely not. It does not specify any class structures and does not automatically offer typical inheritance. However, it is possible to  use OO-ideas and to pull them over lua. That works, but often it leads to erros, because the language is simply not build to be OO. To some extend we are now working with OO ideas, but we learned to to exxagerate. This seems a good balance so far. Now it might sound that the absence standard of OO-concepts is solely but. This is not true. Because the language is so free you can nearly do whatever you want. This offers new flexibility. Especially for people that don't have a lot of OO experience, it is pretty easy to create you first simple games. Just because you don't need to think about all the OO stuff. But, in contrast to typical OOP langauge you have to think about script language issues. For example it is not possible to use a function in your code that is defined later in the same file. It need to be defined, before you use it. in none-script OOP languages you don't need to think about that, because the whole code is compiled into Bytecode in the right order automatically.

Still i would prefer a strictly OOP-language like Java or C#, because it makes code much more reusable, maintainable and clear. Despite the cons I would recommend Corona SDK. A good documentation and a easy programming language are worth a lot, as long you don't want to create extremly complicated games.

We hope this gives you some interesting insights. More articles will follow.

Your Moccagame team

Mobile Game Development

Hey guys,

we just currently started developing android/iOS games and we're intending to regularly write about our experiences. Which vendor to choose, which IDE, which programming models and all sorts of stuff that is interesting. Probably next week we'll start to write some articles. So stay tuned.

Your moccagame team

Cookie Billiard

Cookie Billiard:

Test your mental gears with this fascinating physics game.
Try to feed the poor monster with cookies by using your ability to forecast the movement of the cueball and the cookie, while overcoming and using complex obstacles. This game comes with a variety of challenging levels and two gameplay modes totaling several hours of mind-bending gameplay.  

Your Moccagames team