TMXTilemap Add layer / empty layer crash

Hello,

I’m trying to create a layer on a tilemap programmatically.

I want to create a layer of objects over the background and other info gained by the tilemap.

//use new to test; delete after

//create a new layer for the softblocks
 CCTMXLayerInfo \* pSoftblockLayerInfo = new CCTMXLayerInfo();
 CCTMXTilesetInfo \* pSoftblockLayerTilesetInfo = new CCTMXTilesetInfo();
 CCTMXMapInfo \* pSoftblockLayerMapInfo = new CCTMXMapInfo();

CCTMXLayer \* pSoftblockLayer = CCTMXLayer::create(pSoftblockLayerTilesetInfo, pSoftblockLayerInfo, pSoftblockLayerMapInfo );

I get an error as it cant find the tilemap….anyway round this?

if I try to enter an empty layer in the tiled editor and save it as a tmx. With background layer and an empty “foreground” layer.

I get a crash as it cant create a texture2d for …something? <- Possible bug…

With an empty layer in tiled tmx I get a crash here

 bool CCTexture2D::hasPremultipliedAlpha()
 {
 return m\_bHasPremultipliedAlpha;
 }

but still, id like to do it programmatically

Can you post the specific errors you’re getting? I bet we can figure it out :slight_smile:

Hey, thanx;

using this:
@ //create a new layer for the softblocks
CCTMXLayerInfo * pSoftblockLayerInfo = new CCTMXLayerInfo();
CCTMXTilesetInfo * pSoftblockLayerTilesetInfo = new CCTMXTilesetInfo();
CCTMXMapInfo * pSoftblockLayerMapInfo = new CCTMXMapInfo();
pSoftblockLayerTilesetInfo~~>m_sSourceImage = “block.png”;
//CCTMXLayer * pSoftblockLayer = new CCTMXLayer;
CCTMXLayer * pSoftblockLayer = CCTMXLayer::create;
this~~>addChild(pSoftblockLayer);@

I get this; which I also get adding a blank layer to a .tmx map using tiled.

http://imageshack.us/photo/my-images/145/blanklayer.png/

Uploaded with ImageShack.us

I’m trying to create a layer dynamically , so I can add tiled where I want them dynamically. Maybe I could use just a normal spritebatch, but then I have to redo all the “get tile at” and then remove, etc…as the foreground dynamic layer should change. Any ideas?