开发者

How to avoid double window opening at launch?

开发者 https://www.devze.com 2023-03-15 04:34 出处:网络
I\'ve been porting my cocos2D iOS game to Mac and it works without problems but I don\'t understand why I get two windows open every time I launch the app.

I've been porting my cocos2D iOS game to Mac and it works without problems but I don't understand why I get two windows open every time I launch the app.

One of them is the cocos2d window with the main menu scene and the properties and name I give but there is another blank white window with the app name (I mean the Xcode project name). I suppose this is a trivial issue but I really can't avoid that window from appearing.

What am I doing wrong?

This is my AppDelegate window initialization:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification{

CCDirectorMac *director = (CCDirectorMac*) [CCDirector sharedDirector];

    //Posiciona ventana y define escalado

     NSRect aFrame=[[NSScreen mainScreen] frame];

CGSize winSize = CGSizeMake(1024,768);

CC_DIRECTOR_INIT(winSize);
[self.window showsResizeIndicator];

[director setResizeMode:kCCDirectorResize_AutoScale];
[director setProjection:kCCDirectorProjection2D];

[window_ set开发者_如何学JAVAContentAspectRatio:NSMakeSize(winSize.width,winSize.height)];
[window_ setStyleMask:[window_ styleMask] | NSResizableWindowMask | NSMiniaturizableWindowMask];
[window_ setTitle:@"Barman Hero"];

aFrame=[[NSScreen mainScreen] frame];
if (aFrame.size.width<=winSize.width || aFrame.size.height<=winSize.height) [window_ zoom:self];
[window_ center];
[glView_ setFrameSize:NSMakeSize(window_.frame.size.width,window_.frame.size.height-22)]; 

// Enable "moving" mouse event. Default no.
[window_ setAcceptsMouseMovedEvents:NO];

.....

.....

.....

//Carga escena principal
[[CCDirectorMac sharedDirector] runWithScene:[MainMenu scene]];

}

Thanks in advance.


It is likely that you have a Window defined in MainMenu.xib that is being opened semi-automatically. Remove the window from MainMenu.xib and any code that might reference it and it should no longer open the second window.

0

精彩评论

暂无评论...
验证码 换一张
取 消