Learn to code by building apps. This is the ultimate iOS 11 course.

Want to make apps and learn to code? iOS 11 has so much to offer, there’s something for everyone to create.

Mammoth Interactive has just released a course on iOS 11 (including Xcode 9, Swift 4.0, ARKit, Core ML, SpriteKit, and WatchKit)!

NOW $19 WITH THIS COUPON

With our iOS 11 course, you can express your creativity by making your own apps and games. You can train your mind to think in a new way as you learn to code. You can take your first step to being a developer, or expand from your current programming skills. Ready to get started?

First you learn the basics of Apple’s programming language, Swift 4.0. Follow along with us to learn how to use variables, functions, classes, and more. Then you start coding an actual calculator app from start to finish. We also show you how to use Photoshop for User Interface (UI) design.

Then we show you how to build games for the iPhone using SpriteKit. We want you to be a well-rounded developer. For this reason, we show you how to make the code AND the art for projects from scratch.

Augmented reality is big in the news, as the capabilities of Apple’s ARKit seem to grow every day, whether you want to make an alternate dimension portal for your game or make an app that measures the length of your wall. Our course has a section to introduce you to navigating ARKit.

If you want to increase your portfolio as a developer, making Apple Watch apps is a great way to do so. In our chapters on WatchKit, you learn how to make interactive Apple Watch apps.

We prioritize learning by doing. We teach theory while writing real code and make fully working apps. We’ve also added coding exercises to the end of this course so that you can put your skills to the test.

The best way for you to learn how to make your own app is to follow project-based training content. By taking our course, you get practical, employable skills immediately. You can put the apps you make in this course in your portfolio!

We at Mammoth Interactive value input from students like you. Please feel free to leave your feedback or questions in our FORUM. We are always happy to help.

Come learn iOS 11 with your teachers from Mammoth Interactive.

$19 with promo code “ULTIMATEIOS11”

You’re invited! Come to our SpriteKit webinar.

Do you want to make 2D games for Apple products? Join master programmer Nimish Narang for a 1-hour webinar on how to navigate the SpriteKit framework. Register here for just 10 dollars.

Why SpriteKit?

SpriteKit is THE framework for making 2D games for Apple products. It’s free! You can make cool games, from super simple to more complex, in SpriteKit. SpriteKit provides support for cool special effects and physics. It’s a fun interface to express your creativity. Before you know it, you could see a game you built in SpriteKit in the App Store!

Here’s what we’ll do:

– Learn the basics of scenes, nodes, actions, and physics bodies in Xcode’s game engine
– Put all the concepts together to make the simple version of a classic game for iOS

But wait, there’s MORE! If you enroll in this webinar, you’ll get 2 FREE courses from Mammoth Interactive. First, you’ll get our NEW Introduction to SpriteKit course, where you learn how to build 3 games in SpriteKit. Second, you’ll get our 77-hour course on how to build virtual reality games with Blender and Unity3D!

Have fun, and learn something new. Reserve your spot today for just 10 dollars.

Another new course: Introduction to SpriteKit. Build practical games.

Anyone can use SpriteKit. 

In our BRAND-NEW course, you learn how to make simple 2D games using Apple’s SpriteKit. Now 96% off!

You build the following games: Breakout Clone, Pong Clone, and Space Invaders​. This course is unique because we make ​both the code and the design for the games from scratch.

Other tutorials only show you how to make the functionality or design of a game. We at Mammoth Interactive show you how to do both.

Why SpriteKit?

SpriteKit is the framework for making 2D games for Apple products. It’s ​free! You can make cool games, from super simple to more complex, in SpriteKit. SpriteKit provides support for cool special effects and physics. It’s a ​fun interface to express your creativity. Before you know it, you could see a game you built in SpriteKit in the App Store!

To give a game functionality, you add code to your game’s objects in Xcode. Xcode is a user-friendly programming language that is easy to understand. ​

Don’t worry if you’ve never coded before. We ​start simple and add more to the game as the course goes on. This course begins with an introduction to SpriteKit for those who have never used it before. You will learn how to navigate SpriteKit’s interface.

Is this course for me?

Even if you’re not an artist, you can design basic games. You may have heard of Axiom Verge and Stardew Valley. These games are million-dollar successes. But did you know that only one person made each?

Usually it takes a whole team of people to build a game. But creators Thomas Happ and Eric Barone developed and designed their games by themselves. Now they’re millionaires. You can do it, too.

By taking our SpriteKit course, you will gain the tools you need continue improving yourself in the field of game development. You will be able to apply what you learned to further experiment in SpriteKit or another game development framework.

