1

There does not seem to be a simple way to apply an affine transformation to a node in SpriteKit. (For example, in VB, I am used to setting a transform matrix as a property of e.graphics)

I've tried to look up how to do it, but the only answer I can find is this:

SpriteKit missing linear transformation matrices

However, the answer seems to be very complex for what I am trying to achieve, and perhaps it is outdated? Is there a simple way of applying a transformation matrix to any SKNode?

Community
  • 1
  • 1
Shuri2060
  • 729
  • 6
  • 21
  • I don't see why that answer is complicated. Also, what kind of transformation actually you are trying to achieve? – Whirlwind Jul 10 '16 at 14:58
  • It uses 9 lines to achieve something which I would hope to be able to do in 2 or 3. And no - I'm not necessarily doing something simple like a rotation, etc. – Shuri2060 Jul 10 '16 at 15:52

1 Answers1

1

Whilst SpriteKit is likely a tight wrapper around some of Core Animation (which does have Affine Transformations) the 3D matrix capabilities of Core Animation have not been brought over.

This is why your example is complex, he's "faking" the results of a 3D transformation by using a filter.

Your best possible solution (and staying with Sprite Kit) is to use Scene Kit and render your SpriteKit content onto/into SceneKit objects/planes with full 3D transformation abilities...

However, whilst these frameworks have been designed to work in this manner, there are many bugs and issues, and very few people doing it, and even fewer working on it at Apple. So it's not necessarily stable, nor easy to find how to do it in your way.

Here's a starting point, point 3, using SpriteKit scenes as materials in SceneKit:

http://code.tutsplus.com/tutorials/combining-the-power-of-spritekit-and-scenekit--cms-24049

Confused
  • 6,048
  • 6
  • 34
  • 75