I am new in cocos3d but i know cocos2d. i want to create 3d box dynamically. so what i did inside cc3layer is
-(void) initializeControls {
[self schedule:@selector(create_box:) interval:2 ];
}
-(void)create_box:(id)sender{
[self unschedule:@selector(mov_cel:)];
[[testWorld sharedcontescWorld] world_create_box];
}
and in cc3world class is
static testWorld *_sharedcontescWorld=nil;
+(testWorld *)sharedcontescWorld{
@synchronized([testWorld class]){
if (!_sharedcontescWorld)
[self alloc];
return _sharedcontescWorld;
}return nil;
}
+(id)alloc{
@synchronized([testWorld class]) {
_sharedcontescWorld = [super alloc];
return _sharedcontescWorld;
}return nil;
}
-(void) world_create_box{
int minx=-50;
int maxx=50;
float posx=(float)(minx+arc4random()%maxx);
CC3MeshNode* aNode;
aNode = [CC3BoxNode nodeWithName: @"Simple box"];
CC3BoundingBox bBox;
bBox.minimum = cc3v(-10.0, -10.0, -10.0);
bBox.maximum = cc3v( 10.0, 10.0, 10.0);
[aNode populateAsSolidBox: bBox];
[aNode setLocation:cc3v(posx,0,0)];
aNode.material = [CC3Material material];
[self addChild:aNode];
id move3d=[CC3MoveTo actionWithDuration:1 moveTo:cc3v(posx,0,100)];
id remove=[CCCallFuncND actionWithTarget:self selector:@selector(removeObj:)];
[aNode runAction:[CCSequence actions:move3d,remove,nil]];
}
but it doesn't work......can anyone help me?