Sign in to follow this  
tedex

Gaps between tiles using Pixi-Tilemap

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));
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.