diff --git a/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/AppDelegate.swift b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/AppDelegate.swift new file mode 100644 index 0000000..e5a2b63 --- /dev/null +++ b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/AppDelegate.swift @@ -0,0 +1,16 @@ +import UIKit +import ImagineEngine + +@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + let scene = ___PACKAGENAME___Scene(size: UIScreen.main.bounds.size) + + let window = GameWindow(scene: scene) + window.makeKeyAndVisible() + self.window = window + + return true + } +} diff --git a/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/Podfile b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/Podfile new file mode 100644 index 0000000..dac59d7 --- /dev/null +++ b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/Podfile @@ -0,0 +1,7 @@ +platform :tvos, '10.0' + +target '___PACKAGENAME___' do + use_frameworks! + pod 'ImagineEngine' +end + diff --git a/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateIcon.png b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateIcon.png new file mode 100644 index 0000000..3e7abca Binary files /dev/null and b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateIcon.png differ diff --git a/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateIcon@2x.png b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateIcon@2x.png new file mode 100644 index 0000000..3e25d72 Binary files /dev/null and b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateIcon@2x.png differ diff --git a/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateInfo.plist b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateInfo.plist new file mode 100644 index 0000000..3c0a7ee --- /dev/null +++ b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/TemplateInfo.plist @@ -0,0 +1,54 @@ + + + + + Kind + Xcode.Xcode3.ProjectTemplateUnitKind + Identifier + com.ImagineEngine.Templates.tvOS + Ancestors + + com.apple.dt.unit.tvosApplicationBase + + Concrete + + Description + This template provides a starting point for an tvOS game powered by Imagine Engine. + Options + + + Identifier + languageChoice + Units + + Swift + + Nodes + + ___PACKAGENAME___Scene.swift + ../Podfile + + + + + + Definitions + + AppDelegate.swift + + Path + AppDelegate.swift + + ___PACKAGENAME___Scene.swift + + Path + ___PACKAGENAME___Scene.swift + + ../Podfile + + Path + Podfile + + + + diff --git a/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/___PACKAGENAME___Scene.swift b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/___PACKAGENAME___Scene.swift new file mode 100644 index 0000000..60a3a11 --- /dev/null +++ b/XcodeTemplates/Imagine Engine/tvOS Game.xctemplate/___PACKAGENAME___Scene.swift @@ -0,0 +1,42 @@ +import ImagineEngine + +// A scene acts as a container for your game objects, much like a view controller +// in a tvOS app. You can move between different scene's in a game, so you can +// split your game's menus & levels up into multiple scenes. +final class ___PACKAGENAME___Scene: Scene { + override func setup() { + // Actors are the core objects of any game, they represent all movable & + // scriptable objects - like players, enemies & collectables. + let actor = Actor() + actor.backgroundColor = .red + actor.size = Size(width: 100, height: 100) + actor.position = center + add(actor) + + // Actions enable you to move, rotate & scale your game objects over + // time. You can also define your own actions using the `Action` class + actor.repeat(RotateAction(delta: .pi * 2, duration: 2)) + + // Labels let you easily add text to your game's scenes + let label = Label(text: "Hello Imagine Engine!") + label.font = .boldSystemFont(ofSize: 20) + label.position = center + add(label) + + // Events let you script your game by reacting to things like user input + // or when two objects collided. Each game object has an `events` property + // where you can find all observable events for that object. + events.clicked.addObserver(actor) { actor in + func randomColorValue() -> Metric { + return Metric(arc4random_uniform(101)) / 100 + } + + actor.backgroundColor = Color( + red: randomColorValue(), + green: randomColorValue(), + blue: randomColorValue(), + alpha: 1 + ) + } + } +} diff --git a/XcodeTemplates/README.md b/XcodeTemplates/README.md index bc3c1fd..c279873 100644 --- a/XcodeTemplates/README.md +++ b/XcodeTemplates/README.md @@ -20,6 +20,7 @@ Done! 👌 - Open Xcode and select `New > Project...`. - Under the "iOS" tab, scroll down to the "Imagine Engine" section and select "iOS Game". + - _For tvOS; Select the "tvOS" tab, scroll down to the "Imagine Engine" section and select "tvOS Game"_ - Enter a name for your game and make sure to select "Swift" as language. - Xcode will now create a project for you. Close the project and go to the project's folder on the command line. - Run `pod install`. This will install Imagine Engine through [CocoaPods](https://cocoapods.org).