Folder structure:
Main
-sounds
--index.ts
--assets
---theme.ogg
-maps
--maps.ts
Inside of index.ts use this code
import { Sound } from '@rpgjs/client'
@Sound({
sounds: {
town: require('./assets/theme.ogg'),
},
loop: true,
volume: 0.1
})
export default class Musics {}
Inside of maps.ts use this code
import { RpgPlayer } from '@rpgjs/server'
import { MapData, RpgMap } from '@rpgjs/server'
@MapData({
id: 'samplemap',
file: require('../worlds/maps/samplemap.tmx'),
name: 'theme',
sounds: ['theme'], // You can add several musics
})
export default class TownMap extends RpgMap {
onInit() {
console.log('Map loaded')
}
}
Seems like there is a bug with the sounds.index.ts file as it wont work for looping or volume, but the sound will work this way....