Jump to content

Gaps between tiles using Pixi-Tilemap


tedex
 Share

Recommended Posts

First of all, sorry for my english.

I just started with Pixi and was studying tilemaps, but I'm having gaps between the tiles whenever I scale by the factor of 0.01.

Yes, i'm using PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST;

Here's what I I've got:


PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST;

PIXI.loader
.add('tileset', 'img/tileset.json')
.load(setupMap);

function setupMap() {
	var mapData = []; // Omitting bidimensional array with tiles for the sake of the example
	var map = new Container;
	var tilemap = new PIXI.tilemap.CompositeRectTileLayer(0, [], true);

	for(var coll = 0; coll < 100 * 48; coll++) {
		for(var row = 0; row < 100 * 48; row++) {
			if(mapData.hasOwnProperty(coll) && mapData[coll].hasOwnProperty(row)) {
				tilemap.addFrame(tileset.textures[mapData[coll][row]], coll*48, row*48);
			} else {
				break;
			}
		}
	}

	map.addChild(tilemap);
	stage.addChild(map);

}

// This fucks up everything
document.addEventListener('mousewheel', mousewheel, false);
document.addEventListener('DOMMouseScroll', mousewheel, false);
function mousewheel(e) {
	var zoomOut = e.wheelDelta <= 0;
	map.scale.set(map.scale.x + (zoomOut ? -0.01 : 0.01));
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...