6
votes

I'm working on making a "menu" with SKNode being the menu background, and a bunch of SKSpriteNodes as the child element options.

The problem is I can't figure out how to add a color or texture or something to the SKNode to serve as a background to the menu; there are no .size, .texture, .color, or .background/.backgroundcolor method options

should I use an SKSpriteNode with other SKSpriteNodes inside, or should I maybe use an SKScene instead with SKSpriteNodes inside? or is there a way to assign an SKNode a background image or color?

1
[mainSprite addChild:childSprite]; - Valar Morghulis
@ValarMorghulis I know how to add children, I want a color/texture for the sknode - duxfox--
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithColor:[SKColor redColor] size:yourSize]; - Valar Morghulis

1 Answers

9
votes

I will create red sprite for example

let sprite = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(20, 20))
                sprite.position = CGPointMake(self.size.width/2, self.size.height/2)
                addChild(sprite)