Is there a tutorial available on how to do collisions with tile maps? I've tried adding an arcade boy 2d to it, setting it to tile map and putting in the number of the layers I want to collide with, but it didn't work. I have a arcade body 2d on the player actor as well. Here's my code:
class PlayerBehavior extends Sup.Behavior {
// Speed to move
speed: number = 1;
update() {
// Collide
Sup.ArcadePhysics2D.collides(this.actor.arcadeBody2D, Sup.getActor("Level").arcadeBody2D);
// Move up and down depending on key presses
if(Sup.Input.isKeyDown("W")) {
this.actor.arcadeBody2D.setVelocityY(1 * this.speed);
} else if(Sup.Input.isKeyDown("S")) {
this.actor.arcadeBody2D.setVelocityY(-1 * this.speed);
} else {
this.actor.arcadeBody2D.setVelocityY(0);
}
// Move left and right depending on key presses
if(Sup.Input.isKeyDown("A")) {
this.actor.arcadeBody2D.setVelocityX(-1 * this.speed);
} else if(Sup.Input.isKeyDown("D")) {
this.actor.arcadeBody2D.setVelocityX(1 * this.speed);
} else {
this.actor.arcadeBody2D.setVelocityX(0);
}
}
}
Sup.registerBehavior(PlayerBehavior);
(Sorry about the formatting)
Does anyone have any suggestions?