Sprite-Kit – How to use WhiteColor in SWIFT and Spritekit

I am running Yosemite and Xcode 6. I created a new project using the “Game” option SpriteKit and Swift.

Check in GameScene.swift In the overlay of didMoveToView(), I added the following line to try to change the background color:

self.backgroundColor = SKColor(whiteColor)

This will compile But it won’t run, because the error “Stopped with unresolved identifier’whiteColor'”

The only import is:

import SpriteKit 

Do I need another import to define whiteColor (I assume it is a constant in a certain header file?

[SKColor whiteColor] is a class method, as usual, it is converted to SKColor.whiteColor()

self.backgroundColor = SKColor. whiteColor()

I am running Yosemite and Xcode 6. I created a new project using the "Game" option SpriteKit and Swift.

In the overlay of didMoveToView() in GameScene.swift, I added the following line to try to change the background color:

self.backgroundColor = SKColor(whiteColor)

This will compile but will not run. It stops with the error "Using unresolved identifier'whiteColor'"

The only import is:

import SpriteKit

Do I need another import to define whiteColor (I assume it is a constant in a header file?

[SKColor whiteColor] is a class method, as usual, it is converted to SKColor.whiteColor()

self.backgroundColor = SKColor.whiteColor()

Leave a Comment

Your email address will not be published.