Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:51:02+00:00 2026-05-27T10:51:02+00:00

I am doing a game, and I got only 1 final problem. Its that

  • 0

I am doing a game, and I got only 1 final problem. Its that when the game create an enemy the FPS slow to 40 or 20. Depends if it creates 1 or 2 enemies.

NSMutableArray *walkAnimFrames = [NSMutableArray array];
    for(int i = 1; i <= 3; ++i) {
        [walkAnimFrames addObject:
         [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
          [NSString stringWithFormat:@"laser_%d.png", i]]];
    }

    CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.12f];    
    CCSprite *laser = [CCSprite spriteWithSpriteFrameName:@"laser_1.png"];

    int tempY = (arc4random() % ((int)(300 - laser.boundingBox.size.height))) + laser.boundingBox.size.height;
    float tempRot = (arc4random() % 30) + 1;
    int sign = (arc4random() % 2) - 1;
    if (sign < 0) {
        tempRot *= -1;
    }

    laser.tag = 2;

    laser.position = ccp(650, tempY);
    laser.rotation = CC_RADIANS_TO_DEGREES(tempRot);
    CCAction *walkAction = [CCRepeatForever actionWithAction:
                            [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:YES]];
    [laser runAction:walkAction];
    [spriteSheet addChild:laser];

    b2BodyDef spriteBodyDef;
    spriteBodyDef.type = b2_dynamicBody;
    spriteBodyDef.position.Set(laser.position.x/PTM_RATIO, 
                               laser.position.y/PTM_RATIO);
    spriteBodyDef.userData = laser;
    b2Body *spriteBody = world->CreateBody(&spriteBodyDef);

    [[GB2ShapeCache sharedShapeCache] addShapesWithFile:@"laserBody.plist"];
    [[GB2ShapeCache sharedShapeCache] addFixturesToBody:spriteBody forShapeName:@"laser_1"];
    [laser setAnchorPoint:[[GB2ShapeCache sharedShapeCache] anchorPointForShape:@"laser_1"]];

    //pixeles recoridos/velocidad del move actual
    float timeAnim = 800/(60*move);
    [laser runAction:[CCSequence actions:
                      [CCMoveBy actionWithDuration:timeAnim position:ccp(-800, 0)],
                      [CCCallFuncN actionWithTarget:self selector:@selector(obstaclesDone:)],
                      nil]];    

I am using Physic Editor, to create the shape. After it create. The game works fine in 60 fps. But only in the iPhone. In my iMac works perfectly.

What could do I do to create it without loosing fps. Maybe in the second processor. Or another thread?

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:51:03+00:00Added an answer on May 27, 2026 at 10:51 am

    What is the size and quality of the textures you are using? It could be that too much memory is required to create sprite instances making it difficult to keep a high frame rate constantly changing the positions of those sprites. You could also try profiling with Instruments to see what is eating up your processor cycles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've got this nice Android game (a snake-clone with animations), doing the final
I've got a medium scale project (a turn-based game) that's currently written in C/C++.
I am doing some game design, and decided that I want a data centric
I'm doing a simple game and I got stucked at this : ( XNA,
im trying to make a simple game on cocos2d box2d, its basically got two
I want to get started doing some game development using Microsoft's XNA. Part of
I'm doing a chess game. In there, I want to move an element with
Continuing my quest of learning Java by doing a simple game, i stumbled upon
I'm creating a game with points for doing little things, so I have a
Doing the below will reproduce my problem: New WPF Project Add ListView Name the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.