Sign in to follow this  
Meitou

Setting collisions

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

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.