【发布时间】:2011-12-19 17:41:17
【问题描述】:
我正在使用 Cocos3D。
我有一个不同CC3Nodes 的列表。我想在每个图像旁边放一张图像。
我的问题是:如何创建一个新的CC3Node 并将其添加为子级。
【问题讨论】:
我正在使用 Cocos3D。
我有一个不同CC3Nodes 的列表。我想在每个图像旁边放一张图像。
我的问题是:如何创建一个新的CC3Node 并将其添加为子级。
【问题讨论】:
你需要做这样的事情:
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];
我希望它对你有用!
【讨论】: