跳到主要内容

loadTexture 加载纹理

loadTexture

类型: MethodDeclaration

所属类: SceneTilemap

定义位置: scene.ts

描述

加载纹理

参数 tile: 图块码

参数 sync: 是否同步加载纹理

参数 callback: 回调函数

参数

参数名类型描述默认值
tilenumber--
callbackCallbackFunction--

返回值

类型: 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