feat(game): 添加动物精灵图像变体支持并优化揭示动画
- 引入 light-animal-sprite 图像资源和 variant 属性支持 - 在动物组件中实现正常和浅色精灵图像切换功能 - 重构桌面和移动版动物组件的揭示动画逻辑 - 移除冗余的运动偏好检测和布局效果钩子 - 调整揭示动画的时间参数和平滑度曲线 - 更新资源预加载配置以包含浅色动物图像 - 修改控制组件中的投注数量调整状态管理 - 优化脚本生成精灵图像的复用性
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { HTMLAttributes } from 'react'
|
||||
import animalSpriteUrl from '@/assets/animal/animal-sprite.webp'
|
||||
import lightAnimalSpriteUrl from '@/assets/light-animal/light-animal-sprite.webp'
|
||||
import {
|
||||
ANIMAL_SPRITE_CELL_ASPECT_RATIO,
|
||||
ANIMAL_SPRITE_COLUMNS,
|
||||
@@ -14,6 +15,7 @@ interface AnimalSpriteImageProps
|
||||
alt?: string
|
||||
fit?: 'cover' | 'fill'
|
||||
imageClassName?: string
|
||||
variant?: 'normal' | 'light'
|
||||
}
|
||||
|
||||
export function AnimalSpriteImage({
|
||||
@@ -23,9 +25,11 @@ export function AnimalSpriteImage({
|
||||
fit = 'fill',
|
||||
imageClassName,
|
||||
style,
|
||||
variant = 'normal',
|
||||
...props
|
||||
}: AnimalSpriteImageProps) {
|
||||
const position = getAnimalSpritePosition(animalId)
|
||||
const spriteUrl = variant === 'light' ? lightAnimalSpriteUrl : animalSpriteUrl
|
||||
const accessibilityProps = alt
|
||||
? ({ 'aria-label': alt, role: 'img' } as const)
|
||||
: ({ 'aria-hidden': 'true' } as const)
|
||||
@@ -50,7 +54,7 @@ export function AnimalSpriteImage({
|
||||
style={{
|
||||
aspectRatio:
|
||||
fit === 'cover' ? ANIMAL_SPRITE_CELL_ASPECT_RATIO : undefined,
|
||||
backgroundImage: `url(${animalSpriteUrl})`,
|
||||
backgroundImage: `url(${spriteUrl})`,
|
||||
backgroundPosition: `${position.xPercent}% ${position.yPercent}%`,
|
||||
backgroundSize: `${ANIMAL_SPRITE_COLUMNS * 100}% ${ANIMAL_SPRITE_ROWS * 100}%`,
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user