Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix some classes not autocompleting in Swift, updated template with Swift Appdelegates #1351

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2fd0734
fix some classes not autocompleting in Swift, updated template
LearnCocos2D Feb 12, 2015
489baab
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
c55ac0d
fixed a typo: XCode -> Xcode
LearnCocos2D Feb 12, 2015
71eaf39
updated project creator to support new Swift AppDelegates and Mac tar…
LearnCocos2D Feb 12, 2015
1f19210
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
f552250
fix #1393 - Mac: size of window does not take into account title bar …
LearnCocos2D Mar 3, 2015
64eec30
Merge branch 'KoboldKit-develop-steffen' into develop
LearnCocos2D Mar 3, 2015
c4705e1
fix some classes not autocompleting in Swift, updated template
LearnCocos2D Feb 12, 2015
3d74f9b
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
8b82718
fixed a typo: XCode -> Xcode
LearnCocos2D Feb 12, 2015
e6e9a2d
updated project creator to support new Swift AppDelegates and Mac tar…
LearnCocos2D Feb 12, 2015
0b0663e
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
8e25f9a
fix #1393 - Mac: size of window does not take into account title bar …
LearnCocos2D Mar 3, 2015
448428b
Merge branch 'refs/heads/develop' into develop-steffen
LearnCocos2D Mar 3, 2015
76d7cbb
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
ca0a6f1
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
91025e5
fix main trying to launch "AppController" instead of "AppDelegate"
LearnCocos2D Mar 4, 2015
257137d
update copyrights of appdelegate files
LearnCocos2D Mar 4, 2015
88900d5
fix some classes not autocompleting in Swift, updated template
LearnCocos2D Feb 12, 2015
831cbae
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
4c22ec8
fixed a typo: XCode -> Xcode
LearnCocos2D Feb 12, 2015
c8e637e
updated project creator to support new Swift AppDelegates and Mac tar…
LearnCocos2D Feb 12, 2015
a630c71
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
b46a414
fix #1393 - Mac: size of window does not take into account title bar …
LearnCocos2D Mar 3, 2015
54e67b4
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
4b02356
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
e09f951
fixed template project's "Source" group not pointing to the Source fo…
LearnCocos2D Feb 12, 2015
c98cf31
added Swift AppDelegate files to SB project template
LearnCocos2D Feb 12, 2015
2990051
fix main trying to launch "AppController" instead of "AppDelegate"
LearnCocos2D Mar 4, 2015
0606adc
update copyrights of appdelegate files
LearnCocos2D Mar 4, 2015
9cfbed5
Merge remote-tracking branch 'fork-koboldkit/develop-steffen' into de…
LearnCocos2D Mar 4, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added Swift AppDelegate files to SB project template
  • Loading branch information
LearnCocos2D committed Mar 3, 2015
commit 0b0663e169182ce9849127ceb72036e3c24e3fa7

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -10,28 +10,28 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
CCDirectorMac *director = (CCDirectorMac*) [CCDirector sharedDirector];
CCDirectorMac *director = (CCDirectorMac*)[CCDirector sharedDirector];

// enable FPS and SPF
// [director setDisplayStats:YES];
// director.displayStats = YES;

// Set a default window size
CGSize defaultWindowSize = CGSizeMake(480.0f, 320.0f);
[self.window setFrame:CGRectMake(0.0f, 0.0f, defaultWindowSize.width, defaultWindowSize.height) display:true animate:false];
[self.glView setFrame:self.window.frame];
CGSize defaultSize = CGSizeMake(480.0f, 320.0f);
[_window setFrame:CGRectMake(0.0f, 0.0f, defaultSize.width, defaultSize.height) display:true animate:false];
_glView.frame = _window.frame;

// connect the OpenGL view with the director
[director setView:self.glView];
director.view = _glView;

// 'Effects' don't work correctly when autoscale is turned on.
// Use kCCDirectorResize_NoScale if you don't want auto-scaling.
//[director setResizeMode:kCCDirectorResize_NoScale];
//director.resizeMode = kCCDirectorResize_NoScale;

// Enable "moving" mouse event. Default no.
[self.window setAcceptsMouseMovedEvents:NO];
_window.acceptsMouseMovedEvents = NO;

// Center main window
[self.window center];
[_window center];

// Configure CCFileUtils to work with SpriteBuilder
[CCBReader configureCCFileUtils];
@@ -41,9 +41,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[director runWithScene:[CCBReader loadAsScene:@"MainScene"]];
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
return YES;
}

- (void)applicationWillTerminate:(NSNotification *)aNotification
{
[[CCPackageManager sharedManager] savePackages];
[[CCDirector sharedDirector] stopAnimation]; // required to fix stream of GL errors on shutdown
}

@end
Original file line number Diff line number Diff line change
@@ -7,3 +7,52 @@
//

