Learn iOS SpriteKit with Examples, Code Snippets and Video Tutorials

Swift Basics – Part 3 – Functions

Swift Basics – Part 3 – Functions
October 15, 2014 Justin

If this video we’ll look at functions in Swift, or methods if you want to use the Objective-C lingo.  Below we have a function that accepts an Int value as a parameter, then returns a String value.

Each time the function pointsTotal is called, we pass in an amount to add to the points variable, which is used to tally up all points over time. Every time the function is called, it returns a message (for example… “The new score is 7” ). The return value is simply getting printed in the Output Window, but this could be set to the value of another variable or a text box.

Continue on to Part 4
Justin Dike is the owner and lead developer at CartoonSmart.com. He's taught hundreds of hours of game development video tutorials, covering everything from coding to art. These days he's working mostly on Swift and Sprite Kit tutorials, which often lead into highly polished iOS / tvOS Starter Kits, which require no programming at all, but are capable of making nearly any type game! Yeah, you read that write. You can also find Justin at the official CartoonSmart Podcast

0 Comments

Leave a reply

Check out our premium Swift and Sprite Kit Tutorial content!

Visit CartoonSmart.com