mardi 2 août 2016

How to tile a Sprite Node's Texture?

Using SpriteKit, how would I tile a SKTexture that repeats itself horizontally to fill the width of the SKSpriteNode? This is what I have so far - only stretches the texture.

    var header = SKSpriteNode()
    let headerTexture = SKTexture(imageNamed: "inGameHeader-1.png")
    header = SKSpriteNode(texture: headerTexture)
    header.position = CGPoint(x: 0, y: CGRectGetMaxY(self.frame)-39)
    header.size.width = CGRectGetWidth(self.frame)
    header.size.height = 150
    header.anchorPoint = CGPoint(x: 0,y: 1)
    addChild(header)

Aucun commentaire:

Enregistrer un commentaire