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

cocos2d CCDrawNode scale bounding box

I'm using cocos2d and I create a CCDrawNode. The moment I call addChild: to add the CCDrawNode I call the following method to make the node scale forever: CCActionScaleBy *scaleAction = [CCActionScaleBy actionWithDuration:0.3f…
jkigel
  • 1,592
  • 6
  • 28
  • 49
0
votes
1 answer

Cocos2d: the best way to compose an object that will contain several Sprites

I need to create an object that contains several sprites (2 for simplicity: the game object and its' shadow). I need to compose them into the same class, so having the following questions: what is the best ancestor class to the described one? I…
nickolay
  • 3,643
  • 3
  • 32
  • 40
0
votes
2 answers

First Tap touch event

Hi Im making a cocos2d game that has a sprite flying and falling, Im trying to have a first tap touch event for example when the user touches the screen for the first time it'll start the game animation and start the physics engine. Whats happening…
0
votes
1 answer

Set position of CCLabelTTF in CCNode and add to CCScene [cocos2d v3]

I'm having trouble understanding what is going on here. I currently have a "Header" class that inherits from CCNode. This CCNode class has multiple properties including CCSprite's and CCLabelTTF's. In the init, I create these objects and set their…
SpellChucker
  • 450
  • 5
  • 18
0
votes
1 answer

All sprites added to CCNode are clumped in one point

I used Hearts1.CCPositionType = CCPositionTypeNormalized for my CCNode, Hearts1. For all sprites inside the node, I also used CCPositionTypeNormalized None of my sprites seem to move around, they just stack on top of each other in the same point. Do…
user3271769
0
votes
1 answer

Cannot add CCNode to Scene

I have the IntroScene, and I wanna add a node, but it doesn't seem to work. Here are two different ways I tried doing it, and BOTH failed. First way, failed: in hearts2.h #import #import "cocos2d.h" @interface Hearts2 :…
user3271769
0
votes
2 answers

Got EXC_BAD_ACCESS error in ARC Enabled cocos2d Project?

I followed the sample project from raywnderlich to venture into my first cocos2d application. In that application moving targets are added like below -(void)addMonster { __strong CCSprite * monster = [CCSprite…
vignesh kumar
  • 2,310
  • 2
  • 25
  • 39
0
votes
4 answers

The CCTouch events for CCNode in cocos2d-X

I tried to search but couldn't find the desired answer, can anybody tell me what are the CCTouch events for CCNode? As we have CCTouchBegan, CCTouchMoved and CCTouchEnded for CCLayer
Zubair
  • 304
  • 1
  • 5
  • 19
0
votes
0 answers

iOS, cocos2d. Debug info about current node, layer, scene using a category?

I found this code: link It shows a label about a class of current UIViewController. How to realize the similar thing for cocos2d? It is enough easy with subclassing but is enough hard with a category. And if I use subclassing for an existing project…
user2083364
  • 744
  • 1
  • 7
  • 20
0
votes
2 answers

CCNode retained by CCCallBlock after stopAllActions is called

I have a utility function that I use to move a CCNode in a circular path either for a full circle, or a partial circle. The function works really well, but if I want the CCNode to continually follow the path, which I do via a passed in Block that…
PKCLsoft
  • 1,359
  • 2
  • 26
  • 35
0
votes
2 answers

init methods inheriting from CCNode

I have a question about creating custom init methods in my Player class that inherits from CCNode. Not sure if I need to instead take a different route and create class methods instead: + (id) addSprite: (CCSprite*) sprite…
badboy11
  • 541
  • 1
  • 6
  • 19
1 2
3