我正在为一些精灵加载一个原本是红色的纹理。但是,我想通过我的方法loadPauseIcons():
将该颜色更改为白色func loadPauseIcons() {
let icons = ["HomeIcon", "LevelIcon", "RetryIcon"]
let iconSize = CGSize(width: pauseButton.size.width * 0.6, height: pauseButton.size.height * 0.6)
var iconY = pauseButton.position.y - pauseButton.size.height
for icon in icons {
let currentIcon = SKSpriteNode(imageNamed: icon)
currentIcon.position = CGPoint(x: pauseButton.position.x, y: iconY)
currentIcon.color = .white
currentIcon.size = iconSize
currentIcon.name = icon
currentIcon.zPosition = 11
iconY -= pauseButton.size.height * 0.35 + currentIcon.size.height
self.addChild(currentIcon)
pauseIcons.append(currentIcon)
}
}
此方法在SKScene的touchesBegan()方法上运行。但是,我仍然得到一个红色图标:(房子和三个酒吧)
Ember Data and Custom APIs - 5 Common Serializer Customizations
我是否做错了改变精灵的颜色?
答案 0 :(得分:0)
尝试添加:
currentIcon.colorBlendFactor = 1.0
默认情况下,精灵的colorBlendFactor
为0.0,这意味着忽略了它的color
属性。 colorBlendFactor
的值越接近1.0,精灵的color
属性就越多。