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
0 answers

Fixed sprite on the tile map cocos2d?

I can't figure out how to handle with tile map layer and other node. I want to make another one layer(CCNode) for such things as menu button, score, joystick that must always stay fixed(not scrolled), when the whole map is…
user3475724
0
votes
1 answer

How to remove a CCnode with a touch?

I need help I have tried to remove a ccnode that constantly is respawning at different locations and adding them to an array to get control of which sprites are on screen, but the thing is that I can't get to remove them. It detects the touches but…
0
votes
0 answers

Cocos2D runaction doesn't run

I have a project with 2 Scenes. In my second Scene, i have a button. This button when clicked create at runtime a CCNode from a SPriteBuilder Resources. This CCNode called "Strategy", has 5 custom CCNode created in SpriteBuilder in the Strategy…
Allen Walker
  • 866
  • 1
  • 9
  • 17
0
votes
1 answer

Get position of CCSprite

Im a bit confused. I am trying to move one CCSprite onto the position of another CCSprite. I figured it would be simple, but the CCSprite isn't positioning correctly. I have 2 CCSprites: //Get Position of EMPTY SPRITE CCSprite *sprite =…
Allreadyhome
  • 1,252
  • 2
  • 25
  • 46
0
votes
1 answer

Get CCNode/CCSprite within FOR statement

I have numerous CCNodes that all have the same query run on them. I am trying to stream line the code and am wondering if its possible to get the CCNodes within a FOR statement. For example if I had the CCNodes references within a NSArray like…
Allreadyhome
  • 1,252
  • 2
  • 25
  • 46
0
votes
0 answers

Handle Button in CCNode from CCScene

I'm creating a game in cocos2d v3. In the CCScene, I add a CCNode that contains all the components for my HUD. In the CCNode, there are CCButtons added. I want to be able to handle the touch of these buttons in my CCScene. Is that possible? And if…
SpellChucker
  • 450
  • 5
  • 18
0
votes
1 answer

Disable background userinteraction - Cocos2d

I have a custom CCNode that I am using for providing notifications on a popup basis. I am trying to disable the background when the CCNode is popped up but allow user interaction on the new CCNode. I can disable the parent UIView by using the…
memyselfandmyiphone
  • 1,080
  • 4
  • 21
  • 43
0
votes
1 answer

FadeTo animation doesn't work. cocos2d

According to this code node must slowly appear, right? It doesn't work. What is wrong? CCNodeColor *_backNode = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0 green:0 blue:0 alpha:1.0f]]; _backNode.opacity=0; [self…
user3475724
0
votes
2 answers

Texture position of a sprite shifted [cocos2d v3]

I've been struggling for days with that problem: I have CCNode >> StateComponent and in the StateComponent I have a CCSprite as an attribute and add it as a child in StateComponent. When I set the position of an StateComponent object and NOT of the…
0
votes
1 answer

How to delete a CCNode in sprite builder through Xcode

i am making an angry birds game. At the moment i have 3 birds to the side of the screen. Each time i fire a bird i want to delete one of the animations. How do can I delete a CCNode in sprite builder through Xcode?
user3704648
  • 349
  • 3
  • 14
0
votes
1 answer

Convert UIColor to CCNodeColor

As I'm passing NSStrings into UIColors and what not, for my cocos2d application, I am storing a colour for the scene's background in a UIColor variable, however would like to then convert the UIColor to a CCNodeColor variable? Obviously, the sample…
0
votes
0 answers

Initializing a child CCNode onto a parent CCNode

I am working with SpriteBuilder and Cocos2d to build a simple game, and I want to display an error message inside an if statement. My problem is trying to initialize the CCNode I created in SpriteBuilder to show up on-screen. I tried creating a…
Albert K
  • 25
  • 7
0
votes
1 answer

How does one override "draw" in a CCNode?

I am creating a side scrolling game. I compute all the points representing what a terrain should look like by doing the following: The points representing the top of the hill are determined by using a sin function. The bottom of the hill is just…
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
0
votes
1 answer

CCButton not working completely when pressed in Cocos2D v3 iOS

I have a gameplay scene, over which I add a CCNode as a child. My Game Over node has a replay CCButton in it. The button is supposed to restart the game play scene. The problem is, when I press the "Restart" button, it goes through the lines but it…
Hyder
  • 1,163
  • 2
  • 13
  • 37
0
votes
1 answer

cocos2d-x 3.0rc0 for android in ubuntu: how to compare two CCNodes

In the current cocos2d-x 3.0rc0 distribution, the method "isEqual" doesn't seem to be available for CCNode. Using node1->isEqual(node2) I get an error saying "error: 'cocos2d::CCNode' has no member named 'isEqual'" ) How can I compare two nodes…
user2212461
  • 3,105
  • 8
  • 49
  • 87