Fork from https://github.com/Joncom/impact-grid-movement
-
In your entity, make sure you require
'plugins.gridmovement'
-
Create instance of GridMovement():
this.movement = new GridMovement(this);
-
Add
this.movement.update()
to your entity update() method. -
Add
this.movement.collision()
to your entity check() method. -
Set entity movement speed like this:
this.movement.speed.x or .y
-
Set the movement direction like:
if (ig.input.state('left'))
this.movement.direction = GridMovement.moveType.LEFT;
else if (ig.input.state('right'))
this.movement.direction = GridMovement.moveType.RIGHT;
else if (ig.input.state('up'))
this.movement.direction = GridMovement.moveType.UP;
else if (ig.input.state('down'))
this.movement.direction = GridMovement.moveType.DOWN;
## License
Relesed under the WTFPL license: http://www.wtfpl.net/.