如何在没有 SKTexture 的情况下更改 didBeginContact 中的 SKSpriteNode 大小和颜色?

iGe*_*tIt 5 sprite-kit skspritenode swift swift2

我一直在使用 SKTexture 按以下方式更改 didBeginContact 中的 SKSpriteNode 颜色和大小。

if firstBody.categoryBitMask == spriteCategory && secondBody.categoryBitMask == enemyCategory    {
     var newSprite = firstBody.node
     let newImage = SKTexture(imageNamed: "newSprite.png")
     (newSprite as? SKSpriteNode)?.size = newImage.size() //magic
     oldToNewSpriteAction = SKAction.setTexture(newImage)
     newSprite!.runAction(oldToNewSpriteAction)
 }
Run Code Online (Sandbox Code Playgroud)

现在我正在创建一个没有 SKTextures 的示例代码,按以下方式设置我的 SKSpriteNodes:

oldSprite = SKSpriteNode(color: SKColor.blueColor(), size: oldSpriteSize)
newSprite = SKSpriteNode(color: SKColor.BrownColor(), size: newSpriteSize)
Run Code Online (Sandbox Code Playgroud)

如何在没有 SKTextures 的情况下更改 didBeginContact 中的精灵颜色和大小?

Tim*_*sen 2

这应该有效

newSprite.color = UIColor.redColor()
newSprite.size = CGSize(width: 250, height: 250)
Run Code Online (Sandbox Code Playgroud)