[TileMap][cocos2d-x-2.1.4]Error with 3 tile layer and 1 object layer

I got an error when I create a map with 3 tile layer and 1 object layer (foreground, background, meta, and objects layer).
when I load it, I got an error “Unhandled exception at 0x58F22996 (libcocos2d.dll) in **.exe: 0xC0000005: Access violation reading location 0x00000038.”

And it stop at class CCTexture2D
bool CCTexture2D::hasPremultipliedAlpha()
{
return m_bHasPremultipliedAlpha;
}

I test with a map has 2 tile layer and 1 object layer -> it works.
how can fix it? please help me. thanks

p/s I work with VS2012(Windows 8 Pro)

recheck your background layer. Make sure your image and tmx file in the same directory, and remake your background layer.

i’me having the same problem. My images and tmx are all in the same folder.

ok I figured this out. its a relative file problem.
If you have your tilemap and images in a sub folder of resources, the api will attempt to load images relative to resources folder rather than the sub folder that holds both tmx and tilemap images.
Quick solution is to place tmx file and its images in the root resources folder.

no sorry the filepath issue was highlighted here:
http://www.cocos2d-x.org/forums/6/topics/32713?r=34295#message-34295

I have also found that if you have any tile layer that does not have at least one tile reference a tileset then the access violation in Texture2D::hasPremultipliedAlpha() occurs. I have found that if I remove these empty layers from the tmx file, the problem goes away.

I have in the past used Corona SDK and Million Tile Engine. I used empty tile layers to place my main character on a different layer depending upon his location on the screen. this allowed me to z-order the character based upon its y-pos.

The way to achieve this in cocos2d-x is slightly different and explained here:

http://www.cocos2d-x.org/wiki/TileMap

I’ve got the same issue today.
I found it is the problem of picture file type of tiled map. I solved this issue by converting the file from ‘gif’ type to ‘png’ type.
I guess cocos2dx doesn’t support the ‘gif’ file type.

firstly, open the picture file e.g. dg_grounds32.gif and save as dg_grounds32.png,then
open the tmx file with a text tool and modify the file name.



make sure the file path is correct. try again.