Jump to content

Turn code. Help


polansk1
 Share

Recommended Posts

I found that code but it's in Phaser2 and don't know what i have to change to work in Phaser3... if anyone can help me :) it's really important for my game! 

 

this.marker.x = this.math.snapToFloor(Math.floor(this.car.x), 32) / 32;
this.marker.y = this.math.snapToFloor(Math.floor(this.car.y), 32) / 32;

var i = this.layer.index;
var x = this.marker.x;
var y = this.marker.y;

this.directions[Phaser.LEFT] = this.map.getTileLeft(i, x, y);
this.directions[Phaser.RIGHT] = this.map.getTileRight(i, x, y);
this.directions[Phaser.UP] = this.map.getTileAbove(i, x, y);
this.directions[Phaser.DOWN] = this.map.getTileBelow(i, x, y);

 

if (this.current === this.opposites[turnTo])
{
    this.move(turnTo);
}
else
{
    this.turning = turnTo;

    this.turnPoint.x = (this.marker.x * this.gridsize) + (this.gridsize / 2);
    this.turnPoint.y = (this.marker.y * this.gridsize) + (this.gridsize / 2);
}

 

this.math.fuzzyEqual(a, b, threshold)

 

this.car.x = this.turnPoint.x;
this.car.y = this.turnPoint.y;

this.car.body.reset(this.turnPoint.x, this.turnPoint.y);

this.move(this.turning);

this.turning = Phaser.NONE;
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...