3.X 加载不到图集

import { _decorator, Component, Node, resources, Sprite, SpriteAtlas } from ‘cc’;

const { ccclass, property } = _decorator;

@ccclass(‘Test’)

export class Test extends Component {

@property({type: Sprite})

private sprite: Sprite = null;

start()

{

  // 加载 SpriteAtlas(图集),并且获取其中的一个 SpriteFrame

  // 注意 atlas 资源文件(plist)通常会和一个同名的图片文件(png)放在一个目录下, 所以需要在第二个参数指定资源类型

  resources.load("item/item", SpriteAtlas, (err, item) => {

    let frame = item.getSpriteFrame('000000');

    this.node.getComponent(Sprite).spriteFrame = frame;

  });

}

}

图集目录截图Images_1646842605972

是不是要加后缀名

查一下导出图集格式问题。

需要在 plist 文件里面,sprite 的 key 需要加上 .png

参考一下 这个帖子 3.4版本中图集资源加载问题

非常感谢 按你的回答 已经读取到了

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。