Questions tagged [ccsprite]

CCSprite is a 2D image that is integrated into a larger scene in cocos2d, which normally represents a character or object in a cocos2d game.

CCSprite is a class inheriting from CCNode, which normally represents characters or objects displayed in the cocos2d games.

In computer graphics, a sprite is a two-dimensional image or animation that is integrated into a larger scene. A cocos2d' CCSprite is like any other computer sprite. It is a 2D image that can be moved, rotated, scaled, animated, etc.

  • CCSprite can be created with an image, or with a sub-rectangle of an image.

  • CCSprites can have other sprites as children. When a parent is transformed, all its children are transformed as well.

  • Since CCSprite is subclass of CCNode, they can be transformed manually or by using CCActions.

You can find the details about sprites on Wikipedia.

The CCSprite class reference is given at: http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_sprite.html

424 questions
4
votes
4 answers

How to shake CCsprite in cocos2d?

I have a CCSprite in my game, representing an egg. How do I go about shaking it? I tried the following, but without success: id Runleft = [CCMoveTo actionWithDuration:0.1 position:ccp(244, 156)]; id RunRight = [CCMoveTo actionWithDuration:0.1…
Nims
  • 431
  • 6
  • 15
4
votes
2 answers

How to get RGBA color of a specific pixel in CCSprite

I am writing a game for iPhone using the cocos2d for iPhone v1.0.1 library. To get my game work fine I need to check the color of a specific pixel in a CCSprite when i know the coordinates. I have been looking for the solution for two days but I did…
jarektb
  • 71
  • 1
  • 3
4
votes
2 answers

Getting absolute position of CCSprite in cocos2d

In my game, I have a CCSprite that orbits another CCSprite, much like an electron orbiting a nucleus. I have the electron as a child of the nucleus, to make animation much simpler. All I have to do is rotate the nucleus and the electron follows…
GreenWire
  • 193
  • 4
  • 15
3
votes
1 answer

Add rounded corners to UIImage?

I know it is possible to have rounded corners on objects like a UIImageView (I have done it before). But in this case, I need to have my square UIImage to have rounded corners. I know it is more difficult than just doing it to an object but I need…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
3
votes
2 answers

How to change the image of a CCSprite in cocos2d v3.x

In cocos2d 2.x we change the image of a CCSprite using CCTexture. But in cocos2d 3.x CCTextureCache seems to be deprecated as Xcode warns me : "undeclared identifier 'CCTextureCache'". Or may be am I miss something as I'm new to cocos. So how can we…
lsmpascal
  • 762
  • 8
  • 24
3
votes
2 answers

get facebook profile picture

currently i want to get facebook profile picture then convert the picture into CCSprite. so far my code look like this : //fbId is facebook id of someone NSURL *url = [NSURL URLWithString:[NSString…
3
votes
2 answers

I want to move sprite body when touch point detect

I want to move sprite body when i touch screen but it cant happen... -(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event { for(b2Body *b=world->GetBodyList();b;b=b->GetNext()) { CGPoint location=[touch locationInView:[touch…
Diken Shah
  • 69
  • 6
2
votes
0 answers

Detect collision between a CCSprite and a CCMotionStreak

I have a CCSprite with a Box2d body attached. I'm doing this because my CCSprite is an irregular shape. I did this based on http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone. However, the tutorial is…
vwee
  • 75
  • 5
2
votes
2 answers

How to pause animated sprite animation in Cocos2d?

I want to pause/unpause animation for particular sprite when proper message appears. I would do this by CCNode::stopAllActions() but it cancels all the animations which are then meant to set up again. I just want to do it in a quick pause/unpasue…
pro_metedorr
  • 115
  • 2
  • 7
2
votes
2 answers

Cocos2dx Inherited CCNode class not rotating around around its center?

I'm at a bit of a loss here, forgive me if this has already been asked - i've have searched google high and low but i cant find anything? i'm trying to rotate a group of sprites that are generated in a class, then rotating this object in the main…
A Devanney
  • 63
  • 8
2
votes
3 answers

cocos2d can't add sprite to another sprite

I have a background that extends CCSprite from the cocos2d framework. And I have added this sprite to the gamelayer. Now in this background class I try to add other CCSprites named Star like so: //create the stars stars = [[CCArray alloc] init]; for…
Marnix v. R.
  • 1,638
  • 4
  • 22
  • 33
2
votes
2 answers

Objective C - app works in simulator and on other iPhones, but won't run on my own iPhone 4

My app works fine in the simulator, and on other devices. I have an iPhone 4 with the latest iOS update, and the app refuses to run on my device. It seems to be a problem surrounding retina-display images. The error spew I get when attempting to…
Kevin Whitaker
  • 12,435
  • 12
  • 51
  • 89
2
votes
2 answers

Cocos2D prevent sprite from going off-screen?

Is it possible to prevent my CCSprite from going off-screen? I already allow it to go offscreen on the left and right so that is fine but I just want to stop it from going off screen on the top and bottom. So far what I have done is just cause the…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
2
votes
1 answer

PNG Transparency in cocos2d iphone issue

I've just begun cocos2d development on the iphone. An issue I'm having is that when I add a CCSprite to my scene, instead of it being transparent around the edges of the .png file, its showing up as white. So for example, I define the CCSprite in…
aur1nko
  • 23
  • 2
2
votes
3 answers

cocos2d sprite collision

I have an Array of CCSprites that being displayed all at once. Every sprite has a movement path, a movement path is a random point on screen. All the sprites are moving all at once to random points on screen. What I want to do is to detect collision…
user330885
1 2
3
28 29