Jump to content

Setting collisions


Meitou
 Share

Recommended Posts

Hi everyone, I'm new to phaser. Currently, I'm working to create a MMORPG based game.

There are three questions I have. 

1: Setting Collisions. When I try to set collisions, I am able to set the collisions using the StaticTilemapLayer object returned from map.createStaticLayer. However, I am unable to create collisions using the Layer object returned from map.getLayer(SCENE_CONSTANTS.LAYER_OBJECTS). This forces me to store the variable of the objects layer in the context of the scope, something I don't want to do.

2: Unable to Layer.setCollisionByProperty({ collides: true });when using tiledMap. but am able to set collision using Layer.SetCollision. My tiled Map json object has 

         "height":20,
         "id":2,
         "name":"objects",
         "opacity":1,
         "properties":[
                {
                 "name":"collides",
                 "type":"bool",
                 "value":true
                }],
         "type":"tilelayer",
         "visible":true,
         "width":20,
         "x":0,
         "y":0
        }, 

3. When extending the Phaser Sprite Object. The character image is not loading unless i add it to the scene. The tutorial I was following, they simply added the sprite to the physics using the add method, but I am forced to add to the physics as well as the scene

 

class BaseCharacter extends Phaser.GameObjects.Sprite {
    constructor(scene, positionX, positionY, spriteImageKey) {
        super(scene, positionX, positionY, spriteImageKey);
        this.scene.physics.add.existing(this);
        this.scene.add.existing(this);
    }

}

 

currently following this tutorial: https://medium.com/@michaelwesthadley/modular-game-worlds-in-phaser-3-tilemaps-1-958fc7e6bbd6

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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