Hi, I have created a "normal" app - initially without cocos2d. Now I need cocos2d in this app. So I added all the frameworks that are included when creating a cocos2d app and just copied the cocos2d group from another project by dragging it to my project.
For the init for cocos2d I get the application's window in an ivar of the ViewController which runs the init.
@interface MyViewController : UIViewController <UINavigationControllerDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
- (void) setupMyVC;
@end
@implementation MyViewController
@synthesize window;
-(void) viewDidLoad {
[self setupMyVC];
}
- (void) setupMyVC
{
//get the mainWindow for the CC_DIRECTOR_INIT()
MyAppDelegate *mainDelegate = (MyAppDelegate *)[[UIApplication sharedApplication]delegate];
self.window = mainDelegate.mainWindow;
// CC_DIRECTOR_INIT()
//
// 1. Initializes an EAGLView with 0-bit depth format, and RGB565 render buffer
// 2. EAGLView multiple touches: disabled
// 3. creates a UIWindow, and assign it to the "window" var (it must already be declared)
// 4. Parents EAGLView to the newly created window
// 5. Creates Display Link Director
// 5a. If it fails, it will use an NSTimer director
// 6. It will try to run at 60 FPS
// 7. Display FPS: NO
// 8. Device orientation: Portrait
// 9. Connects the director to the EAGLView
//
CC_DIRECTOR_INIT();
// Obtain the shared director in order to...
CCDirector *director = [CCDirector sharedDirector];
// Sets landscape mode
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
// Turn on display FPS
[director setDisplayFPS:YES];
// Turn on multiple touches
EAGLView *view = [director openGLView];
[view setMultipleTouchEnabled:YES];
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
[[CCDirector sharedDirector] runWithScene: [RecScene scene]];
}
@end
The code works - EXCEPT THAT I GET A WHITE RECTANGLE in the lower left corner (about 5 x 20 large). This rectangle is on top of every sprite I add.
Is that OK, just to drag the cocos2d Group into my app + adding the required frameworks to integrate cocos2d?
Is there something missing?
Or where does the rectangle come from?
Tanks so much for your help!