Collision without physics

I have a sprite controlled by the player with CursorKeys (top, bottom, left, right)

I integrated a collision without physics between my sprite and a zone with Phaser.Geom.Intersects.LineToRectangle() because I am testing each side of my sprite for collision.

It works fine, but if the right bound of my sprite collides with the zone, I can’t move my sprite up and down because the last point of the bound up and bound down also collides with the zone…

How can I do ?

sample here :

function() update {


 let leftBound = sprite.getBounds().getLineD();
 let rightBound = sprite.getBounds().getLineB();
 let upBound = sprite.getBounds().getLineA();
 let downBound = sprite.getBounds().getLineC();

 let leftIntersect = Phaser.Geom.Intersects.LineToRectangle(leftBound,;
 let rightIntersect = Phaser.Geom.Intersects.LineToRectangle(rightBound,;
 let upIntersect = Phaser.Geom.Intersects.LineToRectangle(upBound,;
 let downIntersect = Phaser.Geom.Intersects.LineToRectangle(downBound,;

 if (cursors.left.isDown && leftIntersect == false) {
        sprite.x -= SPEED;'walk',true);
 } else if (cursors.right.isDown && rightIntersect == false) {
        sprite.x += SPEED;'walk',true);
 } else if (cursors.up.isDown && upIntersect == false) {
        sprite.y += -SPEED;'walk',true);
 } else if(cursors.down.isDown && downIntersect == false) {
        sprite.y += SPEED;'walk',true);
 } else {'idle');


Hello, I don’t know but just a random idea here ttrying to help…
What about using rectangles wrapping the sprite where the size should be the SPEED I guess?

let leftBound = new Phaser.Geom.Rectangle(sprite.x - SPEED, sprite.y, SPEED, sprite.height);

then check RectangleToRectangle instead…

let leftIntersect = Phaser.Geom.Intersects.RectangleToRectangle(leftBound, zone.getBounds());

Adjusting something similar to: