Comments (1)
I managed to solve my problem
I used this code from tiled as reference
I dont know if it breaks while scale/rotate objects in tiled, but if works for me)
const tilemap = this.add.tilemap(Timemaps.test);
const tileWidth = tilemap.tileWidth;
const halfTileWidth = tileWidth * 0.5;
const tileHeight = tilemap.tileHeight;
const originX = tilemap.height * tileWidth * 0.5;
const tile_grass = tilemap.addTilesetImage('tile_grass', Images.tile_grass)!;
const layer = tilemap.createLayer('Tile Layer 1', tile_grass)!;
//! Layer position fix
const tilemapWidth = tilemap.widthInPixels;
const halfTilemapWidth = tilemapWidth * 0.5;
layer.setPosition(halfTilemapWidth - halfTileWidth, 0);
const objects = tilemap.objects[0].objects;
for (let i = 0; i < objects.length; i++) {
//! Ref: https://github.com/mapeditor/tiled/blob/12ca7077d3d5cd9655929030092681a986dd749a/src/libtiled/isometricrenderer.cpp#L495-L505
const object = objects[i];
const tileY = object.y! / tileHeight;
const tileX = object.x! / tileHeight;
const x = (tileX - tileY) * tileWidth * 0.5 + originX;
const y = (tileX + tileY) * tileHeight * 0.5;
const sprite = this.add.sprite(x, y, (Images as any)[object.name]);
sprite.setOrigin(0.5, 1);
}
About "Layer position fix" part, layer getBounds doesn't match its rendered position
layer.setInteractive();
this.input.enableDebug(layer, 0);
from phaser.
Related Issues (20)
- A project launched using the Vue3 template, I don't know why it keeps repeatedly rendering the DOM HOT 1
- `getPipelineName()` errors with the Canvas renderer
- scene plugin install failure HOT 4
- Nineslice objects
- Nineslice object bug
- Inconsistent Versioning and the Case for Adopting SemVer HOT 2
- Creating a dynamic texture from an image with preFX has wrong dimensions and coordinates HOT 1
- BitmapText setMaxWidth() bug
- Angle and rotation animations with tweens and scene update are smoother in 3.60 than 3.80 HOT 4
- Camera shaking HOT 1
- ConicGradient feature is very important HOT 1
- Meshes are missing parts when multiple batches are needed to render scene
- DomElement position is not kept correctly in the scene when a camera zooms out HOT 1
- [Input] disableInteractive() with NOT topOnly case
- SceneManager.getScene has wrong return type in ts definition
- Tilemap support for spacing and/or margin broken since 3.80 HOT 2
- Lottie / Vector based Animation Support
- Please add support for planck.js, Matter is a terrible thing
- Phaser sounds/music stop playing in the new iOS 17.5.1 after losing/gaining focus in safari
- In TPhaser3.9 rectangle is err
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phaser.