2

I'm creating a very simple game using Sprite Kit in Swift. The game has a simple grid of SpriteKitNodes and I would like to ask what's the better way to develop it for all devices in a single shot.

I've learned the new Size Classes feature in the Storyboard but could it be used here in with SpriteKit? How could I implement the constraint via code?

Here I'm simply creating the nodes in determined positions but of course they needs to be manipulated depending of the size of the device.

func addNodeToScene(x: CGPoint,y: CGPoint)
    {
        let node = SKSpriteNode(color: self.colorOfSpriteNode, size: CGSize(width: 50, height: 50))

        node = String(format: "node%d", self.nodeIdentifier)
        ++self.nodeIdentifier

        node.position = CGPoint(x: x, y: y)

        addChild(node)
    }

I've checked the class SKContraint, could it be used for this purpose?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
r4id4
  • 5,877
  • 8
  • 46
  • 76

0 Answers0