我一直在使用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)
}
现在我正在创建一个没有SKTextures的示例代码,按以下方式设置我的SKSpriteNodes:
oldSprite = SKSpriteNode(color: SKColor.blueColor(), size: oldSpriteSize)
newSprite = SKSpriteNode(color: SKColor.BrownColor(), size: newSpriteSize)
如何在没有SKTextures的情况下更改didBeginContact中的精灵颜色和大小?
答案 0 :(得分:1)
这应该有效
newSprite.color = UIColor.redColor()
newSprite.size = CGSize(width: 250, height: 250)