objective c - iOS 8 How to Prevent Spritekit Frame Rate Drop -


I have created a game in which I have created a game mode where the player has 30 seconds goal, whatever can do. I have added a 30 second countdown timer in (zero) update: (CFTIn interval) current time method. When the countdown is initiated, the frame rate is greatly reduced, and 99% of the CPU is used even when the object is collided with the object. It does not happen when the timer is not running. Is there another way to add a countdown timer? If not, how can I reduce CPU usage and keep the frame rate constant? I'm using Xcode 6.1 and the code is below. Apart from this, it's an iOS 8 problem. It runs fine on iOS 7.1.

  - (zero) Update: (CFTInterval) Present time [/ * is presented before each frame * / // Reset Counter if int highconter starts = [[NSUser Defaults StandardUserDefaults ] IntegerForKey: @ "highscoret"]; If (startGamePlay) {startTime = currentTime; StartGamePlay = No; } CountDown.text = [NSString stringWithFormat: @ "Get Started!"]; Int countDownInt = 30.0 - (Int) (Current Time-Time-Time); If (countDownInt> gt; 0) // If counting below 0 is counter countdown. Text = [NSString stringWithFormat: @ "% i", countdownown] ;; } And if (countDownInt == 0) {// If the message is not shown, then dismiss it, whatever you need to do is CountDown.text = @ "over time!"; Self.highScoret.text = [NSString stringWithFormat: @ "% d basket", Hyscot]; SKScene * endGameScene = [[Gameover TLock] Initwit Size: SelfIce]; SKTransition * Appear = [SKTransition fadeWithDuration: 0.5]; [Self.view presentScene: endGameScene infection: manifestation]; [Self defense sector 2]; If (Sep. Point> Hyscot) {self.highScoret.text = [NSString stringWithFormat: @ "% d Points", Hyscot]; [Save themselves]; Self.points = 0; Self.scoreLabel.text = [NSString stringWithFormat: @ "% d Points", _ points]; } And {self.points = 0; Self.scoreLabel.text = [NSString stringWithFormat: @ "% d Points", _ points]; Self.highScoret.text = [NSString stringWithFormat: @ "% d Points", Hyscot]; }}}  

and there is other relevant code

  - (zero) touches: (NSSET *) touches the event: (UIEvent * ) Event is called for / when a touch starts / (UITT * touches in touch) {CGPoint location = [Touch space InDude: Self]; If (CGRectContainsPoint (countdown.frame, location)) {startGamePlay = YES; Self.baskett = 0; [Auto reset]; }} UITouch * touch = [touches anyObject]; CGPoint Location = [Touch Position InDude: Self]; SKSpriteNode * Object = [SKSpriteNode spriteNodeWithImageNamed: @ "object.png"]; Object.position = self.object2.position; Object.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius: ball.size.width / 2]; Object.physicsBody.dynamic = Yes; Object.physicsBody.categoryBitMask = objectCategory; Object.physicsBody.contactTestBitMask = targetCategory; Object.physicsBody.collisionBitMask = 0; Object.physicsBody.usesPreciseCollisionDetection = Yes; CG point offset = RWsub (location, object.); If (offset. Y & lt; = 0) returns; [Add self child: object]; CGPoint direction = RW normal (offset); CG points shootman = RWMult (direction, 1000); CGPoint realDest = rwAdd (ShootAmain, Object.); Float veg = 200 / 1.0; Float revival = steering. Wide / velocity; SKAction * actionMove = [SKAction driving: realDest period: realMoveDuration]; SKAction * actionMoveDone = [SKAction removeFromParent]; [Object Run Action: [SKACection Sequence: @ [ActionMove, Action Mavon]]]; } - (zero) object: (SKSpriteNode *) object collidevity target: (SsprintNode *) target {{object removeFromParent]; [[Self-view] Run Action: [Square Placefile Nominated: @ "Effect 2. Wave" Waiting End:]]; Self.points ++; Self.scoreLabel.text = [NSString stringWithFormat: @ "% d Points", _ points]; If (self. Point == 3) {[self restraint]; }}  

The timer inside an updated function is a bad idea waiting this way. Your problem may be loosened

  SKAction * updateTime = [SKAction sequence: @ [/ /]] Fire Function [SKAction waitForDuration: 1.0f] after each other, [SKAction performSelector : @selector (callFunction) OnTarget: Self]]]; // where 30 you want to call your function, the number of that time [self-run action: [scan duplication: update time count: 30]]; - (zero) call function {// what ever you want to do}  

Comments