Schanz97
Schanz97

Reputation: 23

sprite kit: imageNamed: or texture:?

I am currently working on a simple 2d sprite kit game. When I created the background "image" object I initialized it using the SKSpriteNode convenience imageNamed: initializer. However, after looking through some of the spriteKit documentation I found that it is also possible to set the "image" of the background sprite by using a texture instead with the texture: initializer.

I was wondering which one is the best for my scenario, and in general, where to use one over the other.

Here is the code I currently am using- backgroundImage = SKSpriteNode(imageNamed: "BackgroundImage")

Here is the code I could use instead with the texture: initializer- var backgroundTexture = SKTexture(imageNamed:"BackgroundImage") backgroundImage = SKSpriteNode(texture: backgroundTexture)

Upvotes: 0

Views: 364

Answers (0)

Related Questions