Get started today!​

Touches and Moving Sprites in XCode SpriteKit: Swift Crash Course (Free Tutorial)

If you’re designing a game, you probably need your players to move around. In this article, we’ll look at the different ways of doing so in SpriteKit. Want more FREE coding lessons? You’re in luck! We have a free 30-minute beginners course: training.mammothinteractive.com/p/learn-to-code-in-30-minutes

To start a new project, go to File > New > Project. The template we’re using today is the iOS application, which is for the iPhone and iPad. Go to iOS > Application > Game. For Device, specify iPhone. Let’s make our Product Name “Getting started with SpriteKit”. Push Next and then Create. An iPhone app set-up will appear on your screen.

In the left sidebar, open “GameScene.swift”. Delete any excess code until you’re left with this:

import SpriteKit

class GameScene: SKScene {
override func didMoveToView(view: SKView) {

}

override func touchesBegan(touches: Set, withEvent event: UIEvent?) {
/* Called when a touch begins */

for touch in touches {

}
}

override func update(curent Time: CFTimeInterval) {
/*Called before each frame is rendered */
}
}

Let’s create a sprite! On a line below import SpriteKit, declare the variable player, and make it equal to SKSpriteNode. You can use the keyword var and the following format:

var player = SKSpriteNode?()

Next, above the line override func update(currentTime: CFTimeInterval) {, create a new function named spawnPlayer.

func spawnPlayer(){

}

To give our sprite a color and a size, we also need to add the following line within that function:

player = SKSpriteNode(color: UIColor, size: CGSize)

To set the color of the sprite, below var player = SKSpriteNode?(), declare the variable playerColor. We can give it an orange color by typing the following:

var playerColor = UIColor.orangeColor()

Below that, we can also set the background color of our display by declaring the variable backgroundColorCustom and setting it equal to UIColor. For the background to be dark grey, set its Red, Green, and Blue (RGB) values to 0.2 like so:

var backgroundColorCustom = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1.0)

Note that Alpha refers to transparency. Likewise, we can specify that the size of our sprite is, for instance, 50 by 50 pixels by declaring another variable:

var playerSize = CGSize(width: 50, height: 50)

Now, back within the spawnPlayer function, we must replace UIColor with playerColor, and CGSize with playerSize.

Thus our sprite has a color and dimensions. Why don’t we also give it a position? On a new line within the same function, write:

mySprite?.position

As you can see whilst typing “position”, it is a CGPoint. For this reason, we have to set the sprite’s position equal to CGPoint. Furthermore, we can set our sprite’s position inside parentheses after CGPoint. For instance, for our sprite to be positioned in the center of the screen, add onto the existing line so it looks like so:

mySprite?.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY
(self.frame))

If, after y: CGRectGetMidY(self.frame), you add + 200, the sprite will be positioned slightly above the center point of the screen. Remember that X refers to the horizontal axis and Y refers to the vertical axis.

But we’re not done yet! We need one more line in our function:

self.addChild(player!)

Within the override function didMoveToView, we need to reference the background color variable we created:

self.backgroundColor = backgroundColorCustom

Also, we must add a line saying spawnPlayer().

Run the simulator, and you will see an orange square appear on the display. We’ve successfully created a sprite! Next we will add code so that the square on the display moves whenever we drag and pull it with our cursor. To achieve this, first delete the override function touchesBegan.

Instead, we will have a new one called touchesMoved. In the place of the old override function, insert:

override func touchesMoved(touches: Set, withEvent event: UIEvent?) {
for touch in touches{

}
}

Also, within the curly brackets after for touch in touches, type:

let touchLocation = touch.locationInNode(self)

player?.position.x

This will allow us to add in a touch location. As you can see in the tab that pops up when you type it, touch.locationInNode is a CGPoint. This means that we can delete the let before touchLocation = touch.locationInNode(self). This allows us to create a global variable, which we can use throughout the program. We just need to create another variable where we created our other variables, such as on a line beneath var playerSize = CGSize(width: 50, height: 50). Name the new variable touchLocation.

var touchLocation = CGPoint?()

We can now set up our code so that our touch on the screen changes the position of our sprite. In the touchesMoved function, make player?.position.x equal to (touchLocation?.x)!. As well, add the line:

player?.position.y = (touchLocation?.y)!

If you run the simulator, you will be able to move the square around by clicking on it and dragging it. touchesMoved allows you to do this. On the other hand, if you don’t want to drag it and want to have it move to where you touch the display, you can use touchesBegan. Above the touchesMoved function, type override func touchesBegan, and push Enter. XCode will auto-complete the following:

