Showing posts with label SpriteKit. Show all posts
Showing posts with label SpriteKit. Show all posts

Friday, November 20, 2015

Quick Tip: Endless scrolling with SpriteKit and SWIFT (Part 2 of 2)

Natural endless scrolling with easing

Welcome to my tutorial series about scrolling:
  • Part 1: Endless scrolling with background tiles
  • Part 2: Natural endless scrolling with easing


In part one I showed how to implement endless scrolling. This is working fine, but there is still room for improvements. The scrolling starts immediately with full speed and also stops directly after the touch ends. A more natural movement would be to increase and decrease the speed slowly, till the target speed is reached or the movement is stopped. These is also known as ease in or ease out animation.
Thank you to hamobi who helped me with my Stackoverflow question for finding the right solution.

To give you an impression compare the two videos:

Without Easing:




With Easing:





Thursday, November 12, 2015

Quick Tip: Endless scrolling with SpriteKit and SWIFT (Part 1 of 2)

Endless scrolling with background tiles

Welcome to my new tutorial series about scrolling:
  • Part 1: Endless scrolling with background tiles
  • Part 2: Natural endless scrolling with easing

This video gives an impression what I'll show today:




1. About the algorithm and the background tiles


Creating the image tiles for the scrolling parts of the background:


First we need a background image:


Let's mirror this image and add the new one at the right side:


Thursday, October 1, 2015

Quick Tip: How to use the Apple TV remote to control a sprite in your TVOS Apps

How to use the Apple TV remote to control a sprite in your TVOS Apps

Since my Apple TV Developer kit arrived one week ago I had plenty of time to try certain things. I will blog about some of my prototypes in the next days.





Today I'll will focus again on the remote control. It provides, especially in combination with SpriteKit, a simple and very natural way to control a sprite on the screen. For a natural sprite movement the approach of my todays post is much better, the my article about gesture recognition on the AppleTV. 

Let's start...

1. Download the XCode 7.1 Beta from the Apple Developer Portal:




2. Create a new project:





Thursday, September 10, 2015

Quick Tip: How to use the remote control in your TVOS Apps for Apple TV in SWIFT

How to use the remote control in your tvOS Apps for Apple TV in SWIFT

There are already dozens of 'Hello world' tutorials published for the new Apple tvOS, so let's do something different. I'll show how to use the remote control to move a sprite on Apple TV. It was surprisingly easy and took me only 10 minutes to implement:

1. Download the XCode 7.1 Beta from the Apple Developer Portal:




2. Create a new project:




Monday, February 9, 2015

How to implement a space shooter with SpriteKit and SWIFT - Part 7: iAd integration

Adding iAd integration




Welcome to part 7 of my swift programming tutorial. In the previous parts we've created sprites, added movement, enemies with a follow behaviour, bullets & shooting, a HUD, collision detection, sound & particle effects and a global leaderboard using Game Center. Today I'll show how to integrate the Apple Advertising Framework iAD:
  • Enable iAd in iTunesConnect
  • Add a Banner Ad (at the bottom of the screen)
  • Add a Fullscreen Ad (after game over)

Wednesday, January 14, 2015

How to implement a space shooter with SpriteKit and SWIFT - Part 6: Game Center integration

Adding Game Center integration




Welcome to part 6 of my swift programming tutorial. In the previous parts we've created sprites, added movement, created enemies which follow our sprite, added bullets, a HUD, collision detection, sound and particle effects. Today I'll show how to integrate Game Center to add a global leaderboard.


The most complex part is doing configuration stuff in iTunes Connect. 3 from 4 steps of this tutorial are related to that. You need a paid Apple Developer Account to execute the next steps:

  • Upload our App to iTunes Connect  
  • Create a Leaderboard in iTunes Connect 
  • Create a Sandbox Test User in iTunes Connect
  • Coding 

Wednesday, December 17, 2014

How to implement a space shooter with SpriteKit and SWIFT - Part 5: Particles and Sound

Adding particles and sound 




Welcome to part 5 of my tutorial series. In the previous parts we've created a sprite, added movement, created enemies which follow our sprite, added bullets, a HUD, collision detection, .... 
But, for a real game some important elements are missing to beautify the game:
  • Sound effects: explosions, game over, ...
  • Particle effects: explosions, background star field 

