Hello, I hope you are well.
I am trying to create a style of projectile that is fired from the player's position to where they are facing.
I have tried creating an event dynamically but what has not worked for me is to show the animation of the sprite.
I attach my code:
import { RpgEvent, EventData, RpgPlayer, EventMode } from '@rpgjs/server'
@EventData({
name: 'EV-proyectil',
mode : EventMode.Shared,
hitbox: {
width: 96,
height: 96
},
})
export class proyectil extends RpgEvent {
onInit() {
this.setGraphic("proyectil_animation")
//this.showAnimation('base', 'default')
}
async onAction(player: RpgPlayer) {
}
}
in player.ts (onInput):
map.createDynamicEvent({
x: player.position.x,
y: player.position.y,
event: proyectil
})`
sprite:
import { Spritesheet } from '@rpgjs/client'
import { RMSpritesheet } from '@rpgjs/client/lib/Presets/AnimationSpritesheet';
@Spritesheet({
id: 'proyectil_animation',
image: require('./assets/animation.png'),
width: 96,
height: 96,
})
export class proyectil{}