Decreasing FPS while adding obstacles

二次信任 提交于 2019-12-12 01:31:14

问题


I am new to cocos2d-x and I am developing a game in x-code using cocos2d-x.In my game i have a menu scene and game scene. In my game scene after adding the obstacles FPS is decreasing to 10 So my game performance is very low. Following is the code which i used to add obstacles in my game. and i have eight obstacles in my game. I created all the obstacles in one function and call that function by scheduler from init().Please help me solve this problem.

 time = time + 1;
int i=arc4random()%9;

obs1 = CCSprite::create("obs1.png");
obs1->setPosition(ccp((winwsize/5)+(2*winwsize),winhsize/2.45));
this->addChild(obs1,1);
obs1->setVisible(true);

  if(time%60==0&&i>=0&&i<=1)
{
    CCActionInterval* act1=CCMoveTo::create(7.0,ccp(-50,winhsize/2.45));
    obs1->runAction(CCRepeatForever::create(act1));
    CCRotateBy *rot=CCRotateBy::create(13, -2000);
    obs1->runAction(rot);
}

来源:https://stackoverflow.com/questions/23647035/decreasing-fps-while-adding-obstacles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!