Седлается она автоматически когда прыгаешь на неё сверху, а чтобы слезть нужно провести любую атаку
Для этого я изменил контроллер моли:
import crownComp from "./crownComp.js"
export default function controllerComp(joystick) {
let crown = null
return {
id: "controllerComp",
require: ["pos"],
attackSpeed: 1000,
defaultSpeed: 200,
speed: 200,
onCrown: false,
add() {
this.onGround(() => {
if (this.curPlatform() != null &&
this.curPlatform().is("crown") &&
!this.curPlatform().isDead) {
crown = this.curPlatform()
this.pos.x = crown.pos.x
crown.unuse("crownComp")
this.onCrown = true
}
})
this.onFall(() => {
this.onCrown = false
if (crown != null && !crown.isDead
&& !crown.is("crownComp")) {
debug.log(crown.isDead)
crown.use(crownComp(this))
}
})
joystick.on("action", () => {
this.onCrown = false
if (crown != null && !crown.isDead
&& !crown.is("crownComp")) {
debug.log(crown.isDead)
crown.use(crownComp(this))
}
})
},
update() {
if (this.onCrown) {
crown.move(joystick.direction.scale(this.speed*1.5))
crown.flipX = this.flipX
this.pos.x = crown.pos.x
}
else {
this.move(joystick.direction.scale(this.speed))
}
if (joystick.direction.x)
this.flipX = joystick.direction.x < 0
},
}
}