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
43
votes
9 answers

How to differentiate between iphone4 and iphone 3

I am trying to build a game for the iphone using cocos2d engine. I wanted to know how can I tell a difference whether the user is using iphone 4 or iphone 3 as I wanted to load hi-resolution graphics for the iphone4 and low-resolution for iphone 3.…
Ankur
  • 731
  • 2
  • 9
  • 17
30
votes
5 answers

how to obtain a CCSprite's width and height in cocos2d for iphone

That's the question xD Given an instance of a CCSprite in cocos2d in iphone, what method can I use to obtain the image width and height?
Manuel Araoz
  • 15,962
  • 24
  • 71
  • 95
15
votes
1 answer

TDD for Cocos2d-X in android

How do I write the TDD for "is sprite added or not" in the scene for cocos2d-x in eclipse. Here is my code CCSprite *sprite =null; //adding sprite code sprite = new…
RohitK
  • 1,444
  • 1
  • 14
  • 37
11
votes
1 answer

What are drawbacks of using data URI instead of sprite images?

Consider this conditions for my website: I don't support IE8 and below so browser support is not a problem. I also use gzip that would avoid data overload in CSS in cases that I copy and paste data URI images in my CSS file. I only have one CSS…
Mohsen
  • 64,437
  • 34
  • 159
  • 186
10
votes
2 answers

Line Drawing + Intersection of that line with self and also detect CCSprites inside that drawn Line

I am drawing the line using following code, it works just amazing, http://www.merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/ Now I want to..... 1> Detect if the line Intersect with itself. 2) Detect if CCSprite is…
Anand
  • 1,129
  • 7
  • 29
10
votes
4 answers

How to swap the sprite in the CCSprite object in Cocos2d-X

I have an object that inherited from CCSprite. I want from inside this object to change the image. How do I change the image (sprite) without creating a new CCSprite object in Cocos2d-X? Thanks, Adrian.
azelez
  • 2,501
  • 2
  • 27
  • 26
9
votes
4 answers

Cocos2D Rotation and Anchor point

The problem that I have is that when ever I change the anchor point sprite automatically rotates with respect to the current anchor point. And I don't want that to happen. The steps that I followed create a sprite with anchor point (0.5,…
Jose Antony
  • 103
  • 1
  • 7
9
votes
1 answer

Rendering in cocos2d-x using values from a math function

Good morning. I'm on linux, using cocos2d-x for Android. I have created a function that calculate circle values. // Circle point updateCircle() // x = number of iteration · SamplingPeriod |-|-|-| // y = A · sine ( 2 · PI · number…
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
8
votes
2 answers

How do I properly use CCSpriteFrameCache and CCSpriteBatchNode?

I do not understand what I do exactly when I add a CCSpriteFrameCache or CCSpriteBatchNode to my cocos2d application. Can somebody please explain the following points (it would be helpful if you could explain a few; please write the corresponding…
the_critic
  • 12,720
  • 19
  • 67
  • 115
7
votes
1 answer

cocos2d : why convertToGL, and why addChild CCSprite before its body?

i'm starting to learn cocos2d, and i was wondering why actually we use convertToGL from CCDirector, [[CCDirector sharedDirector] convertToGL: touchLoc]; when we already have the [touch view] from [touch locationInView: [touch view]]; ? Also, we…
Paul
  • 6,108
  • 14
  • 72
  • 128
6
votes
2 answers

Getting and setting the RGB / RGBA value of a pixel in a CCSprite (cocos2d-x)

Why do I need this? Basically I need to turn a color image into gray-scale. Including a gray-scale version of the image could be a solution, but space is tight in my situation - I don't want my APK to be too big. Besides, I would like to work on the…
6
votes
3 answers

How to switch the image of a CCSprite

I have a CCSprite that is initialized using [CCSprite spriteWithSpriteFrameName:@"plist_file_key_here.png"]. I have already added all the sprites from my plist file to CCSpriteFrameCache. I have tried setting the texture like this: CCSpriteFrame *…
Ben Trapani
  • 271
  • 1
  • 4
  • 11
6
votes
4 answers

How can I get a child CCSprite to draw on top of its parent?

I'm trying to control the order in which CCSprites are being layered one on top of the other. I'd use zOrder, but I'm animating characters made up of articulated sprites (some sprites parented on others with addChild) and zOrder is only honored…
Dylan
  • 2,315
  • 2
  • 20
  • 33
6
votes
1 answer

cocos2d and box2d : sprite touch not get properly

I have added 7 sprites and give them tag and zorder.. but i can't get touch on third object and at last there is only one object remained then i get touch of it.. But when i added 6 sprites i'll get touch properly. all sprites positions are same but…
Hiren
  • 112
  • 7
5
votes
1 answer

Accessing Objects in other Layers (cocos2d)

I was playing around with a Joystick moving a Sprite around in one layer. Now, according to best practice, the Joystick and the Sprite have to be in different Layers of the same scene. I have managed to separate these, yet I am now completely stuck…
clops
  • 5,085
  • 6
  • 39
  • 53
1
2 3
28 29