draern
draern

Reputation: 339

How to get SCNTransaction end

I have a SKSpriteNode I use like a button. When I tap on it, it calls a function that moves the camera in a SCNScene

 SCNTransaction.begin()
 SCNTransaction.setAnimationDuration(2)

 SCNTransaction.setCompletionBlock {
        SCNTransaction.begin()
        SCNTransaction.setAnimationDuration(2)

        self.ResetCameraButton.texture = self.FunctionAtlas.textureNamed("ResetCameraSelected")

        self.cameraOrbit.eulerAngles.y = initialAngleY
        self.cameraOrbit.eulerAngles.x = initialAngleX
        self.cameraNode.camera?.orthographicScale = self.initialPinchScale

        SCNTransaction.commit()

            }
 SCNTransaction.commit()

This is the button: enter image description here and this is the tapped button: enter image description here

I would like to put the second image, as texture of my SKSpriteNode, during the animation and the first one, only when the animation ends.

If I add below:

self.ResetCameraButton.texture = self.FunctionAtlas.textureNamed("ResetCameraUnselected")

to set the Unselected texture, it doesn't work!

How can I get the end of the animation to set the 'unselected' texture to my SKSpriteNode?

Upvotes: 0

Views: 760

Answers (2)

Wil Shipley
Wil Shipley

Reputation: 9553

Check the documentation for SKAction.

Upvotes: 0

mnuages
mnuages

Reputation: 13462

SKNodes are part of SpriteKit which does not understand SCNTransaction. Only SceneKit APIs marked as "animatable" in the documentation can benefit from this feature.

Upvotes: 1

Related Questions