Tag Archives: Sprite
How to use CCProgressTimer in Cocos2D to show progress?
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
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 out sprite sheet.… Read More »
Sprite 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 sheet animation and without sprite sheets. Here we are going to see how it can be done with out sprite sheet.… Read More »
Sprite 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 sheet animation and without sprite sheets. Here we are going to see how it can be done with out sprite sheet.… Read More »
Sprite 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 sheet animation and without sprite sheets. Here we are going to see how it can be done with out sprite sheet.… Read More »
How to change z order value of a sprite in Cocos2D ?
How to get a Sprite by tag in Cocos2D ?
How to make a sprite visible and invisible in Cocos2D ?
Hi, In order to make a sprite completely invisible , use the following code while using Cocos2D, this code will set the visibility of your sprite to zero. In order to make a sprite completely visible, use the following code while using Cocos2D, this code will set the visibility of the sprite back to one. 🙂
Identifying sprite associated with a particular body in Box2D
How to remove box2D body from world ?
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 { //Getting Touch Locations… Read More »
How to make a sprite visible and invisible in Cocos2D ?
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 yourSprite.visible = 0;… 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 »
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 »
How to stop the sprite sheet animation in cocos2D ?
Hi, In one of our previous post we have discussed how to animate sprite sheet in cocos2D. In some cases you may need to stop the sprite sheet animation abruptly. How to do that? Here the way to do that. Use the following. [spriteName stopAction:spriteNameAction]; where spriteName is the name of your sprite & spriteNameAction is the name… Read More »
Copying a Sprite Image to another Sprite in Cocos2D
Hi, Suppose you want to copy a sprite image to another new sprite while using cocos2D. What you do? See the following code… Let oldSprite be your first sprite CCSprite *oldSprite = [CCSprite spriteWithFile:@”ImgOne.png”]; And newSprite be your second sprite CCSprite *newSprite = [CCSprite spriteWithTexture:[oldSprite texture]]; That’s it! Done! Now newSprite too contain ImgOne as Sprite. 🙂
Create a polygon in Flash or Adobe AIR using Box2D.
The below function creates a polygon in the shape of a triangle. Please call the debugdraw function inside your update method to view the results. Make sure you import the Box2D classes into your file. public function init():void { debug_draw(); addEventListener(Event.ENTER_FRAME, update); createTriangle(); } public function createTriangle():void { var fd : b2FixtureDef = new b2FixtureDef(); var initVel :… Read More »
How to Implement Box2D in Adobe AIR?
Everyone will be fascinated how flash games are built on the web that implements the real world physics. Well for your information there are a lot of physics engines available. One of them is the Box2D. Box2D was written in C++. Then it was converted to flash. So now I am going to show you how to build… Read More »
How to check whether you have touched a body in Box2D iPhone?
How to rotate a body manually in Box2D?
The below code helps you to rotate a body in Box2D manually. Here the body is named “rotating_body” which is going to rotate and a sprite named “rot_sprite” is it’s userData, please give your own image for it. Make sure that you have it in your resources otherwise your program will crash. Note: call this function in a… Read More »