ios - How to keep fps rate constant in sprite kit? -
working on game ios, using sprite-kit framework build it. game runs smoothly first minute in half (maintaining 60 fps rate), player progresses game, frame rate starts decrease. time drops low 8 fps. thought result of added debris , obstacles in game, made effort remove lot of them parent after time. how game set up:
there 6 nsmutablearrays
different types of debris fall in game. format each of them:
-(void)spawndebris6 { skspritenode * debris6 = [skspritenode spritenodewithtexture:[sktexture texturewithimagenamed:@"debris6.png"] size:cgsizemake(20, 20)]; debris6.zposition = 1.0; skemitternode *debristrail = [skemitternode kitty_emitternamed:@"dtrail"]; debristrail.zposition = -1.0; debristrail.targetnode = self; [debris6 addchild:debristrail]; debris6.physicsbody = [skphysicsbody bodywithcircleofradius:25]; debris6.physicsbody.allowsrotation = no; debris6.physicsbody.categorybitmask = collisiondebris; //set random position debris //randomposition = arc4random() %248; //randomposition = randomposition + 10; debris6.position = cgpointmake (302, self.size.height + 65); [_debris6 addobject:debris6]; [self addchild:debris6]; //next spawn: [self runaction:[skaction sequence:@[ [skaction waitforduration:deb6time], [skaction performselector:@selector(spawndebris6) ontarget:self], ]]]; if (_dead == yes) { [self removeallactions]; } if (debris6.position.y > 568) { [self removefromparent]; } }
each of nsmutablearrays
appear on time - first 1 appears @ 0s, 2 @ 10s, 3 @ 40s, 4 @80s, etc. , when new 1 appears i've added code make former ones appear less , removed (to lower frame rate) yet still notice slower frame rate after 90 seconds.
i don't see why affecting frame rate i've minimised particle birth rate, , life span, , made effort delete , slow down spawn rates of debris on time. why fps rate depreciating?
if more info needed please let me know , i'll update post.
i had similar problem. skemitternodes. continue play around them , lower birth rates , life spans, maybe range etc. if problem persists, see if can take them out. may not good, have sacrifice looks functionality. i'd recommend maybe having debris appear @ different times , heights, still have full screen, smooth running screen.
Comments
Post a Comment