Aquarius Posted March 6, 2017 Share Posted March 6, 2017 Hi everyone, I am using arcade physics and my collisions are definer by a Tiled layer. this.collisionLayer = collisionLayer; this.map.setCollisionByExclusion([], true, this.collisionLayer); I have a sprite attached to my cursor, but it seems that (in update) if (this.phaserGame.physics.arcade.collide(this.marker, this.collisionLayer)) { console.log('hey, cursor is over collide area !!'); } won't work because Phaser check if a Sprite is gonna collide, not if it's actually colliding. What I simply need is to know if my marker (or directly my input.activePointer) is colliding. Any clues ? EDIT : Actually : when updating marker position, I get the tile below my cursor. If there is a tile AND his property 'canCollide' is set to true, I did not update marker position. private setMarker() { let marker: Phaser.Sprite = this.marker, tilePointBelowPointer: Phaser.Point = this.pointToTilePosition(); // get tile coordinate below activePointer let tileBelowPointer: Phaser.Tile = this.map.getTileWorldXY(tilePointBelowPointer.x, tilePointBelowPointer.y, 16, 16, this.collisionLayer); if (tileBelowPointer && tileBelowPointer.canCollide) { // do something if you want } else { marker.x = tilePointBelowPointer.x; marker.y = tilePointBelowPointer.y; } } Link to comment Share on other sites More sharing options...
Recommended Posts