I'll show how to implement this today. As a starting point you can download the code from tutorial part 4 here

Thursday, November 27, 2014

How to implement a space shooter with SpriteKit and SWIFT - Part 4: Collision Detection

Adding basic game logic and collision detection





Welcome to part 4 of my tutorial series. In the previous parts we've created a sprite, added movement, created enemies which follow our sprite, added bullets and a HUD. But, for a real game some essential parts are missing:

  • Collision detection between the bullets and our sprite
  • Basic game logic
    • Scoring
    • Pause
    • Life Lost & Game Over

I'll show how to implement this today. As a starting point you can download the code from tutorial part 3 here


Wednesday, November 19, 2014

How to implement a space shooter with SpriteKit and SWIFT - Part 3: Create a HUD

Adding a HUD with SpriteKit and SWIFT





Tutorial Overview:


  • Part 1: Initial project setup, sprite creation and movement using SKAction and SKConstraint
  • Part 2: Adding enemies, bullets and shooting with SKAction and SKConstraint
  • Part 3: Adding a HUD with SKLabelNode and SKSpriteNode
  • Part 4: Adding basic game logic and collision detection
  • Part 5: Adding particles and sound 
  • Part 6: GameCenter integration

Add the HUD:

I'll add a simple HUD which shows the score, the remaining lifes and a pause button. As a starting point you can download the code from tutorial part 2 here

First of all let's fix a bug in the sample code of my last post. Open GameViewController.swift and move the code from viewDidLoad to viewDidAppear. This is necessary because the orientation change to landscape might not be completed. In this case width and height are inverted, if we determine them in viewDidLoad:

Tuesday, November 11, 2014

How to implement a space shooter with SpriteKit and SWIFT - Part 2

Adding enemies, bullets and shooting with SKAction and SKConstraint





Tutorial Overview:

  • Part 1: Initial project setup, sprite creation and movement using SKAction and SKConstraint
  • Part 2: Adding enemies, bullets and shooting with SKAction and SKConstraint
  • Part 3Adding a HUD with SKLabelNode and SKSpriteNode
  • Part 4Adding basic game logic and collision detection
  • Part 5: Adding particles and sound 
  • Part 6: GameCenter integration


Add the enemies:

I'll add several enemy sprites. These will automatically follow and orient to the hero sprite.  You can download the code from Part 1 here.



Wednesday, November 5, 2014

How to implement a space shooter with SpriteKit and SWIFT - Part 1

Initial project setup, sprite creation and movement using SKAction and SKConstraint






Tutorial Overview:

  • Part 1: Initial project setup, sprite creation and movement using SKAction and SKConstraint
  • Part 2: Adding enemies, bullets and shooting with SKAction and SKConstraint
  • Part 3: Adding a HUD with SKLabelNode and SKSpriteNode
  • Part 4: Adding basic game logic and collision detection
  • Part 5: Adding particles and sound 
  • Part 6: GameCenter integration


1. Create a new universal project (template: game; language: Swift)




Tuesday, October 21, 2014

Writing games is more fun than writing a blog post: New teaser video for my upcoming tutorial

Sorry, I love writing blog posts, but this time I have written a small game instead of completing my tutorial. Here's another short teaser video:




That's all for today. The complete code will be available at GitHub soon.

Cheers,
Stefan

Wednesday, October 8, 2014

Kick off for my new Tutorial: How to implement a space shooter with SpriteKit and SWIFT

I'm preparing a new tutorial: 

My goal is to implement a complete space shooter with SpriteKit and SWIFT.

Planned content is:

  • Part 1: Initial project setup, sprite creation and movement using SKAction and SKConstraint
  • Part 2: Adding enemies, bullets and shooting with SKAction and SKConstraint
  • Part 3: Adding a HUD with SKLabelNode and SKSpriteNode
  • Part 4: Adding basic game logic and collision detection
  • Part 5: Adding particles and sound 
  • Part 6: GameCenter integration

Here's a short teaser video:


The sample code will be available on GitHub



That's all for today.

Cheers,
Stefan