1

I would like to be able to write pixels to the image of an SKSprite in iOS7. How do I do this?

Applications? Graphing for example. Random images. Applying damage effects perhaps to a sprite.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Neo42
  • 642
  • 3
  • 10
  • 31

2 Answers2

2

You can't directly write to an SKSpriteNode's pixel data in iOS 7. (This is called out explicitly in Apple's WWDC 2013 videos about sprite kit, which I highly recommend.) The only thing you can do is to change its texture member. The Apple docs on sprites give a variety of techniques to do that.

If you really need to programmatically create an image, you can always do so with a pixel buffer and then make it into an SKTexture with textureWithData:size: and related methods. For explosions and damage effects, though, there are probably better ways to do this, such as particle systems or masking out or combining the underlying sprite with other sprites.

Jesse Rusak
  • 56,530
  • 12
  • 101
  • 102
-1

How to draw a line in Sprite-kit

I didn't know you could draw lines and such directly onto nodes or scenes. This works for my purposes.

Community
  • 1
  • 1
Neo42
  • 642
  • 3
  • 10
  • 31