Samarium
Ok I prepared steps to reproduce because unfortunately on the latest version it does not work for me.
- Install the latest version
- Add new file
characters/heroes/hero.png
- Add new file
characters/heroes/hero.ts
import { Spritesheet, Animation, Direction } from '@rpgjs/client'
function getFrameYForDirection(direction: Direction) {
switch (direction) {
case Direction.Up:
return 0;
case Direction.Down:
return 2;
case Direction.Left:
return 1;
case Direction.Right:
return 3;
}
}
const to = (direction: Direction, length: number) => {
const array: any = []
let k = 1
for (let i=0 ; i < length ; i++) {
array.push({ time: k * 3, frameX: i, frameY: getFrameYForDirection(direction) })
k++
}
return array
}
@Spritesheet({
framesWidth: 9,
framesHeight: 4,
width: 576,
height: 256,
rectWidth: 64,
rectHeight: 64,
spriteRealSize: {
width: 48,
height: 52,
},
textures: {
[Animation.Stand]: {
animations: direction => [[{ time: 0, frameX: 5, frameY: getFrameYForDirection(direction) }]],
},
[Animation.Walk]: {
animations: direction => [to(direction, 9)]
},
},
})
export default class Hero {}
I take only 576x256 pixels from the image
- Move
female.png
& characters.ts
to characters/npc/(female.png, characters.ts)
- Set any hitbox
Result:
Client console:
RpgClientEngine.ts:278 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'startsWith')
at RpgClientEngine.getResourceUrl (RpgClientEngine.ts:278:20)
at _initResource (Resources.ts:36:37)
at _initSpritesheet (Spritesheets.ts:7:12)
at RpgClientEngine.addResource (RpgClientEngine.ts:193:9)
at RpgClientEngine.addSpriteSheet (RpgClientEngine.ts:242:14)
at RpgClientEngine._init (RpgClientEngine.ts:169:14)
at async RpgClientEngine.start (RpgClientEngine.ts:303:9)
Then add id
& image
to hero.ts
id: 'hero',
image: './hero.png',
Result:
Also there are random exceptions in server console:
TypeError: Cannot read properties of undefined (reading 'boundingMap')
- AbstractObject.ts:601 ComponentManager.isCollided
[v6]/[@rpgjs]/common/src/AbstractObject.ts:601:46
- Player.ts:458 ComponentManager.teleport
[v6]/[@rpgjs]/server/src/Player/Player.ts:458:20
- Map.ts:251 SceneMap.changeMap
[v6]/[@rpgjs]/server/src/Scenes/Map.ts:251:26
- task_queues:95 processTicksAndRejections
node:internal/process/task_queues:95:5
- virtual-main-server.ts:27 __vite_ssr_import_2__.default.onConnected
/workspace/rpg/v6/virtual-main-server.ts:27:5
- async Promise.all
- Player.ts:808 ComponentManager.execMethod
[v6]/[@rpgjs]/server/src/Player/Player.ts:808:19
I don't know if it is related to the issue.
Changing the hitbox does not help.
I suppose that changing the hitbox is not synced to the Spritesheet (?) because my hero spritesheet is 64x64 and I assume that it is still treated as 16x16