sprite kit: imageNamed: or texture:?

368 views Asked by At

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)

0

There are 0 answers