我创建了一个SKSpriteNode黑色的游戏,当用户触摸屏幕时,我希望将SKSpriteNode其更改为白色.我用谷歌搜索了所有可能的东西,尝试了许多不同的策略而没有运气.有谁知道如何做到这一点?
这是我的场景的代码:
var blackBird = SKSpriteNode()
override func didMoveToView(view: SKView) {
//Black Bird
var blackBirdTexture = SKTexture(imageNamed:"blackbird")
blackBirdTexture.filteringMode = SKTextureFilteringMode.Nearest
blackBird = SKSpriteNode(texture: blackBirdTexture)
blackBird.setScale(0.5)
blackBird.position = CGPoint(x: self.frame.size.width * 0.35, y:
self.frame.size.height * 0.6)
blackBird.physicsBody =
SKPhysicsBody(circleOfRadius:blackBird.size.height/2.0)
blackBird.physicsBody!.dynamic = true
blackBird.physicsBody!.allowsRotation = false
self.addChild(blackBird)
}
override func touchesBegan(touches: Set<NSObject, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
blackBird.color = .whiteColor()
blackBird.colorBlendFactor = …Run Code Online (Sandbox Code Playgroud) 苹果已经在手机中添加了一般>辅助功能>反转颜色的功能,我可以在我的程序中以某种方式使用它,例如当用户触摸屏幕时颜色反转吗?