Jump to content

Position of extended matter sprites


Reicher
 Share

Recommended Posts

I’m trying to make a game with a rocket ship navigating in a cave. The cave is broken up into 400x400 big tiles that’s combined to form a bigger cave. They all have physics-maps from “PhysicsEditor” that seems to work correctly.

My tileclass:

export default class Tile extends Phaser.Physics.Matter.Sprite  {
constructor(scene, x, y, sprite, phymap) {
    super(scene.matter.world, x, y, sprite, 0, {
        shape: phymap
    });

    this.setStatic(true);
    this.setBounce(0.05);
    scene.add.existing(this);
    }
}

And these are added in game.js:

tilemap[1][0] = new Tile(this, 0, 0, 'ground', tile_body.ground)
tilemap[0][0] = new Tile(this, -400, 0, 'bottom-left', tile_body.bottom_left)
tilemap[0][1] = new Tile(this, -400, -400, 'vertical', tile_body.vertical)

But the tiles are all over the place, if I set them all on position (0, 0) you can see it more clearly:

image

Any ideas to what I am doing wrong? I thought all would be on top of each other if created at position (0, 0) with the same height and width?

Edited by Reicher
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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