Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.82k stars 821 forks source link

texture.root.onRestore doesn't work #1040

Closed subdan closed 5 years ago

subdan commented 5 years ago

Hello, Daniel.

How can I manually restore a texture after context loss? I tried to use: texture.root.onRestore = function():void { }

but the onRestore function doesn't fire on context loss. I get invalid bitmap data error.

In my app I use default CameraUI to capture an image. After the image is ready I create a Texture.

var texture:Texture = Texture.fromBitmapData(bitmapData, false, false, Starling.current.contentScaleFactor); And show this image with Image.

How to handle context loss to restore captured image after context restoration?

PrimaryFeather commented 5 years ago

That should work, actually — there haven't been any changes in this area lately. Do you have a complete sample that I could use to reproduce your problem? Maybe it's a specific setup I didn't think about. Also, have a look at this this section in the Starling Manual.

subdan commented 5 years ago

Ok. I will check it again and get back to you within next week.

subdan commented 5 years ago

Checked again. All is ok.

PrimaryFeather commented 5 years ago

I'm glad to hear it's working! Thanks for checking again. :smile: