I have an app with a cocos3d scene in which I have a 3D animated model. I want to add some effects to the scene and I was thinking of using planes textured with a sprite animation.
I've been able to add the full sprite image to the scene correctly, but this isn't obviously what I want to do.
CC3PlaneNode *sprite = [CC3PlaneNode nodeWithName:@"Sprite"];
[sprite populateAsRectangleWithSize:CGSizeMake(10, 10) andRelativeOrigin:CGPointMake(0, 0)];
sprite.location = cc3v(-0.5, -1, -5);
CCTexture* tex2D = [CCTextureCache.sharedTextureCache addImage:@"equalizer.png"];
CC3Texture* tex3D = [CC3Texture textureWithCCTexture: tex2D];
tex3D.name = @"EqualizerTextureFile";
[CC3Texture addTexture: tex3D];
sprite.texture = tex3D;
[self addChild:sprite];
I've noticed there is a CCSprite class that seems to be related to what I want to do, but it is incredibly hard to figure out how to use it, mainly since I have a cocos3D scene not a cocos2D one.
You can embed a 2D Cocos2D node (including a CCSprite
) in a 3D Cocos3D scene, by using a CC3Billboard
.
CC3Billboard
is a 3D Cocos3D node that can hold a 2D Cocos2D node.
The CC3DemoMashUp
demo app in the Cocos3D distribution contains several examples of using a CC3Billboard
to embed a 2D node (even a 2D particle system) in a 3D scene.