How to prevent distorted images?
up vote
2
down vote
favorite
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!
swift sprite-kit skspritenode
|
show 18 more comments
up vote
2
down vote
favorite
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!
swift sprite-kit skspritenode
1
If you have an image which is exactly the same size as the iPhone X, and set the position toview.center, you should be fine. However, even if it should fit perfect, set it toaspectFilloraspectFitjust so you don't get distortion on other screen sizes.
– George_E
Nov 4 at 10:22
1
Try also checking to see thatchipis at your expected size - and if not, you can set it usingchip.size = CGSize(width: 1125, height: 2436).
– George_E
Nov 4 at 10:25
I have created a new image with the size 1125 x 2436. In the middle is the 128x128 chip. The rest of the image is transparent. Unfortunately this does not work. With the other variantgameScene2.scaleMode = .aspectFitblack bars are displayed again, which I want to prevent.
– TimKrs
Nov 4 at 11:00
Why don’t you consider adding aUIImageto the view controller instead of the scene if you are not moving the background?
– George_E
Nov 4 at 11:03
When I uselet image = UIImage(named: "Chip"), I cannot use it as a node. So I can no longer use SKPhysicsBody, SKAction, etc. avail
– TimKrs
Nov 4 at 11:24
|
show 18 more comments
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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!
swift sprite-kit skspritenode
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!
swift sprite-kit skspritenode
swift sprite-kit skspritenode
edited Nov 4 at 12:52
asked Nov 4 at 9:48
TimKrs
158
158
1
If you have an image which is exactly the same size as the iPhone X, and set the position toview.center, you should be fine. However, even if it should fit perfect, set it toaspectFilloraspectFitjust so you don't get distortion on other screen sizes.
– George_E
Nov 4 at 10:22
1
Try also checking to see thatchipis at your expected size - and if not, you can set it usingchip.size = CGSize(width: 1125, height: 2436).
– George_E
Nov 4 at 10:25
I have created a new image with the size 1125 x 2436. In the middle is the 128x128 chip. The rest of the image is transparent. Unfortunately this does not work. With the other variantgameScene2.scaleMode = .aspectFitblack bars are displayed again, which I want to prevent.
– TimKrs
Nov 4 at 11:00
Why don’t you consider adding aUIImageto the view controller instead of the scene if you are not moving the background?
– George_E
Nov 4 at 11:03
When I uselet image = UIImage(named: "Chip"), I cannot use it as a node. So I can no longer use SKPhysicsBody, SKAction, etc. avail
– TimKrs
Nov 4 at 11:24
|
show 18 more comments
1
If you have an image which is exactly the same size as the iPhone X, and set the position toview.center, you should be fine. However, even if it should fit perfect, set it toaspectFilloraspectFitjust so you don't get distortion on other screen sizes.
– George_E
Nov 4 at 10:22
1
Try also checking to see thatchipis at your expected size - and if not, you can set it usingchip.size = CGSize(width: 1125, height: 2436).
– George_E
Nov 4 at 10:25
I have created a new image with the size 1125 x 2436. In the middle is the 128x128 chip. The rest of the image is transparent. Unfortunately this does not work. With the other variantgameScene2.scaleMode = .aspectFitblack bars are displayed again, which I want to prevent.
– TimKrs
Nov 4 at 11:00
Why don’t you consider adding aUIImageto the view controller instead of the scene if you are not moving the background?
– George_E
Nov 4 at 11:03
When I uselet image = UIImage(named: "Chip"), I cannot use it as a node. So I can no longer use SKPhysicsBody, SKAction, etc. avail
– TimKrs
Nov 4 at 11:24
1
1
If you have an image which is exactly the same size as the iPhone X, and set the position to
view.center, you should be fine. However, even if it should fit perfect, set it to aspectFill or aspectFit just so you don't get distortion on other screen sizes.– George_E
Nov 4 at 10:22
If you have an image which is exactly the same size as the iPhone X, and set the position to
view.center, you should be fine. However, even if it should fit perfect, set it to aspectFill or aspectFit just so you don't get distortion on other screen sizes.– George_E
Nov 4 at 10:22
1
1
Try also checking to see that
chip is at your expected size - and if not, you can set it using chip.size = CGSize(width: 1125, height: 2436).– George_E
Nov 4 at 10:25
Try also checking to see that
chip is at your expected size - and if not, you can set it using chip.size = CGSize(width: 1125, height: 2436).– George_E
Nov 4 at 10:25
I have created a new image with the size 1125 x 2436. In the middle is the 128x128 chip. The rest of the image is transparent. Unfortunately this does not work. With the other variant
gameScene2.scaleMode = .aspectFit black bars are displayed again, which I want to prevent.– TimKrs
Nov 4 at 11:00
I have created a new image with the size 1125 x 2436. In the middle is the 128x128 chip. The rest of the image is transparent. Unfortunately this does not work. With the other variant
gameScene2.scaleMode = .aspectFit black bars are displayed again, which I want to prevent.– TimKrs
Nov 4 at 11:00
Why don’t you consider adding a
UIImage to the view controller instead of the scene if you are not moving the background?– George_E
Nov 4 at 11:03
Why don’t you consider adding a
UIImage to the view controller instead of the scene if you are not moving the background?– George_E
Nov 4 at 11:03
When I use
let image = UIImage(named: "Chip"), I cannot use it as a node. So I can no longer use SKPhysicsBody, SKAction, etc. avail– TimKrs
Nov 4 at 11:24
When I use
let image = UIImage(named: "Chip"), I cannot use it as a node. So I can no longer use SKPhysicsBody, SKAction, etc. avail– TimKrs
Nov 4 at 11:24
|
show 18 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
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)
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
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)
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
add a comment |
up vote
1
down vote
accepted
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)
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
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)
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)
edited yesterday
answered Nov 4 at 14:54
George_E
838425
838425
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
add a comment |
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
I never recommend doing this, set the sks to the size of iphone x instead. You should be designing your scene with 1 size in mind, programming like this is only going to hurt you in the long run.
– Knight0fDragon
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139513%2fhow-to-prevent-distorted-images%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
If you have an image which is exactly the same size as the iPhone X, and set the position to
view.center, you should be fine. However, even if it should fit perfect, set it toaspectFilloraspectFitjust so you don't get distortion on other screen sizes.– George_E
Nov 4 at 10:22
1
Try also checking to see that
chipis at your expected size - and if not, you can set it usingchip.size = CGSize(width: 1125, height: 2436).– George_E
Nov 4 at 10:25
I have created a new image with the size 1125 x 2436. In the middle is the 128x128 chip. The rest of the image is transparent. Unfortunately this does not work. With the other variant
gameScene2.scaleMode = .aspectFitblack bars are displayed again, which I want to prevent.– TimKrs
Nov 4 at 11:00
Why don’t you consider adding a
UIImageto the view controller instead of the scene if you are not moving the background?– George_E
Nov 4 at 11:03
When I use
let image = UIImage(named: "Chip"), I cannot use it as a node. So I can no longer use SKPhysicsBody, SKAction, etc. avail– TimKrs
Nov 4 at 11:24