When you configured the client-side inputs, you must have added a key in this way:
import { Input } from '@rpgjs/client'
export const inputs = {
// here, others inputs
attack: {
bind: Input.F,
}
}
In src/modules/main/server/player.ts
:
import { RpgPlayer, RpgPlayerHooks } from '@rpgjs/server'
export const player: RpgPlayerHooks = {
onInput(player: RpgPlayer, { input }) {
if (input == 'attack') {
player.showAnimation('your_spritesheet_id', 'your_animation_id', true)
}
}
}
player.showAnimation()
https://docs.rpgjs.dev/commands/common.html#show-animation
If you don't want to put an animation on top of the event but replace the event graphic with another one, set true as last parameter. This is useful, if for example, you want to make an animated character (sword stroke when pressing a key) When the animation is finished, the original graphic is displayed again