3

我正在使用 Cocos3D。我有一个不同CC3Nodes的列表。我想在每个图像旁边放一张图像。我的问题是:如何创建一个新的CC3Node并将其添加为子级。

4

1 回答 1

2

你需要做这样的事情:

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];

并为每个节点执行此操作:

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

最后,如果您想将这些节点添加为每个节点作为子节点,请执行以下操作:

[previousNode addChild:newNode];  

代替:

[self addChild:newNode];

我希望这个对你有用!

于 2011-11-03T15:04:29.870 回答