Page 1 of 1

Problem with tilemap positioning

Posted: Mon Sep 16, 2013 5:19 pm
by Mai
Hi,

I'm creating a tiled map and it's... well, misplaced. The obj[] entities are going to different coordinates, 50x and 75y bigger than they should. I tried translating to 0,0,0, translating to tile, changing origin, and nothing has worked so far. Here is my code, mostly copied from the examples, with a few changes only.

Code: Select all

				self.mainScene = new IgeScene2d()
						.id('mainScene')
						.translateTo(0, 0, 0)
						.drawBounds(false)
						.drawBoundsData(false);

					self.backScene = new IgeScene2d()
						.id('backScene')
						.depth(0)
						.drawBounds(false)
						.drawBoundsData(false)
						.isometric(true)
						.mount(self.mainScene);

					self.tileMap = new IgeTileMap2d()
						.id('tileMap')
						.isometricMounts(true)
						.tileWidth(50)
						.tileHeight(50)
						.drawGrid(15)
						.drawMouse(true)
						.mount(self.backScene)
						.depthSortMode(2)
						.highlightOccupied(true);

					for (var i = 0; i < self.mapData.length; i++)
					{
						var col = i%15;
						var line = Math.floor(i/15);

						self.obj[i] = new IgeEntity()
							.id('tile'+i)
							.texture(self.gameTexture.terrain)
							.isometric(true)
							.cell(self.mapData[i])
							.dimensionsFromCell()
							.mount(self.tileMap)
							//.translateTo(col*50,line*50,0)
							.translateToTile(col, line, 0);

						//self.obj[i].originTo(self.obj[i].width()/2,self.obj[i].height()/2,0);
						if (self.mapData[i] > 2)
						{
							self.obj[i].occupyTile(col,line,1,1,1);
						}
					}
Help, anyone?

Re: Problem with tilemap positioning

Posted: Mon Sep 16, 2013 6:11 pm
by OldRod
I haven't done much with Isogenic yet, but this line:

Code: Select all

var col = i%15;
doesn't seem right to me.

Re: Problem with tilemap positioning

Posted: Mon Sep 16, 2013 6:20 pm
by Mai
OldRod wrote:I haven't done much with Isogenic yet, but this line:

Code: Select all

var col = i%15;
doesn't seem right to me.
This line actually doesn't have a problem. =p
It's giving me the values I want, and the objects are being placed on the correct places in relation to each other. They just don't fit in the grid.
Here's a printscreen: http://gyazo.com/d01b862d491d4829f896b0495cc16d93

Re: Problem with tilemap positioning

Posted: Mon Sep 23, 2013 6:31 pm
by coolbloke1324
Any chance you can zip up your project and attach it?

I'm stumped on this one from looking at the code so maybe a live copy will help me to debug! :)

Re: Problem with tilemap positioning

Posted: Tue Sep 24, 2013 1:49 pm
by Mai
There it is. I changed a few things on the code - like adding a tempfix to the terrain tiles so they'd stay where I want -, but the problem is still there. And the bakeryTiles are going to a completely different spot too.