I am developing a game on SpriteKit and have several scenes, each of which has From 3 TextureAtlas to Minimum and maximum image size in each texture. my game crashes from memory problem
what I do in each scene is the definition of the action in the header file for an example:
initialise them in -(id)initWithSize:(CGSize)size Function @interface FirstLevel : SKScene { SKAction *RedBirdAnimation; }
and in the implementation file:
-(id)initWithSize:(CGSize)size{ if(self=[super initWithSize:size]) {[self setupRedBirdActions];} return self; } -(void)setupRedBirdActions{ SKTextureAtlas *RedBirdAtlas = [SKTextureAtlas atlasNamed:@"RedBird"]; SKTexture *RedBird1 = [RedBirdAtlas textureNamed:@"Redbird_01_iphone.png"]; SKTexture *RedBird2 = [RedBirdAtlas textureNamed:@"Redbird_02_iphone.png"]; SKTexture *RedBird3 = [RedBirdAtlas textureNamed:@"Redbird_03_iphone.png"]; NSArray *atlasTexture = @[RedBird1, RedBird2, RedBird3]; SKAction* atlasAnimation = [SKAction animateWithTextures:atlasTexture timePerFrame:0.2]; RedBirdAnimation = atlasAnimation;}
there is something like best practice for loading Atlas textures in my game to prevent it from crashing due to memory.
I do all SkAction with Nil at the end of each skzen and remove all actions from All SkSpriteNode
is there any solution
source share