How to clone Android repo

mkdir android 
cd android
repo init -u git://android.git.kernel.org/platform/manifest.git 
repo sync
make

http://twitter.com/Arubin/status/27808662429

Problem with Sprite Helper, Level Helper, Interlaced PNG

So....
I have this project in which I use @vladubogdan's Level Helper and Sprite Helper. Then I get this extremely annoying bug that I can't figure out the root:
If I run it on device the first time, the pictures are showing. Second time, not showing, third time showing, etc. WHAT HAS GONE WRONG?
Then I tried to clear the project and re build and I got this:


CopyPNGFile /Users/firman/Library/Developer/Xcode/DerivedData/Dotugov2-fhgqwfonumwjtachcdehbmsgrfdu/Build/Products/Debug-iphoneos/Dotugov2.app/timeselect-hd.png Dotugov2/Resources/Images/timeselect-hd.png
    cd /Users/firman/Documents/ios-project/Dotugov2
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng" -compress "" /Users/firman/Documents/ios-project/Dotugov2/Dotugov2/Resources/Images/timeselect-hd.png /Users/firman/Library/Developer/Xcode/DerivedData/Dotugov2-fhgqwfonumwjtachcdehbmsgrfdu/Build/Products/Debug-iphoneos/Dotugov2.app/timeselect-hd.png


While reading /Users/firman/Documents/ios-project/Dotugov2/Dotugov2/Resources/Images/timeselect-hd.png pngcrush caught libpng error:
   \341\217


While reading /Users/firman/Documents/ios-project/Dotugov2/Dotugov2/Resources/Images/timeselect-hd.png pngcrush caught libpng error:


I googled and arrived here: 


It says that the such error is caused by interlaced PNG images. I tried to resave the PNG images to non interlaced but to no avail. I don't know what to do next...

Small notes

Some lessons I learnt the past few days:

Cocos2D: Don't load heavy resources in the init method. This will crash the app. Instead, load them in a scheduled method.
Box2D: Don't change scene while world is locked (when detecting and responding to touch). This will cause a memory leak. Instead, change the scene in an scheduled method.
Android: The method insert in SQLiteDatabase doesn't throw exception. It does throw exception and print the stack trace but it's internally handled by that method and the exception won't by caught by the try catch block. If you need to catch exception, use insertOrThrow instead.

Code snippet to pad numbers with zero:

        NSString *paddingFormat = [[NSString stringWithFormat:@"time\n%%0%dd:%%0%dd", 2, 2] retain];
        NSString *paddedNumber = [NSString stringWithFormat:paddingFormat, 0, 0];

Result:

time
00:00

Hiero. Bitmap Font Tool

So I needed bitmap font atlas for my game. Bitmap font atlas is something similar to Image Atlas, only for font.

There's an open source code for it. The Slick project http://slick.cokeandcode.com/ The bitmap font tool is part of the project, which is located in the Hiero directory.

To correctly set it up as Eclipse project:

1. Create new Eclipse project. Copy the Hiero directory of the Slick project into the source directory of the new project.
2. Copy the lwgl.jar and lwgl-util.jar and slick.jar into the lib directory.
3. Copy the native (platform dependent) binary into some directory in the project structure.
4. Properties -> Java build path -> libraries then click on lwgl.jar and double click on native library location and in the resulting dialog, navigate to the directory where you saved the native binaries of lwgl for your platform.
5. Run the Hiero.java as Java application.

Or, if you still get errors or those steps are too much hassle, you can buy Glyphdesigner for USD 30. Glyphdesigner is better (not much better, just better) than Hiero, and it's easy to run and understand.

Correcting gravity of Box2D for portrait mode


In the accelerometer function of HelloWorldLayer.mm the gravity is set with this line
b2Vec2 gravity( -accelY * 10, accelX * 10);
In order to simulate the desired effect in portrait mode, the line must be re-ordered to:
b2Vec2 gravity( accelX * 10, accelY * 10);

Enabling telnet server on Mac

Is telnet still relevant? It turns out that the answer is yes. Recently a client commissioned me to develop a telnet client for Android. He's developing a wireless barcode scanner which connects to the server using telnet. To test my app, I needed to enable telnet server on my mac. Here's how I did it:

$ sudo launchctl load -w /System/Library/LaunchDaemons/telnet.plist

And to stop the server:


$ sudo launchctl unload -w /System/Library/LaunchDaemons/telnet.plist

How To Get Latitude and Longitude Coordinates from Google Maps

  1. Method one involves the use of a simple snippet of code in your browser's address bar.
  2. Find the location for which you would like to obtain coordinates in Google Maps.
  3. Right click on your chosen location, and select "center map here."
  4. Open Firebug's console in Firefox then copy and paste the snippet of javascript code below into the address bar, and hit "enter."
  5. javascript:void(prompt('',gApplication.getMap().getCenter()));
  6. This will activate a small pop-up window that will show the coordinates for the centered location in decimal format.
     
From: http://gps.about.com/od/gpsproductoverview/ht/google-maps-coordinates.htm