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
5
votes
1 answer

Moving Box2d Bodies Like CCSprite Objects

In cocos2d, you can ease in CCSprites and move them around in all kinds of ways. Most importantly - they can have easing in/out. For most games this is desirable for smooth movement etc. id action = [CCMoveTo actionWithDuration:dur…
Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96
5
votes
0 answers

How to Save CCSprite as PNG

I created CCSprite and add it to the main view. Then I want to see the sprite image, so I saved it to PNG But lots of them doesn't saved correctly. Only show white background. I can't know the reason, and also found some articles via Google, but…
bTagTiger
  • 1,261
  • 5
  • 23
  • 38
5
votes
2 answers

Outline (stroke) for non-rectangular CCNode in cocos2d

I need to create an outline like this dynamically: Not for a CCSprite, but for multiple animated CCSprites united in one CCNode. I'm thinking about: copying CCNode's content to a texture (like canvasBitmapData.draw(sourceDisplayObject) in…
Ivan Mir
  • 1,209
  • 1
  • 12
  • 32
5
votes
2 answers

Images are not displayed and showing error like "cocos2d: CCTexture2D: Using RGB565 texture since image has no alpha"

I am making an application using Box2D in which i am getting images from Asset Library and displaying them as sprites. here is the code which i have done : Getting Images from asset library : CGImageRef imgRef = [[mutArrAssetPhotos objectAtIndex:i]…
Mansi Panchal
  • 2,357
  • 18
  • 27
5
votes
1 answer

CCSprite positioning issue on top of other CCSprite as it animates up screen?

In my app I have a character that has feet and I want to make it so that in my app it looks like it is standing on top of another CCSprite as it travels UP the screen (an animation). Everything is working fine EXCEPT there is a little positioning…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
4
votes
2 answers

Flip CCSprite Horizontally After Adding to Layer

I'm creating a fish for an app that swims to random locations on the screen. Before the fish begins swimming towards the next location, it rotates to the angle between its starting point and the target point. What I'm trying to figure out is: if…
Matisse VerDuyn
  • 1,148
  • 15
  • 40
4
votes
3 answers

Cocos2d show only a part of a CCSprite

Is there any possibility to show only a part of an CCSprite? It seams that contentSize property doesn't have a good result.
mxg
  • 20,946
  • 12
  • 59
  • 80
4
votes
1 answer

How to transfer a CCSprite from one parent to another?

I have a CCSprite called sprite that is a child of a CCLayer called movingLayer that is itself a child of the current CCLayer running my game logic, so it is self in this case. movingLayer is moving back and forth across the screen in a repeat…
Steve
  • 6,332
  • 11
  • 41
  • 53
4
votes
2 answers

Find the closest CCSprite

I am trying to find the closest "player" to a "ball" and each of these objects are CCSprite Objects. This is my first app, so if there's a better way to do this, feel free to suggest it :) Here's my code so far: for(CCSprite *currentPlayer in…
Doug Molineux
  • 12,283
  • 25
  • 92
  • 144
4
votes
1 answer

New Cocos2D 3.x API's?

I am upgrading my app like others to Cocos2D 3.0 as we speak. I am having trouble though with some methods in the app. 1: I also use the accelerometer like so: self.AccelerometerEnabled = YES; however this has also been changed, what is the…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
4
votes
1 answer

Cocos2d - move a sprite from point A to point B in a sine wave motion

What would be the best way to do this? I see the CCEaseSineInOut action but it doesn't look like that could be used to do this. I need to move from one side of the screen to the other. The sprite should move in a sine-wave pattern across the screen.
soleil
  • 12,133
  • 33
  • 112
  • 183
4
votes
2 answers

Cocos2d - retina images not displaying

Simply trying to test retina display. I setup the director like this: CCDirectorIOS* director = (CCDirectorIOS*)[CCDirector sharedDirector]; director.wantsFullScreenLayout = NO; director.projection = kCCDirectorProjection2D; …
soleil
  • 12,133
  • 33
  • 112
  • 183
4
votes
2 answers

Strange error: CGImageProviderCreate: invalid image provider size: 55 x 36

I am using Objective-c and cocos2d, and I am getting the strangest error when combining two pieces of seemingly unrelated code. The suspected code in the init of a layer. /* sprite setup */ CCSprite *sprite = [ [ [ StaticSprite alloc ]…
dqhendricks
  • 19,030
  • 11
  • 50
  • 83
4
votes
1 answer

Cocos2D - Automatically set sprite movement with speed

I was wondering how I could immediately make my sprite CCSprite *van move automatically from the start with controllable speed like int *speed = 1, 2, 3+. I looked around but all I found were not fitting my needs. Is there a simple solution to this…
Burrito411
  • 431
  • 1
  • 8
  • 15
4
votes
2 answers

CCSprite Fadeout with children

I'm using a CCSprite with a few other CCSprite objects added as children, the other animations I'm using (scale and rotate) work great and the children are animated too. But when I'm using CCFadeOut, it only fades the parent. I've read that fadeout…
Thomas
  • 649
  • 9
  • 17
1
2
3
28 29