loadTexture 加载纹理
loadTexture
类型: MethodDeclaration
所属类: SceneTilemap
定义位置: scene.ts
描述
加载纹理
参数 tile
: 图块码
参数 sync
: 是否同步加载纹理
参数 callback
: 回调函数
参数
参数名 | 类型 | 描述 | 默认值 |
---|---|---|---|
tile | number | - | - |
callback | CallbackFunction | - | - |
返回值
类型: void
源代码
位置: 第 2849 行
private loadTexture(tile: number, callback?: CallbackFunction): void {
const tileData = this.tileData[tile & 0xffffff00]
if (tileData) {
let texture
switch (tileData.type) {
case 'normal': {
const guid = tileData.tileset.image
texture = this.textures[guid]
if (guid && texture === undefined) {
texture = GL.createImageTexture(guid, {magFilter: GL.NEAREST})
this.textures[guid] = texture
}
break
}
case 'auto': {
const guid = tileData.autoTile.image
texture = this.textures[guid]
if (guid && texture === undefined) {
texture = GL.createImageTexture(guid, {magFilter: GL.NEAREST})
this.textures[guid] = texture
}
break
}
}
if (callback) {
texture?.on('load', callback)
}
}
}
文档生成时间:2025/7/7 12:07:06