Brian Tracy
Brian Tracy

Reputation: 6831

Mixing Sprite Kit with Empty Application

I am currently developing an application for the iPhone with the Empty Application default. This means that the only thing created by Xcode is an AppDelegate.

The only framework imported in my .pch file is the <Foundation/Foundation.h> Framework.

This is working out for most of my application, but in some places, I would like to use SpriteKit.
Is it possible to use the SpriteKit framework in my application that uses the Empty Application default?

I'm asking this because normally, I have to specifically choose the Sprite Kit Game default when creating a new project in Xcode if I want to use SpriteKit.

The default settings. Note the difference between the Empty Application and the SpriteKit game

Upvotes: 2

Views: 899

Answers (3)

Fogmeister
Fogmeister

Reputation: 77621

Yes this is possible.

In fact, when you select anything other than Empty Application what you get is just an empty application with everything added for the default you chose.

It just saves you the job of having to add it yourself.

Upvotes: 3

dlp
dlp

Reputation: 581

Yes, it's possible

#import <SpriteKit/SpriteKit.h>

- (void)viewDidLoad
{
  [super viewDidLoad];

  SKView *skView = (SKView *)self.view;
  skView.showsFPS = YES;
  skView.showsNodeCount = YES;

  MyScene *skScene = [MyScene sceneWithSize:skView.bounds.size];
  skScene.scaleMode = SKSceneScaleModeAspectFill;

  [skView presentScene:skScene];
}

In the storyboard change the class of the window's view to SKView and it should all work.

Upvotes: 2

user2105505
user2105505

Reputation: 706

Yes, it's absolutely possible. You will just have to add the SpriteKit framework to your empty project like any other framework and do the required setup from there. Good luck!

Upvotes: 1

Related Questions