I can't found any about this on the SDK-Documentation..
How can i get the image from first frame on the sprite object/instance?
var inst= this._runtime.GetInstanceByUID(id); // Get the instance (sprite-object) // - Example - inst.getframe(0) // <--- how can i get the first frame from the sprite-object?
I have found this "old" code for construct 2 runtime.. but how it works in construct 3 runtime?
// This code gets the image from frame.. this.inst.cur_animation.frames[this.inst.cur_frame].texture_img
It's crazy.. i have looked into the runtime with chrome, and i found the imageInfo. In this i found the _imageAsset and then i see _blob (this is what i need!) .. but ..
inst._objectType._animations[0]._frames[0]._imageInfo
.. when i change my code to this..:
inst._objectType._animations[0]._frames[0]._imageInfo._imageAsset
.. the blob is null ?! Why?
Ashley , how can i get the first image/frame from a sprite-object in the sdk? (as blob)
Develop games in your browser. Powerful, performant & highly capable.
The blob is lazy loaded depending on various aspects of the export option, runtime settings, and memory management. What do you need it for exactly? There might be other methods that cover it.
For my next plugins. The first plugin convert the image from the sprite to base64 string.
I made a similar plugin.
here
https://github.com/erenertugrul/construct-plugins/tree/master/image_to_base64/c3
sprite_base64(obj) { var c = null; const e = obj.GetFirstPicked(); if (e) { const b = e.GetCurrentImageInfo(); b && b.ExtractImageToCanvas().then((b) => { c = b.toDataURL("image/png"); base64_link = c; //base64 link this.Trigger(C3.Plugins.erenertugrul_base64_image.Cnds.on_base64); }); } }
And why do you need to do that? base64 strings are less efficient than blobs.
> For my next plugins. The first plugin convert the image from the sprite to base64 string. And why do you need to do that? base64 strings are less efficient than blobs.
> For my next plugins. The first plugin convert the image from the sprite to base64 string.
Example: For shareAsync on fb instant games. This function need a base64 image.
developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.2
> For my next plugins. The first plugin convert the image from the sprite to base64 string. I made a similar plugin. here https://github.com/erenertugrul/construct-plugins/tree/master/image_to_base64/c3 > sprite_base64(obj) { var c = null; const e = obj.GetFirstPicked(); if (e) { const b = e.GetCurrentImageInfo(); b && b.ExtractImageToCanvas().then((b) => { c = b.toDataURL("image/png"); base64_link = c; //base64 link this.Trigger(C3.Plugins.erenertugrul_base64_image.Cnds.on_base64); }); } }
> sprite_base64(obj) { var c = null; const e = obj.GetFirstPicked(); if (e) { const b = e.GetCurrentImageInfo(); b && b.ExtractImageToCanvas().then((b) => { c = b.toDataURL("image/png"); base64_link = c; //base64 link this.Trigger(C3.Plugins.erenertugrul_base64_image.Cnds.on_base64); }); } }
Very useful, thank you! Why you don't post the plugins under addons on the construct page?