How to draw a background fast in cocos2d?

后端 未结 3 1852
后悔当初
后悔当初 2021-02-03 11:42

I\'m toying with a small game on my iPad using cocos2d and I\'ve run into some performance worries. I have a 512x512 image tiled as my background. That gives me around 40fps wit

3条回答
  •  终归单人心
    2021-02-03 12:20

    Turns out cocos2d moves in mysterious ways. Adding the background to an otherwise empty wrapping CCSprite gets the framerate back up to 60:

    CCSprite *spback = [(CCSprite*)[CCSprite alloc] init];
    [self addChild:spback];
    
    CCSprite *sp = [CCSprite spriteWithFile:@"Background.png"];
    sp.position = ccp(1024/2, 768/2);
    [spback addChild:sp];
    

    Credits for this goes to yaoligang on the cocos2d forums.

提交回复
热议问题