Flozzel Posted March 6, 2019 Share Posted March 6, 2019 I have this map created in Tiled, with an object layer for the doors. And this door object has a custom property "link", which should tell where the door goes. In phaser, I created an object layer for this doors and put them in to a new static group (this.physics.add.staticGroup). And if the player hits this door object, a method get called: this.physics.add.overlap( this.player, doors, this.enterDoor , null, this ). And there, in the enterDoor method, I want to read the "link" property, so I can switch the scene based on that value, which tells where to go next. But I am not able to get it there, it not seems to be possible to even add this value to the childs of the group, because already there, these values get lost. I am looking for a solution to this problem. These are the parts of the relevant code: Part 1, colliding with the door works without problems. Only thing there is, I have a missing sprite picture in game, but I do not want to use any sprite for the door. It should be a invisible area and if the player hits, it should go to the next scene. create() { this.map = this.add.tilemap( 'map1' ); var tileset = this.map.addTilesetImage( 'main', 'tiles' ); this.firstLayer = this.map.createStaticLayer( 'layer1', tileset ); this.secondLayer = this.map.createStaticLayer( 'layer2', tileset ); this.thirdLayer = this.map.createStaticLayer( 'layer3', tileset ); this.createPlayer( 400, 400 ); this.secondLayer.setCollisionBetween( 1, 2000 ); this.physics.add.collider( this.player, this.secondLayer); this.objectLayer = this.map.getObjectLayer( 'objectLayer' ); var doors; this.objectLayer.objects.forEach( ( object, index ) => { if (object.type === 'door') { object.key = object.name; object.setXY = { x: object.x + 16, y: object.y + 16 }; doors = this.physics.add.staticGroup( object ); //doors[ index ].set( 'link', object.link ); } }); this.physics.add.overlap( this.player, doors, this.enterDoor , null, this ); } Part 2, this is the enterDoor Method, called if the player hits the door. There I want to read the door.link property and based on that, go to the next scene. enterDoor( player, door ) { console.log( door.link ); //undefined door.disableBody( true, true) ; this.scene.switch( 'Outside', Outside ); // it should be like this: // this.scene.switch( door.link, door.link ); } Link to comment Share on other sites More sharing options...
Flozzel Posted March 27, 2019 Author Share Posted March 27, 2019 Pushing thread. Anyone who could help me with this? Link to comment Share on other sites More sharing options...
Lucius Posted August 12, 2019 Share Posted August 12, 2019 Any luck with this? I have the exact same question. Link to comment Share on other sites More sharing options...
msanatan Posted May 29, 2020 Share Posted May 29, 2020 I had the same issue and posted the location of the custom properties here if anyone is still interested Note that I found it in the `data` property with the current Phaser version, 3.23. I'm not sure if it was always set in earlier iterations of Phaser 3. Link to comment Share on other sites More sharing options...
Recommended Posts