跳到主要内容

setSprite 设置角色的精灵图

setSprite

类型: MethodDeclaration

所属类: AnimationManager

定义位置: actor.ts

描述

设置角色的精灵图

参数 key: 动画键

参数 spriteId: 精灵图ID

参数 imageId: 图像文件ID

参数

参数名类型描述默认值
keystring--
spriteIdstring--
imageIdstring--

返回值

类型: void

源代码

位置: 第 2824 行

public setSprite(key: string, spriteId: string, imageId: string): void {
const animation = this.keyMap[key]
if (animation && spriteId) {
// 创建优先精灵图像映射表
if (!animation.priorityImages) {
animation.priorityImages = {}
animation.setSpriteImages(animation.priorityImages)
}
// 修改角色精灵表中的键值
animation.priorityImages[spriteId] = imageId
// 如果角色动画已经加载了同名纹理,则删除
animation?.deleteTexture(spriteId)
}
}

文档生成时间:2025/7/7 12:07:06