import Foundation
import Cocoa

@NSApplicationMain
class AppDelegate : NSObject, NSApplicationDelegate
{
@IBOutlet weak var window : NSWindow!
@IBOutlet weak var glView : CCGLView!

func applicationDidFinishLaunching(aNotification: NSNotification) {
var director : CCDirectorMac = CCDirector.sharedDirector() as CCDirectorMac

// enable FPS and SPF
//director.displayStats = true

// Set a default window size
var defaultSize = CGSize(width: 480.0, height: 320.0)
window.setFrame(CGRect(x: 0.0, y: 0.0, width: defaultSize.width, height: defaultSize.height), display: true, animate: false)
glView.frame = window.frame

// connect the OpenGL view with the director
director.view = glView

// 'Effects' don't work correctly when autoscale is turned on.
// Use kCCDirectorResize_NoScale if you don't want auto-scaling.
//director.resizeMode = kCCDirectorResize_NoScale

// Enable "moving" mouse event. Default no.
window.acceptsMouseMovedEvents = false

// Center main window
window.center()

// Configure CCFileUtils to work with SpriteBuilder
CCBReader.configureCCFileUtils()

CCPackageManager.sharedManager().loadPackages()

director.runWithScene(CCBReader.loadAsScene("MainScene"))
}

func applicationShouldTerminateAfterLastWindowClosed(theApplication: NSApplication) -> Bool {
return true;
}

func applicationWillTerminate(aNotification: NSNotification) {
CCPackageManager.sharedManager().savePackages()
CCDirector.sharedDirector().stopAnimation() // required to fix stream of GL errors on shutdown
}
}
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
#import <UIKit/UIKit.h>
#import "cocos2d.h"

@interface AppController : CCAppDelegate
@interface AppDelegate : CCAppDelegate
{
}

Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
#import "AppDelegate.h"
#import "CCBuilderReader.h"

@implementation AppController
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
Original file line number Diff line number Diff line change
@@ -1,9 +1,73 @@
//
// AppDelegate.swift
// PROJECTNAME
//
// Created by Steffen Itterheim on 12/02/15.
// Copyright (c) 2015 Apportable. All rights reserved.
//
/*
* SpriteBuilder: http://www.spritebuilder.org
*
* Copyright (c) 2012 Zynga Inc.
* Copyright (c) 2013 Apportable Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

import Foundation

@UIApplicationMain
class AppDelegate : CCAppDelegate
{
override func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Configure Cocos2d with the options set in SpriteBuilder

// TODO: add support for Published-Android support
var configPath = NSBundle.mainBundle().resourcePath!
configPath = configPath.stringByAppendingPathComponent("Published-iOS")
configPath = configPath.stringByAppendingPathComponent("configCocos2d.plist")

let cocos2dSetup = NSMutableDictionary(contentsOfFile: configPath)

// Note: this needs to happen before configureCCFileUtils is called, because we need apportable to correctly setup the screen scale factor.
#if APPORTABLE
if cocos2dSetup[CCSetupScreenMode] == CCScreenModeFixed {
UIScreen.mainScreen().currentMode() = UIScreenMode.emulatedMode(UIScreenAspectFitEmulationMode)
}
else {
UIScreen.mainScreen().currentMode() = UIScreenMode.emulatedMode(UIScreenScaledAspectFitEmulationMode)
}
#endif

// Configure CCFileUtils to work with SpriteBuilder
CCBReader.configureCCFileUtils()

// Do any extra configuration of Cocos2d here (the example line changes the pixel format for faster rendering, but with less colors)
//cocos2dSetup[CCConfigPixelFormat] = kEAGLColorFormatRGB565

setupCocos2dWithOptions(cocos2dSetup)

return true
}

override func startScene() -> CCScene {
return CCBReader.loadAsScene("MainScene")
}

// example override of UIApplicationDelegate method - be sure to call super!
override func applicationWillResignActive(application : UIApplication) {
// let CCAppDelegate handle default behavior
super.applicationWillResignActive(application)

// add your code here...
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -11,7 +11,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="CCGLView"/>
<customObject id="h1c-Bs-cXs" customClass="AppDelegate">
<customObject id="h1c-Bs-cXs" customClass="AppDelegate" customModule="PROJECTNAME" customModuleProvider="target">
<connections>
<outlet property="glView" destination="TdD-9J-RVA" id="ucZ-1b-znr"/>
<outlet property="window" destination="WbL-ZP-sg3" id="srr-UU-Jc1"/>
@@ -670,7 +670,7 @@
<window title="PROJECTNAME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" animationBehavior="default" id="WbL-ZP-sg3">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="109" y="132" width="480" height="320"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="1Kl-CE-vX6">
<rect key="frame" x="0.0" y="0.0" width="480" height="320"/>
<autoresizingMask key="autoresizingMask"/>