开发者

"Invalid Texture For Sprite" Cocos2d Tilemap Error

I am trying to make a game in Cocos2d that uses an orthogonal tilemap. I create the map in tiled using a simple tileset I drew in Adobe Illustrator. The tiles are 32x32 pixels, and the map is only 20x20 tiles. When I use the tilemap in Cocos2d, it works fine when I test it out on the iPhone simulator. However, when I test it on my iPod touch, the app crashes (terminates with NSException) and it gives me an error saying

-(id) initWithTexture:(CCTexture2D*)texture

{

NSAssert(texture!=nil, @"Invalid texture for sprite");
CGRect rect = CGRectZero;
rect.size = texture.contentSize;
return [self initWithTexture:texture rect:rect];

}

I开发者_如何学C've messed with the map and the tiles but I cannot get the app to work. Any help is appreciated. Thanks.


I had the same problem. The thing was that I have not added tileset image to my project. When the app was compiled, this resource has not been copied to the device, so texture could not been loaded. I have simply added image for the tileset and it worked ok. Hope it will help someone.


Not sure about this - but it could be you have not got the case of the filename correct. If you have a file called image.PNG but you reference it as @"image.png" it will work in the simulator, but not when deployed to the device.

I learnt this from this book.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