Getting Started with SpriteKit by Jorge Jordan
Author:Jorge Jordan [Jordan, Jorge]
Language: eng
Format: azw3, epub
Publisher: Packt Publishing
Published: 2016-01-25T05:00:00+00:00
Furthermore, let's declare some variables that will be useful for the development of the parallax effect. Add the following lines just after private var isEnemyCollisionDetected: Bool = false:
private var backgroundBottom: SKSpriteNode! private var backgroundTop: SKSpriteNode! private var treesBottom: SKSpriteNode! private var treesTop: SKSpriteNode!
To initialize these variables, we are going to call a new method. Add the following line at the end of didMoveToView:
self.initializeParallaxEffect()
Implement this with the following lines of code:
func initializeParallaxEffect() { // Initialize background layers backgroundBottom = SKSpriteNode(imageNamed: "background") backgroundBottom.anchorPoint = .zero backgroundBottom.zPosition = -1 // Copy the previous node into another backgroundTop = backgroundBottom.copy() as! SKSpriteNode // Set top layer position backgroundTop.position = CGPoint(x: backgroundBottom.position.x, y: backgroundBottom.position.y + backgroundBottom.size.height) // Initialize tree layers treesBottom = SKSpriteNode(imageNamed: "trees") treesBottom.zPosition = 4 treesBottom.position = CGPoint(x:(view!.bounds.size.width/2), y: view!.bounds.size.height/2) // Copy the previous node into another treesTop = treesBottom.copy() as! SKSpriteNode // Set top layer position treesTop.position = CGPoint(x: treesBottom.position.x, y: treesBottom.position.y + treesBottom.size.height) // Add background layers to the scene addChild(backgroundBottom) addChild(backgroundTop) // Add tree layers to the scene addChild(treesBottom) addChild(treesTop) }
Download
Getting Started with SpriteKit by Jorge Jordan.epub
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Filmora Efficient Editing by Alexander Zacharias(5767)
The Infinite Retina by Robert Scoble Irena Cronin(5238)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(3964)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3933)
Edit Like a Pro with iMovie by Regit(3415)
Linux Administration Best Practices by Scott Alan Miller(2858)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2835)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2520)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2390)
Docker on Windows by Stoneman Elton(2317)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2312)
Creative Projects for Rust Programmers by Carlo Milanesi(2234)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2107)
Hands-On Linux for Architects by Denis Salamanca(2051)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(2004)
Computers For Seniors For Dummies by Nancy C. Muir(1996)
The Old New Thing by Raymond Chen(1940)
Linux Kernel Debugging by Kaiwan N Billimoria(1762)
