Tuesday, October 8, 2013

Cocos2D-X Multi-Resolution Support

Guide here: http://www.cocos2d-x.org/wiki/Multi_resolution_support

Cocos2D Managing Touch Input

In a subclass of CCLayer, just set "isTouchEnabled" to true and implement the callback functions.

Otherwise, add a touch delegate class to the touch dispatcher. There are 2 types, as explained here: http://www.cocos2d-iphone.org/wiki/doku.php/tips:touchdelegates

Porting From Obj-C to C++ for Cocos2D-X

This page provides a guide for developers when porting code from Obj-C to C++

http://www.cocos2d-x.org/wiki/Moving_From_Objective-C_to_C++

Converting from Screen to Map Coordinates in Isometric 2D Games

This article here provides a great explanation on this.

Formulae in summary:

From screen coordinates to tile x,y

map.x = screen.x / TILE_WIDTH + screen.y / TILE_HEIGHT;
map.y = screen.y / TILE_HEIGHT - screen.x / TILE_WIDTH;


From tile x,y to screen coordinates

screen.x = (map.x - map.y) * TILE_WIDTH_HALF;
screen.y = (map.x + map.y) * TILE_HEIGHT_HALF;



Note: these only work if the iso map is skewed at 45 degrees. If it's skewed in 30 degrees or 60 degrees, trigonometry will be needed.

Thursday, October 3, 2013

Android Google Maps Draw Text Label On Map

Unfortunately, on V2 of the API, this is not possible. The workaround is to create a bitmap image from text, and then draw it as an image Marker.

Solution is described here: http://stackoverflow.com/questions/14631223/draw-text-on-google-map-no-longer-possible

When creating the Paint object, the text size should be calculated during runtime based on the display. This is done according to the example here: http://stackoverflow.com/questions/12620343/text-size-with-different-resolution

Wednesday, October 2, 2013

Git See Older Version of File

Here's a quick way to see the older version of a file in Git:

git show HEAD~4:pathto/file

Where "4" represents the number of versions to go back in HEAD.

See the following references for more details and variations:

Android: ListView Black When Scrolling

Encountered this a couple of times on some Android OS versions.

It's due to the scrolling cache. To fix it, use "setCacheColorHint(preferredBgColor)". I usually just use transparent.

Reference:

Android: Using "ellipsize" to Deal With Long Text

In a TextView the "android:ellipsize" attribute is used to handle rendering of text that is too long for the space given.

More information in the following links:

Saturday, September 28, 2013

Notes for Android Google Maps API Version 2

Some notes:

  • It is required to obtain an API key at the Google APIs console
    • First step is to create a project, the name is not important
    • Within the project, switch on the Google Maps API
    • Create a "Registered App" for each key you want to create
      • I have 1 desktop and 1 notebook, so I ended up registering 2 apps with the debug keys on each machine
      • These keys, by default can be used across apps
  • There are 2 main ways to include a map in a screen
    • The preferred way is to use a fragment, which can be used with the most flexibility with the newer API levels
      • Some older devices won't be able to use fragments unless it's called from within a FragmentActivity
    • Alternatively, MapView can be used but requires life-cycle events to be forwarded to the MapView
  • Gotchas:
    • You have to include the source codes of the Google Play Services library project in your workspace in order to use the API
    • It still doesn't support the ingestion of a KML file and automatically drawing the contents on the map
    • The docs say you don't have to use MapsInitializer.initialize, I've had to do it (with MapView)
Resources:

Android API Levels

This page contains the reference to use on this: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels

Simple Guide on "How to Get Started in Data Science"

Link: http://hortonworks.com/blog/how-to-get-started-in-data-science/#.UkNOfLx543c

Contains pointers for people from different backgrounds e.g. Java developer, Hadoop developer, Statistician etc.

Java Still Going Strong

I've always believed in using Java for the backend because of its performance, maturity, versatility, availability of open source tools/libraries and also you can have large teams work on projects together without things getting messy.

So it's good to see these articles, which also provide a good inside look at Twitter's struggles with Ruby on Rails and its subsequent migration to Java:

Tuesday, September 24, 2013

Twitter Search Queries

Advance Twitter search queries:

Twitter Java Library

Twitter4J is an open-source (Apache License) Java Twitter library that can be used to integrate into Twitter's API.

It includes OAuth and gzip support, and can be used within Android.

Site: http://twitter4j.org/en/

Tuesday, August 6, 2013

Removing DOS Carriage Return in Linux

This shows up as "^M" in some editors, and can cause some scripts to fail.

To fix it, install the package "dos2unix". Available in at the minimum RedHat and Ubuntu based distros.

Thursday, August 1, 2013

Android Private Libraries

In the Eclipse ADT, this is libraries that are placed in the "libs" folder, they are automatically placed on the classpath as "Android Private Libraries".

However, when removing it, the ADT removes the library but flags it as an error as it is missing. A restart needed to be performed before the project compiles properly.

Android Include Library in APK

In order for library JAR files to be included in the APK, it is necessary to go the "Build Path" and check "Android Private Libraries" in "Order and Export".

References:

Android Library References

To make one project depend on another, add into project.properties as follows:

android.library.reference.1=../LibraryOne
android.library.reference.2=../LibraryTwo