0

I am using SpriteKit and Texture Packer. I have a small sequence of animation. I was able to load certain images such as background and logos. But when I try to load the texture, which has an animation sequence using -

SKSpriteNode *char1 = [SKSpriteNode spriteNodeWithTexture:TEST_TEX_CHARACTER01];

It says SKTexture:Error loading image resource: "character01".

Please help me out!

Bug
  • 2,576
  • 2
  • 21
  • 36
Arjun Busani
  • 550
  • 1
  • 7
  • 15
  • missing file extension perhaps? Shouldn't it be character01.png? – CodeSmile Oct 03 '13 at 12:16
  • Maybe not directly related to your question, however you don't need to use Texture Packer when you use SpriteKit. SpriteKit has a neat way of creating texture atlases automatically. Here's a pretty good documentation on how to create animations with SpriteKit using texture atlases (http://www.raywenderlich.com/45152/sprite-kit-tutorial-animations-and-texture-atlases). If you want the actual problem solved you should probably provide more code + details about asset names, etc. – Ben-G Oct 10 '13 at 00:31

1 Answers1

0

Texture Packer creates a header file when you tell it you are using SpriteKit. I came across the same issue recently, although it worked just fine in a previous game. Everything appears to be correct in the plist, header and atlas.

I will edit my answer with a solution when I find one.

EDIT:

This turned out to be pretty simple. If you have any images with @2x in the name, change the name to a plain file name (e.g. ship@2x.png needs to be ship.png).

With that change to any files that need it and re-publishing your atlas from Texture Packer you should be able to use the convenience macro name from the header, e.g.

SKSpriteNode *ship = [SKSpriteNode spriteNodeWithTexture:ARTWORK_TEX_SHIP];
jgnovak-dev
  • 495
  • 3
  • 11