How to detect shake in iPhone ? An example
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...
View ArticleHow to detect single/double/triple taps in iPhone ?
Hi, How can you detect single/double/triple taps in iPhone using Objective C? Use the following code to detect single or multiple taps in iPhone/iPad/iPod. The code can also be used with Cocos2D &...
View ArticleHow to Show Cocos2D Particle Effects Repeatedly ?
Hi, For showing particle effects repeatedly in Cocos2D, use the sample code. CCParticleSystemQuad *yourParticleEffect = [CCParticleSystemQuad particleWithFile:@"yourEffect.plist"]; [self...
View ArticleHow to call a function after fixed time interval in Cocos2D ?
Hi, For calling a function after a definite time interval in Cocos2D, use the following code. [self performSelector:@selector(yourFunction) withObject:nil afterDelay:7.0]; this will call the function...
View ArticleShow Alert in cocos2D Android.
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...
View ArticleHow to open browser from android cocos2D Application?
This code snippet helps you to open browser in android cocos2D application public void openBrowser(){ CCDirector.sharedDirector().getActivity().runOnUiThread(new Runnable() { public void run() { Intent...
View ArticleSprite Animations Without Sprite Sheets
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...
View ArticleHow to get Device Orientation in Cocos2D, iPhone in Objective C?
Hello all…… We may need to know that what is your current device orientation. Using the below code you can do this. if([[UIDevice currentDevice] orientation] == kCCDeviceOrientationPortrait) {...
View ArticlePause And Resume iPhone Game Using Cocos2D
More than usually we need to apply the functions of Pause and Resume/Play for our games. In Mac’s cocos2D programming it’s more than simple. Simply use the following code for Pause & Resume where...
View ArticleHow to move a body manually in Box2D? or Give a force to a body in Box2D,...
This is a sample code to move a body in Box2D . First you have to make a body with variable name “moving_rec” and call the below function in a schedular at regular intervals. -(void) moveBody{ b2Vec2...
View Article
More Pages to Explore .....