Clamping a value is an operation of moving the value to a range of allowed values. It can be achieved by comparing the value with allowed minimum and maximum values. For example I was deforming SKWarpGeometryGrid from the direction of a point outside the grid and needed to constrain angles between grid points and the …
Positioning a node at the edge of a screen
iOS devices have several screen sizes and aspect ratios. This is something to keep in mind when building a game in SpriteKit because placing a node at the edge of a screen is not straight forward. But first let's take a quick look on managing scenes. One way for it is to use scene editor …
Continue reading "Positioning a node at the edge of a screen"
Drawing gradients in SpriteKit
I was working on an upcoming game in SpriteKit only to discover that adding a simple gradient is not so straight-forward as one would expect. Therefore I created an extension to SKTexture. https://gist.github.com/laevandus/c38a8b9e958ef68c6730025f6b4cc7f4 This extension adds support for creating linear and radial gradients. Linear gradient can be drawn with an angle (in radians) although in …
Processing data using Metal
Metal framework on Apple devices provides a way of using GPU for running complex computing tasks much faster than on CPU. In this blog post I am giving a quick overview how to set up a Metal compute pipeline and processing data on the GPU. Metal compute kernel As a first step we need to …