Closed NgVThangBz closed 11 months ago
reproduce steps and sample?
@halx99 , you can try that: save image to appdata and reload image
_spriteView = new Sprite; std::string fullPath = FileUtils::getInstance()->getWritablePath() + "checkImage.jpg"; utils::captureScreen([=](bool is, std::string_view name){ _spriteView->initWithFile(name); },fullPath);
Am I using the wrong api? I tried it on cocos2dx, and it seems to work fine
@NgVThangBz By your screenshots, you seem to be familiar with the debugger, so what is preventing you from stepping through the code to find out why it is not behaving as it should?
For instance, what is the value of name
that is passed into _spriteView->initWithFaile(name)
in the captureScreen
callback? Show what it actually is, and what you expect it to be. Do the same test on Cocos2d-x to find out what the difference is, and actually add this type of information in your posts. You can keep stepping through the code in the debugger until it goes through the FileUtils methods, and then you can see exactly what is happening in there; the code is relatively straightforward.
Providing vague or incomplete information, and with what appears to be little effort on your side, is not the best way to motivate others in helping you solve a problem.
@rh101 As I mentioned at the beginning, I debugged inside and found something wrong with TextureCache::addImage,
and I see _textures.find(fullpath);
cannot find, and in cocos it runs
@rh101 As I mentioned at the beginning, I debugged inside and found something wrong with
TextureCache::addImage,
and I see_textures.find(fullpath);
cannot find, and in cocos it runs
I understand, but you seem to have stopped short of stepping into the code that tries to load the file, and to see why it isn't working as you expect it to.
The engine code isn't a mystery, it's right there for all to see, and spending a few extra minutes stepping into it may help you find the answers you're looking for, or at the very least more insight into the issue that would allow you to provide more detailed information about any possible problem. That little bit of extra effort would save other people a significant amount of time in helping you solve issues like this.
I can't reproduce, more info?
@halx99, bạn có thể thử: lưu hình ảnh vào dữ liệu ứng dụng và tải lại hình ảnh
_spriteView = Sprite mới; std::string fullPath = FileUtils::getInstance()->getWritablePath() + "checkImage.jpg"; utils::captureScreen([=](bool is, std::string_view name){ _spriteView->initWithFile(name); },fullPath);
@halx99 you try that right?
yes, woked
yes, woked
sr,i check it agian this is my error, im set scaleY when _texture not yet init, Sorry for disturbing
Sprite::initWithFile
( path to appdata), not work if path in Content, it run fine, but if image in app data, it not can run.im check, in
Image::initWithImageData
, not can init, and i check in app data exist file image. (my code run good in cocos2dx 3.17) so please check it. save a image and load it