I’m developing a game, obviously there are moving objects… when I move them they lag. My colleague has the same problems
Thus I move obstacle:
-(void)moveThings:(ccTime)dt
{
CGSize size = [[CCDirector sharedDirector] winSize];
for(CCSprite * sprite in visibleObstacle)
{
if(sprite.position.x<=size.width)
{
sprite.position=ccp(sprite.position.x-2, sprite.position.y);
}
else
{
[self removeChild:sprite cleanup:YES];
[visibleObstacle removeObject:sprite];
}
}
}
Thus I move plane:
-(void)manageFlight
{
[plane runAction:[CCMoveTo actionWithDuration:0.05 position:ccp(plane.position.x, plane.position.y-2)]];
//self.bgLayer.position=CGPointMake(self.bgLayer.position.x-1, self.bgLayer.position.y);
//self.bgTrees.position=CGPointMake(self.bgTrees.position.x-5, self.bgTrees.position.y);
}
ALso I move background which is tile.. well when I move obstacle for instance they happen to lag, even if sprites are small. any advice? Are there other reliable frameworks for games on iphone? thanks
It look like removing sprites causes your lags. You should just hide it or/and to reposition as you want.
As following: