Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add image as child of a CC3Node

I'm using Cocos3D. There i've a list of different CC3Nodes. I want to put an image next to each of it. My problem is: how to create a new CC3Node and add it as a Child.

like image 611
Adrian Avatar asked Dec 07 '25 05:12

Adrian


1 Answers

You need to doing something like this:

CC3PlaneNode *imageNode = [CC3PlaneNode nodeWithName:@"One Plane Node on 3D Object"];
[imageNode populateAsCenteredRectangleWithSize: CGSizeMake(200.0, 200.0)
    andTessellation:ccg(40, 40) withTexture: [CC3Texture textureFromFile:@"Your Image Address"] invertTexture: YES];
imageNode.material.specularColor = kCCC4FLightGray;
imageNode.shouldCullBackFaces = NO;
[imageNode retainVertexLocations];
[self addChild:imageNode];

And for doing this for each Node:

CC3PlaneNode *newImageNode = [imageNode copyWithName:@"New Node Name"];
...
[self addChild:newImageNode];

At the end of it, if you want to add these node each node as a child do:

[previousNode addChild:newNode];  

instead of:

[self addChild:newNode];

I hope it works for you!

like image 146
Hamed Rajabi Avatar answered Dec 11 '25 20:12

Hamed Rajabi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!