Reicher

Position of extended matter sprites

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

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.