NOTE: Sorry for the multiple posts, I’m currently looking for the delete button. :S
Hi all,
I am using CCTMXTiledMap to load a small tile map. I noticed that when doing a CCTMXTiledMap::setPosition(), sometimes the tiles do not align right.
Here is an example when doing seting the position to x-y coordinates <79,0>:
Here is the same example at x-y coordinates <78,0>
Tile map specs:
* Layers: 2 {“TextHello” (The one with the blue tiles)} {“Background” (ground looking tiles)}
* Tilemap size: 32 x 24 tiles
* Tiles size: 32 x 32 pixels
I am doing the bare minimum in code:
Header:
class GameWorldCanvas : public cocos2d::CCLayer
{
public:
GameWorldCanvas(void);
~GameWorldCanvas(void);
LAYER_NODE_FUNC(GameWorldCanvas)
virtual bool init(void);
virtual void ProcessKeyPress(int messageID, int wParam, int lParam);
void Update( cocos2d::ccTime deltaTime );
void AppendTileMap( const char* mapFile );
private:
cocos2d::CCTMXTiledMap* canvasMap;
float curPos;
bool isMoving;
};
Source:
GameWorldCanvas::GameWorldCanvas(void)
: curPos(79)
, isMoving(false)
{
}
GameWorldCanvas::~GameWorldCanvas(void)
{
this->removeAllChildrenWithCleanup(true);
}
bool GameWorldCanvas::init(void)
{
canvasMap = CCTMXTiledMap::tiledMapWithTMXFile("map.tmx");
canvasMap->setPosition( (int)canvasMap->getPositionX() - (int)curPos, 0 );
addChild(canvasMap);
//For enabling keyboard input
CCEGLView::sharedOpenGLView().setTargetCCLayer(this);
schedule(schedule_selector(GameWorldCanvas::Update));
return true;
}
The tile splitting seems to occur vertically on the same exact location when the vertical line is between 2 tiles.
I guess my question is… Is there some detail about tile maps that I am not aware of?
Here’s the tile map file just in case: http://www.sendspace.com/file/shda85