简体   繁体   中英

Error loading textures using Spritekit and Texture Packer

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!

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 (eg 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, eg

SKSpriteNode *ship = [SKSpriteNode spriteNodeWithTexture:ARTWORK_TEX_SHIP];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM