Error loading image in SpriteKit Hello World
I created a new xcode project "game" and I am trying to make a really simple "Hello World" where I display an image on the screen.
My image is not loading. Mistake:SKTexture: Error loading image resource: "img/flappy1.png"
The code is an exact copy of the tutorial in which it works. Did I forget something?
My code:
My image:
When I run the application:
+3
source to share
2 answers
Try "flappy1.png" instead of "img / flappy1.png".
What looks like folders in the Xcode organizer are not actually folders on disk, but instead "groups" that only exist within Xcode.
In addition to this, when an asset is added to a project in Xcode, the project retains the path to the asset and can be loaded without an absolute path.
So:
var birdTexture = SKTexture(imageNamed: "flappy1.png")
+1
source to share