cocos3d は初めてですが、cocos2d は知っています。3D ボックスを動的に作成したい。だから私がcc3layerの中でしたことは
-(void) initializeControls {
[self schedule:@selector(create_box:) interval:2 ];
}
-(void)create_box:(id)sender{
[self unschedule:@selector(mov_cel:)];
[[testWorld sharedcontescWorld] world_create_box];
}
そしてcc3worldクラスでは
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]];
}
しかし、それは動作しません......誰かが私を助けることができますか?