Monthly Archives: March 2011

“Conversion to Dalvik format failed with error 1” Error in ANDROID / Eclipse.

This is a normal error when you import some project into eclipse. I will show you how to solve this First try cleaning the project from project->Clean. If this didn’t work, then try these Follow these steps 1. Go to Project » Properties » Java Build Path » Libraries and remove all except the “Android X.Y” (eg: Android… Read More »

"Conversion to Dalvik format failed with error 1" Error in ANDROID / Eclipse.

This is a normal error when you import some project into eclipse. I will show you how to solve this First try cleaning the project from project->Clean. If this didn’t work, then try these Follow these steps 1. Go to Project » Properties » Java Build Path » Libraries and remove all except the “Android X.Y” (eg: Android… Read More »

Cocos2D Sprite Sheet Animation

Hi, Suppose you have a sprite sheet of the desired animation you want. But how will you use that sprite sheet animation in your program using cocos2D? That’s simple. See the following code first. Note : But how to make a sprite sheet? That topic can be found here. Making of sprite sheets from individual images are well… Read More »

Email id verification using Objective C

Hi, In order to verify an email address you have entered is valid or not using Objective C, use the following code. – (BOOL) checkYourMail: (NSString *) myEmail{ NSString *checkMail= @”[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}”; NSPredicate *matchMail = [NSPredicate predicateWithFormat:@”Matching %@”, checkMail]; return [matchMail evaluateWithObject:myEmail]; } 🙂

Using Gestures in ANDROID,A Simple example.

This is a really simple example illustrating gestures in ANDROID. You Know that everything you do with your hand inside the phone is a gesture like SingleTap, doubleTap etc. Here is a quick illustration of this. For this the activity must implement OnGestureListener. The GestureDetector detects the gestures. Let’s look at the example. The layout file main.xml for… Read More »

How to open browser in an ANDROID application? How to open a URL from an ANDROID application?

Hi all,In this tutorial I will show you how to open browser from an ANDROID application. This is done through intents. You know that intents are used to invoke other activities. So we here invoke the browser activity. The following code will open the default browser in your ANDROID phone. This is the manifest file for the above… Read More »

How to change the Z value of a Sprite during an action in Cocos2D ?

Hi, There may arise some situations where you need to change the z value of a particular sprite during an action in Cocos2D. So how can you do that? See the following lines of code. CCSprite *sample= [CCSprite spriteWithFile:@”trialImage.png”]; sample.position = ccp(160,240); [self addChild:sample z:1]; /* Some of your actions goes here! */ [self reorderChild:sample z:9]; This will… Read More »

Creating a Button using Objective C

Hi, Sometimes you may need to create some buttons to the View using Objective C code rather than using Interface Builder. Here is how you can do that easily and efficiently. //You can create button with type. Here I am creating a Custom Button UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; //Then what? Give action to be performed on it!… Read More »

Android listView with icons

In this post, we will have a list whose rows are made up of image, Here we just supply data to the adapter and helping the adapter to create a View objects for each row The output will be For this first create a xml file to hold the listview The next objective is to create the xml… Read More »

How to add files like images inside your emulator in ANDROID?

In many of our android applications we need images and other files to be inside your emulator, such as images in the gallery. But unlike iPhone we cannot simply drag and drop files inside the emulator., because iPhone’s is simply a simulator. It justs creates an envoronment for testing. But ANDROID mimics the real phone. So we need… Read More »

Retrieving Data from NSTextField in Cocoa Mac

Hi, If you want to retrieve the data a user typed in on a Cocoa Mac application, follow the following steps. 1. You first need to declare a NSTextField variable in .h file @interface SampleAppDelegate : NSObject { NSTextField *myText; } @property (retain) IBOutlet NSTextField *myText; 2. Then you need to synthesize it for properties in .m file… Read More »

Using NotificationManager in ANDROID for showing notification, sample code.

Multiple Notifications are a unique feature in ANDROID phones. This tutorial will show you how to create notification from your application. ANDROID uses the NotificationManager class to create the notification. Let’s look at the code. Explanation. mManager.notify(APP_ID, notification); This line in the code sends the notification where notification is the object of the Notification class where you can… Read More »

Changing the image of the sprite in cocos2D ?

Hi, You all know how to add an Image to a sprite. But what if we need to change the image of the same sprite? How to do that? Use the following line of code to change the image of a sprite which already initialized with a sprite. [sampleSprite setTexture:[[CCTextureCache sharedTextureCache] addImage:@”newImage.png”]]; where sampleSprite is the name of… Read More »

How to Flip Sprite in Cocos2D ?

Hi, On certain occasions you may need to flip the sprite you are using in your application. There are two ways to flip a sprite. Let’s see how this can be done along X-direction Method:1 mySprite.flipX = 180; where mySprite is the name of your sprite you want to flip. Method:2 CCFlipX *flipOnX = [CCFlipX actionWithFlipX:YES]; [mySprite runAction:flipOnX… Read More »