Swift: Drawing text on bitmap

Note: Source code (DrawingText) available on Github In the last article, we covered the basics of bitmap drawing with Swift and the Quartz/Core Image APIs. As I was playing with that, I wondered how text could be drawn on a bitmap. In Flash, the BitmapData API does not have an API for drawing text, the workaround was to use a TextField offscreen that would be passed to the BitmapData.draw API.

Read more

Swift: Bitmap data and filters

Note: Source code (FilterExample) available on Github I was wondering how bitmap programming works on iOS, just like with BitmapData in Flash, I wanted to perform simple operations for painting but also curious about how filters work. Again, in AS3, you would use the applyFilter API on BitmapData, so here is how things work on iOS/MacOS with Swift and the Quartz/Core Image APIs. Graphics Context and the Quartz drawing engine

Read more

Swift: Touch event and physics field

Note: Source code (PhysicsField Example) available on Github iOS8  introduces a set of new features for SpriteKit, and one of them is Physics field (SKFieldNode). They simulate physical forces and as a result, automatically affect all the physics bodies living in the same tree, very useful for games or any other kind of experiments. Multiple kinds of fields are introduced, from vortex, magnetic, spring, etc. A SKFieldNode is invisible, but still needs to

Read more

Swift: Bouncing balls with built-in physics engine

Note: Source code (Bouncing Balls Example) available on Github I have been playing tonight with the built-in physics engine in SpriteKit. Like most Flash developers, I am sure you have played or used the Box2D engine in some projects. I have to admit, the APIs have always been pretty brutal to use. The engine that comes out of the box with SpriteKit has a much more approachable API, very intuitive.

Read more

Swift: Types conversion, subclassing, casting and drawing

Here is another Swift example, showing how to convert types, subclass a native one, perform casting and draw multiple shapes (like with the Drawing API) and make them move: // Playground – noun: a place where people can play // Consider this your Main class, basically the Stage // Note: The code below is for OSX Playground, not iOS // this imports higher level APIs like Starling import SpriteKit import

Read more