gpt4 book ai didi

ios - 使用 scaleMode .AspectFit 时如何更改 SKView 信箱颜色

转载 作者:搜寻专家 更新时间:2023-10-30 21:59:04 28 4
gpt4 key购买 nike

我正在使用来自样板代码(新游戏 iOS 项目)的标准全屏 SpriteKit View ,以及我何时使用

scene.scaleMode = .AspectFit

为确保场景适合,剩余(信箱)区域用黑色着色。

我试过这些选项来改变颜色:

let skView = self.view as SKView

// was hoping this one would work
skView.backgroundColor = UIColor.redColor()

// didn't expect this would work, since scene is scaled anyways
scene.backgroundColor = SKColor.redColor()

还尝试将 Storyboard编辑器中的 SKView 背景颜色更改为另一种颜色,但没有成功。

关于在哪里查看更改信箱区域颜色的任何提示?

最佳答案

我认为这应该是一种在信头的耳朵中设置颜色或放置 sprite 的方法……但似乎没有。另外,我不同意 LearnCocos2D。 AspectFit 没有任何问题。它有它的用处。

我所做的是使用 AspectFit,但也根据屏幕尺寸计算场景的尺寸。这对 OSX 游戏没有太大帮助,但它对 iOS 会很好地工作。

func createScene() -> GameScene {
let screenSize = UIScreen.mainScreen().bounds.size
var size:CGSize = CGSizeZero

size.height = Constants.sceneHeight
size.width = screenSize.width * (size.height / screenSize.height);


return GameScene(size: size)
}

override func viewDidLoad() {
super.viewDidLoad()

let scene = self.createScene()

// Configure the view.
let skView = self.view as SKView
skView.showsFPS = false
skView.showsNodeCount = false

/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true

/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFit

skView.presentScene(scene)
}

关于ios - 使用 scaleMode .AspectFit 时如何更改 SKView 信箱颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25633467/

28 4 0
文章推荐: angular - 使用 router.navigate 导航不适用于 nativescript-tab-navigation 模板
文章推荐: sql - 数据库架构 : Why not create new table for each 'entity' ?
文章推荐: typescript - 两种方式的数据绑定(bind)不适用于