Category Archives: Cocos2D

How to Fix ‘Warning : Multiple Build Commands For Output File’ ?

By | June 14, 2011

Hi, The following warning, ‘Multiple Build Commands For Output File’ occurs when you try to delete resource files by ‘delete reference’ other than the correct method of‘move to trash’ while deleting files from ‘Resources’ folder of your project. Therefore the Copy Bundle Resources still holds the references of the same file you have deleted and… Read More »

How to Fix ‘Warning : Multiple Build Commands For Output File' ?

By | June 14, 2011

Hi, The following warning, ‘Multiple Build Commands For Output File’ occurs when you try to delete resource files by ‘delete reference’ other than the correct method of‘move to trash’ while deleting files from ‘Resources’ folder of your project. Therefore the Copy Bundle Resources still holds the references of the same file you have deleted and… Read More »

How to detect shake in iPhone ? An example

By | April 13, 2011

Hi, Sometimes you may want to detect shake gesture in iPhone using your programs. But how can you detect shake gesture in iPhone? Shake gesture in iPhone can be detected by using the accelerometer. The following lines of code can be used for detecting the shake gesture in iPhone. You can use these lines of… Read More »

How to remove box2D body from world ?

By | April 10, 2011

Hi, If you are a game developer and you are using box2D for real world simulations, you would probably need a particular body to be removed from the box2D world! But how can you remove box2D body from world ? See the following sample code which does the same. – (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {… Read More »

How to empty an NSMutableArray ?

By | April 6, 2011

Hi, Sometimes you may need to empty an NSMutableArray which is already initialized with some objects. You don’t need to release it and again alloc it for future use! You can simply empty an NSMutableArray using the following line of code. [yourArray removeAllObjects]; Here ‘yourArray’ is your NSMutableArray. 🙂

How to make Sprite Sheets ?

By | April 2, 2011

Hi, If you are a game developer then you will always need a sequence of images to be animated & the best way to do it is via sprite sheet animations. But how can a sprite sheet be made? Suppose you have a sequence of images of any animations, how will you convert it into… Read More »

Cocos2D Sprite Sheet Animation

By | March 29, 2011

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… Read More »

How to make a sprite visible and invisible in Cocos2D ?

By | March 27, 2011

Hi, In certain situations you may need to make visible or invisible certain sprites. But how to set a sprite visible and invisible in Cocos2D? See the following Cocos2D code. //Set the sprite’s visible value to 1 to make it visible yourSprite.visible = 1; //Set the sprite’s visible value to 0 to make it invisible… Read More »

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

By | March 27, 2011

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… Read More »

How to show more than one animation in sequence in Cocos2D?

By | March 25, 2011

For showing a number of animations sequentially in Cocos2D we use the CCSequence. CCSequence can accept a number of actions as parameters which will be executed in sequence , ie one after another. Here is a sample code to so this. /* This action will scale my_sprite */ id scaleTo = [CCScaleTo actionWithDuration:4 scale:1.5]; /*This… Read More »