-3

Changing a SKNodes SKTexture by

Node.texture = SKTexture(imagenamed: MyTexture)

isn't working, is there another way?

Whirlwind
  • 14,286
  • 11
  • 68
  • 157
  • 1
    You are asking the wrong question, it should be `How can I get Node.texture = SKTexture(imagenamed: MyTexture) to work?` Followed by the chunk of code in the description showing what you are doing wrong. Looking for a workaround instead of fixing your problems is going to hurt you in the long run. – Knight0fDragon Apr 18 '17 at 15:42
  • I agree with @Knight0fDragon what isn't working? nothing happens? errors? – Ron Myschuk Apr 18 '17 at 15:47
  • nothing happens – No.1 Cares Apr 18 '17 at 17:55
  • Possible duplicate of [Updating texture not working](http://stackoverflow.com/questions/37903386/updating-texture-not-working) – GTG101 Apr 18 '17 at 18:02
  • @No.1Cares What you stated in your question, is only true for your current setup, which is unknown, so nobody can give you a precise answer. Normally, assigning a new texture to a node's texture property works as it should. I can write a simple example for you to show you that it works... And if you upload relevant code, you can get more info about the issue. – Whirlwind Apr 18 '17 at 20:16

1 Answers1

1

I use this way:

let changeTexture = SKAction.animateWithTextures([page1], timePerFrame: 0.1)
bg.runAction(changeTexture)
Alessandro Ornano
  • 34,887
  • 11
  • 106
  • 133
GTG101
  • 149
  • 13
  • @No.1Cares It worked, but in your case this is just masking the current issue. It should work both way. Also, Alessandro's answer differs from what you did. The difference is in timing. By doing your way, the texture is applied immediately, and by doing `SKAction` way, you are delaying everything until the next frame ( actions are queued for the next frame for execution). – Whirlwind Apr 18 '17 at 20:18