Game development for Apple platforms

Spawning pieces in code

Here's a video of me trying to figure out how to spawn the L-piece in a way that makes sense.

I discard the idea of designing the pieces in the SpriteKit scene editor because it seems too error-prone. Node dimensions, anchor sizes, node hierarchy, and physics bodies - they all need to be very precise, and the scene editor is not really geared towards that.

Instead, I subclass an SKSpriteNode as an LPiece node and create a physics body with NSBezierPath (to be implemented as UIBezierPath for other platforms). The path creation highlights an unfortunate hole in Apple's APIs when targetting multiple platforms.

#coding #nsbezierpath #skphysicsbody #spritekit #uibezierpath #video