Каков наилучший способ аспектного изображения в синей коробке? Игра основана на пикселях, поэтому я хотел бы также сохранить пиксельный вид.Scaling SpriteKit game
0
A
ответ
0
В соответствии с фактическим Swift 2.2 вы можете найти:
@available(iOS 7.0, *)
public enum SKSceneScaleMode : Int {
case Fill /* Scale the SKScene to fill the entire SKView. */
case AspectFill /* Scale the SKScene to fill the SKView while preserving the scene's aspect ratio. Some cropping may occur if the view has a different aspect ratio. */
case AspectFit /* Scale the SKScene to fit within the SKView while preserving the scene's aspect ratio. Some letterboxing may occur if the view has a different aspect ratio. */
case ResizeFill /* Modify the SKScene's actual size to exactly match the SKView. */
}
Вы можете сделать это, например, в вашем ViewController:
override func viewDidLoad() {
super.viewDidLoad()
if let scene = PreloadScene(fileNamed:"PreloadScene") {
// Configure the view.
let skView = self.view as! SKView
...
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFit
...
skView.presentScene(scene)
}
}
Или транзитом из SKScene
к другому SKScene
:
let transition = SKTransition.doorsOpenVerticalWithDuration(0.5)
let nextScene = MainScene(size: self.scene!.size)
nextScene.scaleMode = .AspectFit
self.scene?.view?.presentScene(nextScene, transition: transition)
+0
Почему-то AspectFit не дает мне почтового ящика и кажется точно таким же, как AspectFill. – Latcie
+0
Попробуйте добавить код на свой вопрос, чтобы лучше понять вашу проблему. –
0
Вы можете масштабировать свой спрайт в синей коробке.
func fitToBlueBox(node:SKSpriteNode, blueBox:SKSpriteNode) { let actualScale = min(blueBox.size.width/node.size.width, blueBox.size.height/node.size.height) node.setScale(actualScale); }
Смежные вопросы
- 1. Swift SpriteKit Game Center
- 2. SpriteKit Game Center Authentication
- 3. show menu when paused game ins spritekit
- 4. SpriteKit Game Spending Много времени в AppDelegate
- 5. pausing spritekit game using appdelegate in ios8
- 6. Установка позиции узла SpriteKit (Mid-Game)
- 7. Double Tap делает краш SpriteKit Game
- 8. Внедрение iAd в Spritekit Game With Swift
- 9. Swift IOS Spritekit Scaling Sprite Размер на основе размера устройства
- 10. Libgdx camera/scaling issue
- 11. Ошибка исходной ошибки типа Collide - spritekit swift game
- 12. Easy SpriteKit Обнаружение контакта (Space Shooter Game) Не правильно Wotking
- 13. Swift-Не удается присутствовать Game Center с SpriteKit
- 14. Spritekit Game Сцена останавливается при первом обращении после добавления Game Center к игре
- 15. Windows scaling
- 16. Scaling EhCache
- 17. Scaling SKSpriteNode
- 18. GraphEngine Scaling
- 19. MongoDB scaling
- 20. postscript scaling
- 21. CGPDFDocument scaling
- 22. Scaling Drupal
- 23. Нужен совет по Libgdx Scaling
- 24. Java Game Game Program
- 25. Обновление Swift 2 (SpriteKit)
- 26. In-App Purchase Swift Game
- 27. SpriteKit
- 28. SpriteKit создает 3D-объекты
- 29. Scaling значение прогресс бар
- 30. CPU Intensive App Scaling
... использовать режим Aspect Fit масштаб? – Knight0fDragon
Я называю это self.view? Будет ли это масштабировать все узлы? – Latcie