Tag Archives: CCSprite

Show Alert in cocos2D Android.

By | February 4, 2012

Here is a simple example showing alert in android cocos2D. For this I am using an example from my previous android cocos2D tutorial.. So please read that tutorial before reading this because the I am using the classes and files from it. I am only changing the Gamelayer.java file to show an Alert Dialog when the sprite move… Read More »

How to save data or score in Android Cocos2D?

By | January 21, 2012

Hello Friends Today I will show you how to save data in cocos2D android in a database and reload it when the game starts. This has been always a problem withe game developers for cocos2D android. I will show you a way to save almost any number of data in a database using SQlite in android. Check these… Read More »

How to implement a bomb explosion in Box2D iphone?

By | January 30, 2011

Below code is a simplest way to do that. [java] -(void) explodeBomb { b2Vec2 force = b2Vec2(0.25,0.70); // give the direction for the force. bombBody->ApplyLinearImpulse(force, bombBodyDef.position); CCSprite *sp = (CCSprite *) bombBody->GetUserData(); sp.opacity = 0; // setting the sprite in the body opacity to zero. [self schedule:@selector(destroyBomb) interval:2]; //destroying bombBody after 2 sec. } -(void) destroyBomb { CCLOG(@"Destroying… Read More »

How to add infinite backgrounds in Cocos2D, iphone?

By | December 24, 2010

You often may need scrolling backgrounds in your game or any other application. The following code helps you to add continuous backgrounds. Each sprite is added to the right of the current sprite which make them continuos. //Add more stripes, flip them, and position them next to their neighbour stripe. for (int i = 0; i < numStripes;… Read More »