I created a SKSPriteNode without texture but color
let tileNode = SKSpriteNode(color: SKColor.redColor(), size: CGSize(width: 80.0, height: 120.0))
tileNode.position = CGPointMake(50, 50)
tileNode.name = "rectangle"
addChild(tileNode)
But the node doesn't display on the screen.
However, I can detect it with touch collision
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
let location: CGPoint = (touches.anyObject() as UITouch).locationInNode(tilesLayer)
let rect: SKSpriteNode = tilesLayer.childNodeWithName("rectangle") as SKSpriteNode
if rect.containsPoint(location) {
println("TOUCHED") //It works
}
}
EDIT : The SKSpriteNode color is only hidden if there is a background SKSpriteNode texture. Complete code : https://gist.github.com/BabyAzerty/9dca752d9faa7b768bf0