Monthly Archives: April 2012

How to get Device Orientation in Cocos2D, iPhone in Objective C?

By | April 17, 2012

Hello all…… We may need to know that what is your current device orientation. Using the below code you can do this. Note: If you have to explicitly set the orientation of your phone to any of the above you can set this in the appDelegate.m file. You can put an “||” (OR) symbol in… Read More »

How to inherit from other styles or how to extend your own styles in android?

By | April 17, 2012

Hello all…. I have covered many tutorials on styles on how to implement and use them. Today I will show you how to inherit from other styles or how to extend a style already created by you and use it for applying to other views. Here is one of my previous posts. http://www.coderzheaven.com/2012/02/03/changing-the-style-or-theme-of-default-alertdialog-in-android/ Another one… Read More »

How to animate a series of images in iphone? A simple Example.

By | April 12, 2012

The following code shows animation of 5 images. -(void)viewDidLoad { NSArray *images = [NSArray arrayWithObjects: [UIImage imageNamed:@”pic1.jpeg”], [UIImage imageNamed:@”pic2.jpeg”], [UIImage imageNamed:@”pic3.jpg”], [UIImage imageNamed:@”pic4.jpeg”], [UIImage imageNamed:@”pic5.jpeg”], nil]; CGRect frame = CGRectMake(0,0,320,460); UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame]; imageView.animationImages = images; imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.animationDuration = 3; imageView.animationRepeatCount = 0; [imageView startAnimating]; [self.view addSubview:imageView]; [imageView release]; [super… Read More »

How to add sprite to a body in Box2D in Adobe AIR, FLEX and FLASH? Or Add image/Sprite to a body in ActionScript.

By | April 12, 2012

The below code is for FlashBuilder 4, If you are using FlexBuilder3 use addChild() instead of the commented block in the following code.

Simulate a Balloon in Box2D, iPhone or ANDROID

By | April 12, 2012

Hello……… Sometimes you may want your body to act against the gravity of the world. One method to do this is described below. First what you have to do is to make a body in the shape of a circle and give it the image of a balloon as the userdata. Then in the tick… Read More »

Date and TimePicker in ANDROID.

By | April 12, 2012

The following code simply allows you to select a date and time using the datepicker and timepicker in ANDROID.

Saving Key-Value pair in Windows Phone using IsolatedStorageSettings

By | April 12, 2012

This sample code helps you to save a key and a corresponding value in windows Phone inside your application sandbox with the help of isolatedStorageSettings. PLease check this post before working around this post. How to save a text file in Windows Phone 7 or How to use isolated storage settings in Windows Phone 7?… Read More »

Copying an image to another in ANDROID.

By | April 7, 2012

Here is a simple example to copy an image to another image file in ANDROID. In this example a button click will open the gallery and after that it will be copied to another image file. You have to check the File-explorer to find the file. This is the java code for doing it. here… Read More »

Sprite Animations Without Sprite Sheets

By | April 7, 2012

You can simulate any animations if you have a sequence of images which makes the illusion of that animations and rendering those images to the screen. In cocos2D it can be done in two ways, with sprite sheet animation and without sprite sheets. Here we are going to see how it can be done with… Read More »

Sprite Animations Without Sprite Sheets

By | April 7, 2012

You can simulate any animations if you have a sequence of images which makes the illusion of that animations and rendering those images to the screen. In cocos2D it can be done in two ways, with sprite sheet animation and without sprite sheets. Here we are going to see how it can be done with… Read More »

Sprite Animations Without Sprite Sheets

By | April 7, 2012

You can simulate any animations if you have a sequence of images which makes the illusion of that animations and rendering those images to the screen. In cocos2D it can be done in two ways, with sprite sheet animation and without sprite sheets. Here we are going to see how it can be done with… Read More »

Java check memory Allocation

By | April 7, 2012

When run the code the output will be similar to this Total memory is: 5177344 Initial free memory: 4986744 Free memory after garbage collection: 5063784 Free memory after allocation: 5045296 Memory used by allocation: 18488 Free memory after collecting discarded Integers: 5063784

Get characters in a string – C Sharp/C#

By | April 7, 2012

Hi, Sometimes you may need to get all the characters in a string using C Sharp/C#. The following code gives you an example of how to get or display all the characters of a given string. Output: sampleString[0] = I sampleString[1] = sampleString[2] = L sampleString[3] = o sampleString[4] = v sampleString[5] = e sampleString[6]… Read More »

How to use CCProgressTimer in Cocos2D to show progress?

By | April 7, 2012

The progress timer takes a sprite and, based on a percentage, displays only a part of it to visualize some kind of progress in your game. You can choose between radial, vertical, and horizontal progress timers. But the timer doesn’t update itself. You have to change the timer’s percentage value frequently to update the progress.

Sprite Animations Without Sprite Sheets

By | April 7, 2012

You can simulate any animations if you have a sequence of images which makes the illusion of that animations and rendering those images to the screen. In cocos2D it can be done in two ways, with sprite sheet animation and without sprite sheets. Here we are going to see how it can be done with… Read More »

Switch Images in ANDROID.

By | April 7, 2012

Hi all …….. Ofter we have trouble with loading continous images in ANDROID from our application directory. The reason is that all resources have a unique resource ID which we need to get to load these resources. The following example shows how to get these unique identifier from the “path” of the resource. For example… Read More »

How to drag and drop a file from outside to your flex or AIR application and render it correctly?

By | April 7, 2012

Actually we have to do this by registering your application with the eventlisteners for NATIVE_DRAG_ENTER and NATIVE_DRAG_DROP. The following code shows how to do this. Just copy and paste the code to your MXML file and see the result. Drag and drop an image file from outside to your AIR application. import mx.controls.Alert; import mx.controls.Image;… Read More »

How to create shortcut for your application in the Desktop in Android?

By | April 7, 2012

Shortcuts are really useful feature in android. This example also explains how to create shortcut for your app in the desktop of your android phone. This is the complete code of an application which creates a shortcut of this app in the homescreen. Note : You need to add permission for this to work. Now… Read More »