Questions tagged [ccnode]

CCNode is the main element of a framework. Anything that gets drawn or contains things that get drawn is a CCNode. The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu.

The main features of a CCNode are:

  • They can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc)
  • They can schedule periodic callback (schedule, unschedule, etc)
  • They can execute actions (runAction, stopAction, etc)
  • Some CCNode nodes provide extra functionality for them or their children.

Subclassing a CCNode usually means (one/all) of:

  • overriding init to initialize resources and schedule callbacks
  • create callbacks to handle the advancement of time
  • overriding draw to render the node

Features of CCNode:

  • position
  • scale (x, y)
  • rotation (in degrees, clockwise)
  • CCCamera (an interface to gluLookAt )
  • CCGridBase (to do mesh transformations)
  • anchor point
  • size
  • visible
  • z-order
  • openGL z position

Default values:

  • rotation: 0
  • position: (x=0,y=0)
  • scale: (x=1,y=1)
  • contentSize: (x=0,y=0)
  • anchorPoint: (x=0,y=0)

Limitations:

  • A CCNode is a "void" object. It doesn't have a texture
41 questions
11
votes
1 answer

Moving a Stick figure, anchorpoints, animation, or something else...?

Ok so I am making a game with stick figures with cocos2d in objective c... Different things need to be animated so please, give me a suggestion of what would be the best way to go about accomplishing the movement for these things: The main…
Gabriel
  • 3,039
  • 6
  • 34
  • 44
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
4
votes
2 answers

Rotated Clipping Node in Cocos2d

I'm using the clipping node here: http://www.learn-cocos2d.com/2011/01/cocos2d-gem-clippingnode ClippingNode.h #import "cocos2d.h" @interface ClippingNode : CCNode { CGRect clippingRegionInNodeCoordinates; CGRect clippingRegion; } @property…
docchang
  • 1,115
  • 15
  • 32
3
votes
1 answer

cocos2d : How to clone a CCNode hierarchy

I try to clone a CCNode hierarchy, the problems is I need to reset and set all the variable by type, can I have a way to do that more automatically ? basiclly what I want to do is : - store a CCNode* (with some child, for example an image at Pos…
user1482649
  • 45
  • 1
  • 7
2
votes
1 answer

setParent addChild does not seems to refresh children position in cocos2d-x 3.6

I want to change the parent of sprite, using oldparent->removeChild(child) from the old parent node, and then child->setParent(newparent) in the child sprite, passing the new parent as param. also tried with newparent->addChild(child). The issue is…
cesarpachon
  • 1,179
  • 2
  • 10
  • 23
2
votes
1 answer

Cocos2d V3 How change z order of child? reorderChild is not available in V3

Cocos2D V3 does not contain CCNode reorderChild:z: How can I change the z order of a CCNode in V3? Any help much appreciated.
2
votes
2 answers

Cocos2d - Change CCNode Image Programmatically

Does anyone know how to change a CCNode's image programmatically? I'm using SpriteBuilder to make a simple game.
Jude Michael Murphy
  • 1,198
  • 2
  • 12
  • 23
1
vote
1 answer

Cocos2d Node not accepting Touches

Cocos2d v3: I have a very strange problem. I have a dozen or so CCNodes that are acting like menus for my game. They take up just a small section of the center of the screen. To present one node I hide (node.visible = NO) all the other nodes. Two of…
Asdrubal
  • 2,421
  • 4
  • 29
  • 37
1
vote
1 answer

Add CCNodes to a Parent CCNode using a for loop

-(CCNode *)createFieldNode:(NSMutableArray *)fieldArray{ CGSize winSize = [CCDirector sharedDirector].viewSize; CCNode* stackNode= [CCNode node]; for (int i; i <=fieldArray.count; i++){ //itemP is previous item in array and…
Asdrubal
  • 2,421
  • 4
  • 29
  • 37
1
vote
1 answer

Game over popup in Cocos2d v3 iOS

I want to create a Game Over Pop Up, with two buttons and a high score label etc.. This pop up will be visible when the game over event happens and the gameplay scene will be paused. I tried to implement a game over scene (a separate GameOver class)…
Hyder
  • 1,163
  • 2
  • 13
  • 37
1
vote
1 answer

Interstitial iAd on cocos2d issues

Im trying to get interstitial ads in my cocos2d game I made but having trouble getting it to work. Ive tried this snippet I found online for iOS7 but I cannot get it to work. Since the Controller uses CCNode instead of UIViewController Im not sure…
1
vote
1 answer

Cocos2d - how to scale two CCNodes with respect to each other

I have two CCNodes in Cocos2d that I want to dynamically scale in sync with each other. Both CCNodes are background nodes. Visually one CCNode, NodeA, is above the other CCNode, NodeB in the y direction. But when I scale both nodes at the same…
James Testa
  • 2,901
  • 4
  • 42
  • 60
1
vote
2 answers

CCNode recursive getChildByTag

As far as I understand the CCNode::getChildByTag method only searches among direct children. But is there any way to recursively find a CCNode's child by tag in all its descendant hierarchy ? I'm loading a CCNode from a CocosBuilder ccb file and I'd…
sdabet
  • 18,360
  • 11
  • 89
  • 158
0
votes
1 answer

How to initialize a color in a CCNode instance variable for SpriteBuilder and Swift?

Here's my code so far. My plan is to eventually give each variable a randomized value but when I update them in my game, but in the class I think I should create instance variables and initialize them to something. import UIKit class Planet:…
user2398046
0
votes
0 answers

CCNode addChild from method

I am trying to add a CCNode to my scene. It works using this in the scene class (Level.m) itself: - (void)didLoadFromCCB { CCLOG(@"didLoadFromCCB"); self.userInteractionEnabled = TRUE; CCNode *node = [CCBReader…
cocoseis
  • 1,443
  • 1
  • 13
  • 35
1
2 3