1

I wanted to extract each of the sprites in the following sprite sheet. Provided with the key-value of sprite origin points in the sheet. each sprite into its own SKSpriteNode object I think through using SKTexture somehow enter image description here

{
            CACTUS_LARGE: { x: 652, y: 2 },
            CACTUS_SMALL: { x: 446, y: 2 },
            CLOUD: { x: 166, y: 2 },
            HORIZON: { x: 2, y: 104 },
            MOON: { x: 954, y: 2 },
            PTERODACTYL: { x: 260, y: 2 },
            RESTART: { x: 2, y: 2 },
            TEXT_SPRITE: { x: 1294, y: 2 },
            TREX: { x: 1678, y: 2 },
            STAR: { x: 1276, y: 2 }
        }
Mohamed DiaaEldin
  • 1,061
  • 1
  • 10
  • 23
  • 2
    https://stackoverflow.com/a/28050732/4376309 This post discusses how to extract sprites out of a sprite sheet if they are evenly-spaced. Your sheet is not evenly spaced, but it is quite small. I would manually split them into individual images using any image editing program. Then you can create a new sprite atlas in Xcode, like so: https://stackoverflow.com/a/32635961/4376309 – peacetype Dec 31 '17 at 03:44
  • 1
    since you have the coordinates, you can infer size (I am assuming you have 2 pixel padding) so all you need to do is slap that into 1 SKTexture, then use `SKTexture(rect:CGRect, in:SKTexture)` to extract the SKTextures you want. If nobody provides an answer for you with this info, then tag me later on tomorrow and I will try to whip up a real answer for you. I would do it now but it is going to be a lot of work to write up a nice answer for you. – Knight0fDragon Jan 04 '18 at 14:25
  • Can you test it as it did not work for me SKTexture(rect:CGRect, in:SKTexture) – Mohamed DiaaEldin Jan 04 '18 at 14:52

0 Answers0