override func touchesBegan(touches: Set, withEvent event: UIEvent?) {
code
}

Now cut the following code from the touchesMoved function:

for touch in touches{
touchLocation = touch.locationInNode(self)

player?.position.x = (touchLocation?.x)!
player?.position.y = (touchLocation?.y)!
}

Replace code in the touchesBegan function with that text. Likewise, you can follow the same steps to create the function touchesEnded. When you click on the display and drag your cursor, the square will move to wherever you let go of the cursor.

 

For our next example, let’s mimic a spaceship shooter game. First off, go back to having only the function touchesMoved. Also, in the spawnPlayer function, change + 200 to - 500.

Let’s say, like in a game of this kind, we want our spaceship to be able to move left and right but not up and down. We can achieve this by simply deleting this line from the touchesMoved function:

player?.position.y = (touchLocation?.y)!

When you make big games, moveThePlayer could have 20 lines of code in it. You don’t always want to put things into your override function. They’re there to set up the functionality. They’re not meant to carry all the programming weight. Instead, since we set touchLocation as a global variable, we can call a new function in order to move our sprite. Below the touchesBegan function, you can create the new function moveThePlayer:

func moveThePlayer(){

}

As well, cut the following line from touchesMoved, and paste it into your new function:

player?.position.x = (touchLocation?.x)!

Run the simulator. You will see the sprite moving left and right when you click and drag your cursor.

There you have it! Not only can you now spawn a new player, you know how to use touchesMoved, touchesBegan, and touchesEnded to make your players move like you want them to. To keep learning how to code for FREE, check out our 30-minute introductory course here: training.mammothinteractive.com/p/learn-to-code-in-30-minutes

Changing Background Color in XCode SpriteKit: Swift Crash Course (Free Tutorial)

Designing an application? One of the first things you need to think about is a color scheme, which includes the background color of your app. Today we’re looking at how to set the color of the display (background color) of an iPhone or iPad app. Want more FREE coding lessons? We have a free 30-minute beginners course: training.mammothinteractive.com/p/learn-to-code-in-30-minutes

To start a new project, go to File > New > Project. Select iOS > Application > Game. For Device, specify iPhone. Let’s make our Product Name “Getting started with SpriteKit”. Push Next and then Create. An iPhone app set-up will appear on your screen.

In the left sidebar, open “GameScene.swift”. Delete any extra code until your screen looks like this:

import SpriteKit

class GameScene: SKScene {
override func didMoveToView(view: SKView) {

}

override func touchesBegan(touches: Set, withEvent event: UIEvent?) {
/* Called when a touch begins */

for touch in touches {

}
}

override func update(curent Time: CFTimeInterval) {
/*Called before each frame is rendered */
}
}

On a line underneath import SpriteKit, declare a variable using the keyword var. I like to call this variable backgroundColorCustom because backgroundColor too closely resembles a reserved word. Swift needs reserved words, such as class, SKScene, and override, in order to run code.

var backgroundColorCustom

To give our background a custom color, add onto that line until it looks like this:

var backgroundColorCustom = UIColor(red: CGFloat, green: CGFloat, blue: CGFloat,
alpha: CGFloat)

We are now able to set the Red, Green, and Blue (RGB) values for our color, as well as the alpha (transparency). Let’s say we want a dark gray. Replace the CGFloat after red, green, and blue with 0.2. Likewise, give alpha a value of 1.0.

var backgroundColorCustom = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1.0)

If you prefer to use one of Swift’s default colors, such as orange, you can make your variable equal to UIColor.orangeColor(). Regardless, within the override function didMoveToView, we must reference our new variable:

self.backgroundColor = backgroundColorCustom

Run the simulator to see an iPhone display with a dark gray background. If you zoom in, you will notice that the bottom right-hand corner of the display gives you some values: nodes and fps. What are they?

Let’s find out. Exit out of the display, and open a sidebar listing your SpriteKit files. Then open GameViewController.swift, which controls which scene gets shown on an application. Therefore, if you want to change the scene, you need to edit this file.

As you may be able to tell, the reason our display showed the node count and frames per second (FPS) is because there are the following lines in the GameViewController.swift file:

skView.showsFPS = true
skView.showsNodeCount = true

To not show these values, simply add // in front of each of the lines to turn them into comments, which aren’t read by the compiler.

That is how to set the background color in XCode SpriteKit with Swift. To keep learning how to code for FREE, check out our 30-minute introductory course here: training.mammothinteractive.com/p/learn-to-code-in-30-minutes