Cocos2d iphone Cocos2d CCScale

Cocos2d iphone Cocos2d CCScale,cocos2d-iphone,Cocos2d Iphone,我想创建脉冲平台,但CCScale存在一些问题。 我在NSMuttableArray中有一些平台类的对象 @interface Platforms : CCNode{ CCSprite *platformSprite; int typeP; } @property (nonatomic, retain) CCSprite *platformSprite; @property int typeP; @实施 - (id)init:(int)type { self = [

我想创建脉冲平台,但CCScale存在一些问题。 我在NSMuttableArray中有一些平台类的对象

@interface Platforms : CCNode{

    CCSprite *platformSprite;
    int typeP;

}
@property (nonatomic, retain) CCSprite *platformSprite;
@property int typeP;
@实施

- (id)init:(int)type
{
    self = [super init];
    if (self != nil) {
        typeP = type;
        platformSprite = [CCSprite spriteWithFile:@"ball.png" rect:CGRectMake(0, 0, 51, 52)];
        [self addChild:platformSprite];
    }
    return self;
}
我将所有对象添加到屏幕

for (int i = 0 ; i < [_array count]; i++) {
        Platforms* _platforms2 = [[_array objectAtIndex:i ]retain];
        [self addChild:_platforms2];
        [_platforms2 release];
}
但是它不工作((我的平台不跳动。我的问题在哪里?
谢谢。

如果您想这样做,您可以选择

[tempSprite.platformSprite runAction:[CCSequence actions:[CCScaleTo actionWithDuration:3.0f scale:0.2f],[CCScaleTo actionWithDuration:3.0f scale:1.0f], nil]];
不需要做所有这些:

-(void)checkForScale:(ccTime)dt 
-(void)scaleDown:(Platforms *)tempSprite 
-(void)scaleUp:(Platforms *)tempSprite 

是否调用了scaleUp/scaleDown?您应该在那里设置一个断点并找出答案。我唯一能想到的是,与浮点值相等是很棘手的。即scale属性可能不是精确的0.2f,而是0.1999999f或0.200000001f
[tempSprite.platformSprite runAction:[CCSequence actions:[CCScaleTo actionWithDuration:3.0f scale:0.2f],[CCScaleTo actionWithDuration:3.0f scale:1.0f], nil]];
-(void)checkForScale:(ccTime)dt 
-(void)scaleDown:(Platforms *)tempSprite 
-(void)scaleUp:(Platforms *)tempSprite