sharks

Members
  • Content count

    10
  • Joined

  • Last visited

About sharks

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Glad you figured it out
  2. Hey, it's me from the thread you referenced. I've added my code and added some comments for you var overlapObjects = this.map.getObjectLayer('Overlap')['objects']; //my Object layer was called Overlap let overlapObjectsGroup = this.game.physics.add.staticGroup({ }); let i = 0; overlapObjects.forEach(object => { let obj = overlapObjectsGroup.create(object.x, object.y, 'grass'); obj.setScale(object.width/32, object.height/32); //my tile size was 32 obj.setOrigin(0); //the positioning was off, and B3L7 mentioned the default was 0.5 obj.body.width = object.width; //body of the physics body obj.body.height = object.height; }); overlapObjectsGroup.refresh(); //physics body needs to refresh console.log(overlapObjectsGroup); this.game.physics.add.overlap(this.player, overlapObjectsGroup, this.test, null, this);
  3. sharks

    Overlapping on a Tilemap Object Layer

    That makes sense, you're a lifesaver! I'm unsure how to setOrigin on a layer created using `game.physics.add.group` as it's body so for now, hardcoding works.
  4. I asked a similar question - might be helpful
  5. sharks

    Overlapping on a Tilemap Object Layer

    Alright that was correct indeed regarding Tile ID. It's such a weird solution though, considering we may have any number of objects in a layer and we won't possibly know the IDs assigned to them. Right now, the overlap works. But the coordinates shown in Tiled for the object and the map are off. It's above where it should be on the map. I tried converting the coordinates using WorldToTileX/Y but didn't work. Any thoughts? For anyone who has the same question in the future, this is how a single large object in object layer can be scaled (minus the position offset issue) var overlapObjects = this.map.createFromObjects('Overlap', 2, { key: 'overlap_item' }); var ladders = this.game.physics.add.group({ key: 'ladders', setXY: { x: overlapObjects[0].x, y: overlapObjects[0].y }, setScale: { x: overlapObjects[0]._scaleX, y: overlapObjects[0]._scaleY } }); //obviously this needs to be looped as there might be multiple objects
  6. sharks

    Overlapping on a Tilemap Object Layer

    Thanks, that makes sense. When it says object ID 26, what does it mean? Could you please share a screenshot of it from tiled? And your object conversion method looks nice. I'll give it a try shortly.
  7. Hi guys, I have several layers on my map and I have an "Overlap" object layer which has a rectangle created around tiles. Now when the player (physics sprite) walks on it, I would like to trigger events. I'm unable to detect if the user is walking on it or not and would like some help. Thanks.
  8. sharks

    Creating & Switch Tilemaps dynamically

    You guys were absolutely correct. Stopping & Creating a scene works wonderfully and it's the solution I'm going with. Thanks!
  9. sharks

    Creating & Switch Tilemaps dynamically

    Alright, will give it a try tonight. Thanks. :)
  10. Hi guys, I've worked on a part of the system which loads multiple layers for a given tile map for a key "Map A" (All of them are static). Now at some time, I'd like to move the user to the next map with key "Map B". What's the best way to destroy a tilemap/layers and recreate the world? Thanks, S