Reputation: 2491
Hi guys!
Currently discovering cocos2d framework.
Now I'm trying to use UIKit stuff in cocos2d project.
What I'm doing: I've added the methods:
-(void)activityIndicatorRun {
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.color = [UIColor orangeColor];
spinner.hidesWhenStopped = YES;
[spinner startAnimating];
[self scheduleOnce:@selector(activityIndicatorStop) delay:5.0f];
}
AND
-(void)activityIndicatorStop {
[spinner stopAnimating];
}
After I added this like of code to my init method:
[self scheduleOnce:@selector(activityIndicatorRun) delay:54];
I think that I need to add a subview to my view. But I'm not sure about how you can do this, and where.
Question: Can anyone help me?
Thanks in advance!
Upvotes: 2
Views: 1990
Reputation: 42153
You can add UIKit components as subview of your underlying OpenGL ES view in your cocos2d app.
For cocos2d-iphone 0.99/1.0:
[[[CCDirector sharedDirector] openGLView] addSubview:spinner];
For 2.x:
// CCDirector is subclass of UIViewController in 2.x on iOS
[[[CCDirector sharedDirector] view] addSubview:spinner];
Upvotes: 5