しめ鯖日記

swift, iPhoneアプリ開発, ruby on rails等のTipsや入門記事書いてます

SpriteKitのSKTextureというものについて調べてみた

SKTextureというNodeに画像を付ける為のオブジェクトについて調べてみました。
SKSpriteNodeに画像を付けるだけならUIImageでもできるので、UIImageとの違いを中心に調べてみます。

SKSpriteNodeに付ける事ができる

SKSpriteNodeのtextureというプロパティーにセットして使います。
SKNodeにはセットできないようです。

UIImageは初期化時にしかセットできないので、途中で変更したい時はUIImageでなくSKTextureを使った方が良さそうです。

SKActionで使える

SKActionにはSKTextureをセットするメソッドがあります。
これはUIImageではできません。

public class func setTexture(texture: SKTexture) -> SKAction
public class func setNormalTexture(texture: SKTexture) -> SKAction
public class func animateWithTextures(textures: [SKTexture], timePerFrame sec: NSTimeInterval) -> SKAction
public class func animateWithNormalTextures(textures: [SKTexture], timePerFrame sec: NSTimeInterval) -> SKAction