I need to know how to flip a sprite either on collide or inside of this patrol code… This is what we tried, it says that flipX is not defined…
// custom component controlling enemy patrol movement
export default function patrol(speed = 60, dir = 1) {
return {
id: "patrol",
require: [ "pos", "area", ],
add() {
this.enemy = this;
this.on("collide", (obj, col) => {
dir = -dir;
this.enemy.flipX = !this.enemy.flipX;
})
},
update() {
this.move(speed * dir, 0)
}
}
};