Hi guys,
Now I’m developing some game using cocos creator.
I think this engine so awesome.
But I don’t know how to get my goal.
First, I got a image data from server with base64 format and make up this with sprite with code.
like this.
getTextureFromString(imgString) {
const imgAsset = new ImageAsset(imgString);
const tex = new Texture2D();
tex.image = imgAsset;
return tex;
}
getSpriteFrameFromString(imgString) {
const spriteFrame = new SpriteFrame();
spriteFrame.texture = this.getTextureFromString(imgString);
return spriteFrame;
}
this works very fine but when I use this code I can’t use trim option.
When I use spriteframe located in inspector it shows trimx, trimy right.
But when I use base64 string to make sprite, it shows original size and trimmed size are same.
How can I get a trimmed size with code?
I think I can calculate “ISpriteFrameInitInfo” with code, But I can’t find how to do it.
I need some help
thank you