get imageName of texture

Hi,


I need to get the name of a current SKSpriteNode texture and I can not find how to access.


My code:

let push:String = cyanNode.description // Fail
            if(push == "cyanSelect" ){
                cyanNode.texture = SKTexture(imageNamed: "cyan")
            }else{
                cyanNode.texture = SKTexture(imageNamed: "cyanSelect")
            }


Could you help me?



Thanks.

Accepted Reply

Looking and asking for other sides, I have been told that there is no possibility to return the name of the textured image.


So I will solve it with an array to know if it is active or not.


Thanks.

Replies

The image name isn't kept with the texture. The texture is created from an image, but is a different kind of thing.


You will have to associate the original name with the texture in some indirect way. For example, you can put the texture image name in the node's userInfo dictionary, or subclass the node. (You might be able to subclass or extend SKTexture. Not sure if that is going to work.) Or you can just store it in a separate property, such as "cyanNodeTextureName".

Seen this (dated) SO thread?


http://stackoverflow.com/questions/21698512/sktexture-get-image-name

Looking and asking for other sides, I have been told that there is no possibility to return the name of the textured image.


So I will solve it with an array to know if it is active or not.


Thanks.