forked from noxious/client
Use originX and Y for hair
This commit is contained in:
parent
8005bc1318
commit
0e455f8ffc
@ -28,13 +28,22 @@ const texture = computed(() => {
|
|||||||
|
|
||||||
const isFlippedX = computed(() => [6, 4].includes(props.zoneCharacter.character.rotation ?? 0))
|
const isFlippedX = computed(() => [6, 4].includes(props.zoneCharacter.character.rotation ?? 0))
|
||||||
|
|
||||||
const imageProps = computed(() => ({
|
const imageProps = computed(() => {
|
||||||
depth: 1,
|
// Get the current sprite action based on direction
|
||||||
originY: [0, 6].includes(props.zoneCharacter.character.rotation ?? 0) ? 4.33 : 5.33,
|
const direction = [0, 6].includes(props.zoneCharacter.character.rotation ?? 0) ? 'back' : 'front'
|
||||||
flipX: isFlippedX.value,
|
const spriteAction = props.zoneCharacter.character.characterHair?.sprite?.spriteActions?.find(
|
||||||
texture: texture.value,
|
spriteAction => spriteAction.action === direction
|
||||||
y: props.zoneCharacter.isMoving ? Math.floor(Date.now() / 250) % 2 : 0
|
)
|
||||||
}))
|
|
||||||
|
return {
|
||||||
|
depth: 1,
|
||||||
|
originX: spriteAction?.originX ?? 0,
|
||||||
|
originY: spriteAction?.originY ?? 0,
|
||||||
|
flipX: isFlippedX.value,
|
||||||
|
texture: texture.value,
|
||||||
|
y: props.zoneCharacter.isMoving ? Math.floor(Date.now() / 250) % 2 : 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
loadSpriteTextures(scene, props.zoneCharacter.character.characterHair?.sprite as SpriteT)
|
loadSpriteTextures(scene, props.zoneCharacter.character.characterHair?.sprite as SpriteT)
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
|
@ -66,10 +66,13 @@ export async function loadSpriteTextures(scene: Phaser.Scene, sprite: Sprite) {
|
|||||||
data: sprite_action.data,
|
data: sprite_action.data,
|
||||||
group: sprite_action.isAnimated ? 'sprite_animations' : 'sprites',
|
group: sprite_action.isAnimated ? 'sprite_animations' : 'sprites',
|
||||||
updatedAt: sprite_action.updatedAt,
|
updatedAt: sprite_action.updatedAt,
|
||||||
frameCount: sprite_action.frameCount,
|
originX: sprite_action.originX ?? 0,
|
||||||
|
originY: sprite_action.originY ?? 0,
|
||||||
|
isAnimated: sprite_action.isAnimated,
|
||||||
frameWidth: sprite_action.frameWidth,
|
frameWidth: sprite_action.frameWidth,
|
||||||
frameHeight: sprite_action.frameHeight,
|
frameHeight: sprite_action.frameHeight,
|
||||||
frameRate: sprite_action.frameRate
|
frameRate: sprite_action.frameRate,
|
||||||
|
frameCount: sprite_action.frameCount
|
||||||
} as AssetDataT)
|
} as AssetDataT)
|
||||||
|
|
||||||
// If the sprite is not animated, skip
|
// If the sprite is not animated, skip
|
||||||
|
@ -47,7 +47,6 @@ export function tileToWorldY(layer: TilemapLayer | Tilemap, pos_x: number, pos_y
|
|||||||
export function placeTile(zone: Tilemap, layer: TilemapLayer, x: number, y: number, tileName: string) {
|
export function placeTile(zone: Tilemap, layer: TilemapLayer, x: number, y: number, tileName: string) {
|
||||||
let tileImg = zone.getTileset(tileName) as Tileset
|
let tileImg = zone.getTileset(tileName) as Tileset
|
||||||
if (!tileImg) {
|
if (!tileImg) {
|
||||||
console.log('tile not found:', tileName)
|
|
||||||
tileImg = zone.getTileset('blank_tile') as Tileset
|
tileImg = zone.getTileset('blank_tile') as Tileset
|
||||||
}
|
}
|
||||||
layer.putTileAt(tileImg.firstgid, x, y)
|
layer.putTileAt(tileImg.firstgid, x, y)
|
||||||
|
@ -25,7 +25,19 @@ export class AssetStorage {
|
|||||||
const blob = await response.blob()
|
const blob = await response.blob()
|
||||||
|
|
||||||
// Store the asset in the database
|
// Store the asset in the database
|
||||||
await this.db.table('assets').put({ key: asset.key, data: blob, group: asset.group, updatedAt: asset.updatedAt, frameCount: asset.frameCount, frameWidth: asset.frameWidth, frameHeight: asset.frameHeight })
|
await this.db.table('assets').put({
|
||||||
|
key: asset.key,
|
||||||
|
data: blob,
|
||||||
|
group: asset.group,
|
||||||
|
updatedAt: asset.updatedAt,
|
||||||
|
originX: asset.originX,
|
||||||
|
originY: asset.originY,
|
||||||
|
isAnimated: asset.isAnimated,
|
||||||
|
frameWidth: asset.frameWidth,
|
||||||
|
frameHeight: asset.frameHeight,
|
||||||
|
frameRate: asset.frameRate,
|
||||||
|
frameCount: asset.frameCount
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to add asset ${asset.key}:`, error)
|
console.error(`Failed to add asset ${asset.key}:`, error)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ export type AssetDataT = {
|
|||||||
data: string
|
data: string
|
||||||
group: 'tiles' | 'objects' | 'sprites' | 'sprite_animations' | 'sound' | 'music' | 'ui' | 'font' | 'other'
|
group: 'tiles' | 'objects' | 'sprites' | 'sprite_animations' | 'sound' | 'music' | 'ui' | 'font' | 'other'
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
|
originX?: number
|
||||||
|
originY?: number
|
||||||
isAnimated?: boolean
|
isAnimated?: boolean
|
||||||
frameCount?: number
|
frameCount?: number
|
||||||
frameWidth?: number
|
frameWidth?: number
|
||||||
|
Loading…
x
Reference in New Issue
Block a user