简体   繁体   中英

Animations of SpriteKit overlay on SceneKit stops when SceneKit animations stop

I guess someone must have asked this before, but I can't find it right now so in the meanwhile here goes.

Animations of SpriteKit overlay on SceneKit stops when SceneKit animations stop. This is unexpected. It's like the whole SCNView and its children goes into sleep as soon as the 3D contents don't move. How can I make the spritekit scene animate independently of what the scenekit scene does? Update: I have confirmed that if I add a simple 3D box that rotates indefinitely and keep it in the view somewhere, the 3D scene does not "sleep" and neither does the overlay. Is there a setting somewhere to stop the SceneKit part from sleeping?

Background: I use SCNView.overlaySKScene . I have a indefinitely repeating animation of one of the subnodes of that overlay. As soon as an action and/or animation goes on in the SceneKit scene, the overlay 2D stuff also animates, but stops as soon as the 3D animations stop.

iOS 9.2.1.

A SceneKit view runs its update/render loop only when it knows there's animation going on. (Because if there's no change in what's to be rendered, rendering just wastes CPU/GPU time and eats up battery power.)

SceneKit is rather conservative in guessing when it should run the render loop. It runs if there are CAAnimation s or SCNAction s in the scene or if the physics engine is doing something, but I think that's about it.

If you've got other stuff that wants to run the render loop (like an overlay SKScene that needs to run its own game loop), just set the view's playing property to true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM