Reputation: 67
I have the problem that the images I add are distorted. I have created a pixel accurate background for the iPhone X at (1125 x 2436)
, so I don't have to use .aspectFill
and .aspectFit
because I want a screen without black borders.
I use the following code to create the images:
func animateDeck() {
let chip = SKSpriteNode(imageNamed: "Chip")
chip.position = CGPoint(x: 300, y: 400)
chip.zPosition = 2
chip.setScale(1)
gameScene2.addChild(chip)
print("test")
}
Is there a way to display the images in their correct size without using .aspectFit
or .aspectFill
?
now (left) and how it should be (right)
Thank you in advance!
Upvotes: 2
Views: 301
Reputation: 30341
Check out this project I just made to show you how to create a texture and apply it to a node. All you need should be in GameScene.swift
.
Also, in your ViewController
, make sure that your GameScene
is initialised properly as shown in my project, or how you did it with this:
gameScene2 = GameScene(size: view, bounds: size)
Upvotes: 1