Monthly Archives: June 2014

PhoneGap App

Spending too much time to edit, build, transfer and run your app between PC and mobile device? Web browser cant test all the features? PhoneGap App is here for rescue http://app.phonegap.com First, you need to install the desktop app, then install the mobile app, and last pair the two. However, it only support phonegap project and not codova.      

Simple loading sprite animation

Ok, here is a very simple tutorial on creating animation using sprite image in coronalab. Most game developer/designer have no difficulty in understanding what is a sprite. Sprite is basically a ground of images composed into 1 big image, where each pieces represent a frame in timeline. By playing these frame one by one very fast, we create an illusion of animation. Yes, tat’s the same concept how Disney did it for their early day cartoon show. So, now, we have a sprite image ready here: sprite The image filename is sprite.jpg, with size in 648 (width) x 214 (height) pixel. There are total 4 frame, just a simple animation. Each frame size is 162 (width) x 214 (height) pixel. Ok, now the coding part. In corona, we first need to initialize the image sheet data: we take in 5 parameters when creating sheetData variable:
  1. width: width of the single frame 648/4 = 162 pixel
  2. height: always 214 pixel as our sprite image is a horizontally long image. There are more complicated cases where your sprite might be more than 1 row.
  3. numFrames: only 4 here as you can see
  4. sheetContentWidth: your sheet image size in width, is 648 pixel
  5. sheetContentHeight: same as above, but in height, is 214 pixel
once you get these value set correctly, you create the imageSheet variable by passing in the image file path and name, then this sheetData too as parameters. Next, you need to create another variable called sequenceData. This will tell corona how to play your sprite. Our animation here is very straightforward, just keep looping it from 1st frame to last frame. Then, we create the loadingSprite object using imageSheet and sequenceData as parameters. we add in these code to position it at the center of screen: Last but not least, play it using this command: Source code for this tutorial is available at gitlab repository (public). For more advance and complete tutorial, please refer to Coronalab Tutorial here.

Android emulator too slow?

No worry, you can speed it up! You can use the Virtual Machine Acceleration to improve the execution speed. Many modern CPUs provide extensions to execute Virtual Machines more efficiently. Before attempting to use this type of acceleration, you need to determine if your current development system’s CPU, supports one the following virtualization technologies:
  • Intel Virtualization Technology (VT-x, vmx) → Intel VT-x supported processor list
  • AMD Virtualization (AMD-V, SVM), only supported for Linux (Since May 2006, all CPUs AMD include AMD-V, except Sempron).
Another way to find out if your Intel processor supports VT-x Technology, it’s by executing the Intel Processor Identification Utility, for Windows. you can download it from the Intel Download Center, or you can use the booteable utility, which is OS Independent. intel_pid_util_620px   So if you got these 2 red things enabled, congratulation! Else, too bad… In order to speed up the emulator, you need to download and install one or more Intel x86 Atom System Images, as well as the Intel Hardware Accelerated Execution Manager (HAXM). Open your Android SDK Manager, and select the Intel x86 Atom System Image, for whichever version that you want to test. Then go to Extras and select Intel x86 Emulator Accelerator (HAXM), and install those packages: asdk_man_intel_image_haxm After download, run the Intel installer, which is available within your Android SDK at extras/intel/Hardware_Accelerated_Execution_Manager. Note:If you have any problems installing the package, you can find more information and step by step guidance check this Intel Article.
  1. Install one or more Intel x86 Atom System Images as well as the Intel Hardware Accelerated Execution Manager, available under Extras.
  2. Run the Intel installer, which is available within your Android SDK at extras/intel/Hardware_Accelerated_Execution_Manager.
  3. Create a new AVD with the target set to an Intel image.
  4. When starting the emulator, ensure there are no error messages indicating a failure to load HAX modules.

Getting started with Cordova

Formerly known as phonegap, cordova helps you build hybrid type of mobile app fast and easy across all platform. If you are accessing from http://phonegap.com/, then the documentation there will ask you to do the following installation which is deprecated at the moment: You should enter from http://cordova.apache.org/ and follow the instruction there. Basically, you need to have npm first. I assume you are just like me, using windows and focusing on android app development. Basically, cordova will ask you to  follow either the cross-plaform or platform-specific method. I will just use cross-platform as it’s the point of picking up cordova iin firstplace. At the time of writing, cordova is at version 3.5.0. The documentation is available here. After you have installed the cordova CLI and created your first app, …you will wanto try to add a platform to it: Then, you realize there is an error. Basically, it is bcs your android SDK path is not register on windows environment. You may follow this stackoverflow article solution. If you dunno what I am talking about at this point, most probably you haven’t get your android SDK installed too. Basically, you need to have these setup first:
  1. Download and install Eclipse Classic
  2. Download and install Android SDK
  3. Download and install ADT Plugin
Finally, when you have got everything ready, to build the app, you call: and to send it to your phone thru usb cable: You should beable to see the default page with cordova logo now. Congratulation, you have got your very first cordova app built and running!