티스토리 뷰

8일째 쯤되니까 지겨워 진다. 


기본 골격을 완성한 후에 살붙여야 겠다.


우선 마지막 잡다한 것. 새가 벽에 부딧혔을 때의 지진 효과 구현.


화면 전체를 움직이는 기능은 따로 없길레 camera를 움직임.


-(CCSequence*)earthquakeEffect

{

    static float oneFrame = 2.0 / 24.0;

    static CGPoint viewMove[] = {

        CGPointMake(+2.0, -4.0),

        CGPointMake(-4.0, +6.0),

        CGPointMake(+4.0, -4.0),

        CGPointMake(-4.0, +4.0),

        CGPointMake(+4.0, +3.0),

        CGPointMake(-5.0, -4.0),

        CGPointMake(+2.0, +4.0),

        CGPointMake(+1.0, -.0)

    };

    

    id delayTimeAction = [CCDelayTime actionWithDuration:oneFrame];

    

    NSMutableArray *earthquake = [NSMutableArray array];

    

    for (int i = 0; i < sizeof(viewMove)/sizeof(viewMove[0]); i++)

    {

        CGPoint pt = viewMove[i];

        CCCallBlock *run = [CCCallBlock actionWithBlock:^{

            // 카메라 move

            float centerX, centerY, centerZ;

            float eyeX, eyeY, eyeZ;

            

            [self.camera centerX:&centerX centerY:&centerY centerZ:&centerZ];

            [self.camera eyeX:&eyeX eyeY:&eyeY eyeZ:&eyeZ];

            

            [self.camera setCenterX:centerX+gScale*pt.x centerY:centerY+gScale*pt.y centerZ:centerZ];

            [self.camera setEyeX:centerX+gScale*pt.x eyeY:eyeY+gScale*pt.y eyeZ:eyeZ];

        }];

        

        [earthquake addObject:run];

        [earthquake addObject:delayTimeAction];

    }

    

    return [CCSequence actionWithArray:earthquake];

}





full screen earthquake effect.

Fail : 전체 화면 TintTo 적용. (작동하지 않음)


    id whiteTintBy = [CCTintTo actionWithDuration:1 red:0 green:255 blue:255];

    

    for( CCNode *node in [self children] )

    {

        if( [node conformsToProtocol:@protocol(CCRGBAProtocol)] )

        {

            [node runAction:whiteTintBy];

        }

        else

        {

            for( CCNode *node2 in [node children] )

            {

                if( [node2 conformsToProtocol:@protocol(CCRGBAProtocol)] )

                {

                    [node2 runAction:whiteTintBy];

                    

                }

            }

        }

    }


다른 방법으로 각각 Set 더하고 set모든 객체에 대해 runAction을 때려보았는데 작동하지 않는다.

구현 자체가 바로 밑에 달리넘만 되던가 그런거 아닌것도 같고.. 다른 방법을..

stack overflow.. 검색해도 안나오더니 camera color change로 찾으니 나온다. ㅠㅠ


-(CCSequence*)TintByWhite

{

    float waiting = 0.5;

    

    CCLayerColor* colorLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 128)];

    id opaque = [CCFadeOut actionWithDuration:waiting];

    

    CCCallBlock *changeColor = [CCCallBlock actionWithBlock:^{

        // 화면 전체를 하얀색에서 정상색으로 되돌리기

        colorLayer.scale = 1.2;

        [self addChild:colorLayer z:kColorLayer];

        [colorLayer runAction:opaque];

    }];

    

    CCDelayTime *delay = [CCDelayTime actionWithDuration:waiting];

    CCCallBlock *removeLayer = [CCCallBlock actionWithBlock:^{

        [self removeChild:colorLayer];

    }];

    

    return [CCSequence actions:changeColor, delay, removeLayer, nil];

}


아니면 별도의 layer 분리 후 

        // 0.4 초 동안 3배 커지게 설정
        CCScaleTo *scale = [CCScaleTo actionWithDuration:0.4 scale:3.0];
        // 애니메이션이 끝나면 숨기고, 삭제한다.
        CCCallBlock *block = [CCCallBlock actionWithBlock:^{
            explosion.visible = NO;
            [self removeFromParentAndCleanup:YES];
        }];
        
        // 움직임 에니메이션이 끝나면 block을 순차적으로 실행하기 위한 시퀀스 생성
        CCSequence *seq = [CCSequence actions:scale, block, nil];
        [explosion runAction:seq];

자치 권한을 맞겨도 된다.




댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크