iOS Question return bitmap from sknode?

ilan

Expert
Licensed User
Longtime User
hi

i want to return a bitmap (UIimage) from an sknode with all his childrens.

i found this:

B4X:
CGRect bounds = self.scene.view.bounds;
UIGraphicsBeginImageContextWithOptions(bounds.size, NO, [UIScreen mainScreen].scale);
[self drawViewHierarchyInRect:bounds afterScreenUpdates:YES];
UIImage* screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

https://stackoverflow.com/questions/20625378/how-to-render-a-sknode-to-uiimage

how could i use this in b4i?

thank you
 

ilan

Expert
Licensed User
Longtime User
SpriteKit has no built-in method for this.

actually, there is a function (as far as i understand it)

B4X:
Dim bmp As Bitmap = GameScene.View.TextureFromNode(sknode).Image

the problem is that i am getting an error:

Application_Start
Ignoring release logger in debug mode.
<Google> To get test ads on this device, call: request.testDevices = @[ kGADSimulatorID ];
Application_Active
<Google:HTML> You are currently using version 7.21.0 of the SDK. Please consider updating your SDK to the most recent SDK version to get the latest features and bug fixes. The latest SDK can be downloaded from http://goo.gl/iGzfsP. A full list of release notes is available at https://developers.google.com/admob/ios/rel-notes.
failed: Error Domain=com.google.ads Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show., NSLocalizedFailureReason=Request Error: No ad to show.}
true
<Google:HTML> You are currently using version 7.21.0 of the SDK. Please consider updating your SDK to the most recent SDK version to get the latest features and bug fixes. The latest SDK can be downloaded from http://goo.gl/iGzfsP. A full list of release notes is available at https://developers.google.com/admob/ios/rel-notes.
true
Error occurred on line: 950 (Main)
Expected: UIImage, object type: __NSCFType
Stack Trace: (
CoreFoundation __exceptionPreprocess + 189
libobjc.A.dylib objc_exception_throw + 49
CoreFoundation +[NSException raise:format:] + 104
Ballz Shooter -[B4IObjectWrapper setObject:] + 292
Ballz Shooter -[STexture Image] + 155
CoreFoundation __invoking___ + 29
CoreFoundation -[NSInvocation invoke] + 321
Ballz Shooter +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1842
Ballz Shooter -[B4IShell runMethod:] + 525
Ballz Shooter -[B4IShell raiseEventImpl:method:args::] + 1881
Ballz Shooter -[B4IShellBI raiseEvent:event:params:] + 1915
Ballz Shooter -[B4IDebugResumableSub resume::] + 341
Ballz Shooter __21-[B4ICommon Sleep:::]_block_invoke + 65
libdispatch.dylib _dispatch_client_callout + 14
libdispatch.dylib _dispatch_continuation_pop + 535
libdispatch.dylib _dispatch_source_latch_and_call + 212
libdispatch.dylib _dispatch_source_invoke + 1159
libdispatch.dylib _dispatch_main_queue_callback_4CF + 653
CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
CoreFoundation __CFRunLoopRun + 2445
CoreFoundation CFRunLoopRunSpecific + 372
CoreFoundation CFRunLoopRunInMode + 123
GraphicsServices GSEventRunModal + 71
GraphicsServices GSEventRun + 80
UIKit UIApplicationMain + 148
Ballz Shooter main + 140
libdyld.dylib start + 1
??? 0x0 + 1
)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Hi,

this method will only return a value if you have set a texture before to the node. However, it will not return a rendered image with all the node's children.

Jan

ohhh ok i misunderstood it then :) (was too good to be true :p)
 
Upvote 0
Top