sktextureatlas

How does SKTexture caching and reuse work in SpriteKit?

冷暖自知 提交于 2019-12-17 23:46:54
问题 It is often mentioned on StackOverflow that SpriteKit does its own internal caching and reuse. Does Sprite Kit load a texture atlas multiple times if I use SKTextureAtlas later? should I cache textures in properties in sprite kit? SpriteKit memory management preload cached and fps issue If I don't make any effort to reuse textures or atlases, what caching and reuse behavior can I expect from SpriteKit? 回答1: Texture Caching in SpriteKit “Long story short: rely on Sprite Kit to do the right

SpriteKit: Using SKTextureAtlas causes incorrect Physics Body

核能气质少年 提交于 2019-12-11 13:23:41
问题 I am building my first sprite kit game, and recently read an article that said to use SKTextureAtlas to improve performance. So I migrated all my sprite images into organized .atlas folders and updated the code accordingly. However, now my sprites have weird physics bodies (mainly over-enlarged) . For instance, my player sprite has three states: Flying (flat), Flying Up and Flying Down. The three images are pretty similar, with slight variations (arms pointing flat, up, down) . Before

How do I get rid of SKTextures?

吃可爱长大的小学妹 提交于 2019-12-11 08:35:07
问题 Maybe this is easy, but I'm lost. I have a project where I have to make a full-screen animation that uses 8 jpgs to simulate a page opening. So what I am doing is: I have an SKSpriteNode that displays on the full screen making an array of 8 SKTextures using SKTexture preloadTextures to load them once they're loaded, I use animateWithTextures to show the animation later on, another method removes the SKSpriteNode from the scene. When I first do the page turn, it uses a ton of memory, but when

How to force SKTextureAtlas created from a dictionary to not modify textures size?

 ̄綄美尐妖づ 提交于 2019-12-08 06:32:33
问题 In my project, textures are procedurally generated from method provided by PaintCode (paint-code). I then create a SKTextureAtlas from a dictionary filed with UIImage generated by these methods : myAtlas = SKTextureAtlas(dictionary: myTextures) At last, textures are retrieve from atlas using textureNamed : var sprite1 = SKSpriteNode(texture:myAtlas.textureNamed("texture1")) But displayed nodes are double sized on iPhone4S simulator. And triple sized on iPhone 6 Plus simulator. It seems that

SpriteKit: performance hit while preloading SKTextureAtlas

隐身守侯 提交于 2019-12-06 22:38:13
问题 I'm experiencing a performance hit when preloading SKTextureAtlas : let textureAtlas = SKTextureAtlas(named: atlasName) textureAtlas.preload(completionHandler: { ... }) By performance hit, I mean FPS dropping to ~50 for a short amounts of time. I tested it with Time Profiler in Instruments and verified that this work is indeed being done on a worker thread, like stated in documentation. The image bellow shows a Time Profiler capture of the spike, caused by preloading atlas. As you can see,

SpriteKit SKTextureAtlas, Terminated Due to Memory Pressure while loading texture

大兔子大兔子 提交于 2019-12-06 16:41:26
Similar to the SpriteKit Featured Game "Adventure" from WWDC, I am try to load my background image via tiles. I have created a Texture Atlas that contains 6,300 "tiles" that are each 100x100 pixels in size. The complete background image is a total of 30,000x2048 (for retina displays). The idea is that the background will move from right to left (side-scroller). The first column and the last column match so that they seem continuous. When the application runs, it loads my initial loading screen and title images and spikes to 54MB in my memory tab with a CPU usage of 16% . This stays the same as

SpriteKit: performance hit while preloading SKTextureAtlas

醉酒当歌 提交于 2019-12-05 03:02:21
I'm experiencing a performance hit when preloading SKTextureAtlas : let textureAtlas = SKTextureAtlas(named: atlasName) textureAtlas.preload(completionHandler: { ... }) By performance hit, I mean FPS dropping to ~50 for a short amounts of time. I tested it with Time Profiler in Instruments and verified that this work is indeed being done on a worker thread, like stated in documentation . The image bellow shows a Time Profiler capture of the spike, caused by preloading atlas. As you can see, most of the spike is caused by 2 worker threads, which all seem to be loading image data, as far as I

CUICatalog: Invalid Request: requesting subtype without specifying idiom (Where is it coming from and how to fix it?)

99封情书 提交于 2019-12-04 22:26:22
When I run my SpriteKit game, I receive this error multiple times in the console. As far as I can tell (though I'm not completely sure), the game itself is unaffected, but the error might have some other implications, along with crowding the debug console. I did some research into the error, and found a few possible solutions, none of which seem to have completely worked. These solutions include turning ignoresSiblingOrder to false , and specifying textures as SKTextureAtlas(named: "atlasName").textureNamed("textureName") , but these did not work. I think the error is coming somewhere from the

Swift : How to handle a lot of textures in memory

心已入冬 提交于 2019-12-04 15:43:35
I have a lot of characters in my game and because of that I have so many textures. When a texture atlas is loaded (containing about 5 different image textures) it increases the memory use and keeps it there at that amount. So the more textures just keeps driving that number up and up until sometimes the application crashes. I don't need all the characters at once, how can i maybe load some character textures when I need them and deallocate the others when i don't, but ill need to be able to bring it back. Rule 1 First of all you don't need to manually load in memory your texture atlas. When

Sprite Kit animateWithTextures lags

人盡茶涼 提交于 2019-12-01 00:27:50
I'm using texture atlases in my Sprite Kit game. I'm creating SKTextureAtlas object and store it's textures in array for each animation. So when I need some animation on my hero I call animateWithTextures sending it the corresponding array. There are some lags when I start animations. Is there some way to start animation smoothly? I am sure there are few ways to get around this. What you need to do is to preload an atlases before your gameplay actually start. Just show a loading screen at the beginning of the game and preload your atlases. You may try with + preloadTextureAtlases