CCRotateBy动作是间歇性的跳跃/生涩?的Cocos2D

时间:2013-03-07 21:43:44

标签: cocos2d-iphone ccaction

我有一个cpCCSprite的子类,它只是用于使用chipmunk spaceManager而我的类看起来像这样:

@implementation Helmet

+(id) helmetWithGame:(Game*)game {

    return [[[self alloc] helmetInit:game] autorelease];

}

- (id) helmetInit:(Game*)game {

    cpShape *helmet_1;
    cpShape *helmet_2;
    cpShape *helmet_3;
    cpShape *reference;

    reference = [game.spaceManager addCircleAt:cpvzero mass:STATIC_MASS radius:2];

    helmet_1 = [game.spaceManager addCircleToBody:reference->body radius:20 offset:cpv(-5, 2)];

    helmet_2 = [game.spaceManager addCircleToBody:reference->body radius:8 offset:cpv(16, -14)];

    helmet_3 = [game.spaceManager addCircleToBody:reference->body radius:8 offset:cpv(8, -14)];

    reference->group    =1;
    helmet_1->group     =1;
    helmet_2->group     =1;
    helmet_3->group     =1;

    [self initWithFile:@"Helmet.png"];
    [self setBody:reference->body];

    self.spaceManager = game.spaceManager;
    self.autoFreeShapeAndBody = YES;

    gameScreenSize = game.contentSize;

    return self;
}

- (void) generateAndShowOn:(Game *)game {

    float startX = (float)((arc4random_uniform(101)) + 100);//returns number from 100 to 200 and casts it as a float
    float startY;

    int endXRange = (game.contentSize.width * .8) - (game.contentSize.width * .5);
    float endX = (float)((arc4random_uniform(endXRange)) + (game.contentSize.width * .5));
    float endY;

    BOOL shouldStartTop;

    if ((arc4random_uniform(101)) < 50) {//returns number from 0 to 100 and checks to see if it is less than 50. If it is, than the helmut starts at the top
        shouldStartTop = YES;
        startY = game.contentSize.height + (self.contentSize.height * .5);
        endY = -self.contentSize.height;
    }

    else {

        shouldStartTop = NO;
        startY = -(self.contentSize.height * .5);
        endY = game.contentSize.height + self.contentSize.height;
    }

    self.position = ccp(startX, startY);
    [game addChild:self];

    ccBezierConfig bezier;
    bezier.controlPoint_1 = ccp (startX, startY);
    bezier.controlPoint_2 = ccp (endX, endY);
    bezier.endPosition    = ccp (endX, endY);

    id rotate =[CCRotateBy actionWithDuration:1.5f angle:360];
    id curve = [CCBezierTo actionWithDuration:1.5f bezier:bezier];
    id spawn = [CCSpawn actions:rotate, curve, nil];

    [self runAction:spawn];

    [self schedule:@selector(doneAnimating) interval:1.6];

}

- (void) doneAnimating{

    if ([[self delegate]respondsToSelector:@selector(helmetPastBounds:)]) {
        [[self delegate]helmetPastBounds:self];

    }
}

- (void) dealloc {

    CCLOG(@"%s", __PRETTY_FUNCTION__);

    [super dealloc];
}

@end

因此,每秒都会调用此类的一个新实例,因此屏幕上一次可以有多个头盔。然后我有另一种方法,只需在完成操作后稍微调用以移除当前头盔并取消分配它。但我遇到的问题是,每次都会出现跳跃/生涩的行为,这与60岁时的FPS有关。我是否需要采取与行动不同的事情或可能导致此事的原因?

0 个答案:

没有答案