Swift: how to handle a lot of texture in memory

There are many characters in my game, and because of this I have so many textures. When a texture atlas (containing about 5 different image textures) is loaded, it increases memory usage and holds it there in that total. Thus, the more textures just keep that number up, and so on until the application works. I don’t need all the characters at once, how can I load character textures when I need them, and free others when I don’t, but I need to be able to get them back.

+3
source share
1 answer

Rule 1

.

let sprite = SKSpriteNode(imageNamed: "Dog")

SpriteKit Dog, , .

, .

.

2

. , "" , .

?

, .

30 , , 1... 10 11... 20 21... 30, 3 , :

  • TextureAtlas1: 1 10
  • TextureAtlas2: 11 20
  • TextureAtlas3: 21 30

SpriteKit .

+4

Source: https://habr.com/ru/post/1650985/


All Articles