Closed qq461787436 closed 3 weeks ago
我在加载csb之前会调用addSpriteFramesWithFile提前把资源加载进来 测试了下,确实是提前addSpriteFramesWithFile加载后,打开csb文件会导致这个问题 SpriteFrameCache::getInstance()->addSpriteFramesWithFile(_FullPath, _Texture2D) 这样加载的
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(_FullPath, _Texture2D)调用这个加载plist时候不能填写完整路径,只能填写文件名才能正确与加载和使用,否则会出现上面情况
确实应该统一用 fullPath
获取Outlook for Androidhttps://aka.ms/AAb9ysg
From: Code @.> Sent: Friday, August 16, 2024 2:43:29 PM To: axmolengine/axmol @.> Cc: Subscribed @.***> Subject: Re: [axmolengine/axmol] 执行csb文件,打开界面慢 (Issue #2092)
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(_FullPath, _Texture2D)调用这个加载时候不能填写完整路径,填写plist文件名才能正确与加载,否则会出现上面情况
― Reply to this email directly, view it on GitHubhttps://github.com/axmolengine/axmol/issues/2092#issuecomment-2292918364, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABVHOJ5FI2MHKPW6MHAGJLDZRWNRDAVCNFSM6AAAAABMTO7EU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJSHEYTQMZWGQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>
调用的这个获取文件的完整路径ax::FileUtils::getInstance()->fullPathForFilename()
貌似addSpriteFramesWithFile传入完整路径,SpriteFrameCache的_spriteSheets的会把路径当key,当csb加载的时候是以文件名请求加载,_spriteSheets按这个文件名查找,结果没有找到对应的对象就重新加载了!
嗯,目前实现内部不会转换路径,也就是说外部需要保证加载某个 plist 路径形式一致性
看了下原 cocos2dx 也不会强制以 fullPath 作为 key
嗯,cocos那边我是主线程加载直接传文件名的,所以一直没发现还这个需要注意这个,现在升级成axmol引擎我改成了多线程资源加载,加载完成后用完整路径进行添加了,才导致这样的情况,现在直接改成文件名了,完美解决!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.