I’ve been stuck on this problem for the past 2 days. I am trying to use a plist file to load a sprite from a spritesheet. I first try it with the files and code provided by the author of the tutorial I’m working with. It works fine. But when I substitute my plist file and my sprite name into the code, it gives me a null pointer exception. The author’s plist file is, “mole.plist” and mine is “myspritesheet.plist.” The author’s sprite key is “a0001.png” while mine is “blue.png”. The changes to the code is as below:
CCString* file = (Utils::getArtScaleFactor() > 1) ? CCString::create(“myspritesheet.plist”) : CCString::create(“myspritesheet.plist”);
CCSpriteFrameCache::sharedSpriteFrameCache()>addSpriteFramesWithFile);>setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(“blue.png”));
In my sprite cpp file, I load the sprite from the spritesheet with the following key:
this
The error I get is the standard null pointer exception:
Fatal signal 11 (SIGSEGV) AT 0x00000028 (code=1), thread 707 (Thread-81)
-
My theory of the problem is that the code is able to load the plist file but it is unable to use the key (blue.png) to load my sprite from the spritesheet. I have gone into both plist files to compare the author’s plist code with mine and there is little differences. I am frustrated now with not being able to understand how spriteFrameByName() retrieves the sprite from the spritesheet with the key I provide.
-
There is a difference in that the author uses a pvr.ccz file to load his sprite in his plist file from his spritesheet while I use a .png file (blue.png). Does that make any difference? My understanding of a pvr.ccz file is that it is just a compressed file. Am I using the right method, spriteFrameByName() to retrieve my sprite?