Thursday, 15 March 2012

sprite kit - SpriteKit SKTexture.preloadTextures high memory usage Swift -


I have STKActual with about 90 png images. Each image has a resolution of 2000 x 70 pixels and has a size of ~ 1kb.

Now I have inserted this image from the Errata in an array like this:

  Var dropBarAtlas = SKTtextureAtlas (named: "DropBar") for 0 . In & lt; DropBarAtlas.textureNames count {var textuteName = NSString (format: "dropbar% i", i) var texture = drop bartattles.txtname (textuteName) dropFrames .addObject (texture)}  

TheMoveToView preloaded the array with texture in the text:

  SKTtexture.preloadTextures (dropFrames, withCompletionHandler: {() -  

Animation 30 fps to play with. I use animate with texture.

  var Chetanopropbar = SKAction My problem is that when I preload texture So, memory usage is increased to about 300 MB. Is there another performant solution? 
and what frame rate and image size are recommended for SKAction.animateWithTextures?

< P>

You should keep in mind that the size of the image file (1 KB in your example) is stored in the RAM to store the required memory There is nothing with the quantity of. You can calculate the amount of memory required with this formula Can:

width x height x byte per pixel = size in memory

If you use the standard RGBA8888 pixel format, that means that your image is almost in RAM memory 0.5 megabytes is required, because RGBA uses 8888 4 pixels per pixels - 1 byte for each red, green, blue color and 1 byte for alpha transparency. You can read more.

So what you can do, you have to customize the texture and use different textual formats. Here is another example about the texture.


No comments:

Post a Comment