Closed jestarray closed 9 months ago
Hey, I have a workaround in our project to fix this issue, we use Isometric and our tiles are oversized (256 192 compare to tile size 256 128) Note that the position of rotated tile is still a bit off because I have no idea where the anchor point of the tile image is in Tiled. So I chose (0.5, 0.5) as anchor point.
replace pipeline.batchTexture() in Phaser.Tilemaps.TilemapLayer.prototype.renderWebGL with:
pipeline.batchTexture(
src, //gameObject
texture, //texture
texture.width, texture.height, //textureWidth, textureHeight
// x + ((tw + tile.pixelX) * sx), y + ((th + tile.pixelY) * sy),
tile.pixelX + 0.5 * tile.baseWidth, tile.pixelY - (tile.height * 0.5 - tile.baseHeight),
tile.width, tile.height, // srcWidth, srcHeight,
sx, sy, //scaleX, scaleY,
tile.rotation, //rotation
tile.flipX, tile.flipY, //flipX, flipY,
scrollFactorX, scrollFactorY, //scrollFactorX, scrollFactorY,
// tw, th, //displayOriginX, displayOriginY,
tile.width * 0.5, tile.height * 0.5,
frameX, frameY, frameWidth, frameHeight, // frameX, frameY, frameWidth, frameHeight,
tint, tint, tint, tint, false, //tintTL, tintTR, tintBL, tintBR, tintEffect,
0, 0, //uOffset, vOffset,
camera, //camera
null, //parentTransformMatrix
true, //skipFlip
textureUnit //textureUnit
);
It seems most of the time the tiles should be aligned to bottom-left by default - I think its pretty common to have tiles of variable height where baseline always will be the bottom. Possibly an option to provide top alignment.
Interesting to know how others are dealing with this as it seems very common.
Pretty sure this was (finally) resolved via https://github.com/phaserjs/phaser/commit/d855fa73d33e28ee539f15df14de04a0e02ca711
The tilemap size is 32x32 and the ninja is a 32x64 sprite (imported in tiled as 32x64 also). In tiled I place it on the bottom left but when rendered in phaser, it is an index off.
mappy.json