2009-11-17 1 views
1

4 개의 이미지와 배경이 있습니다. 이미 움직일 이미지를 움직이기 시작했습니다. 그러나 뒷 배경은 움직이지 않습니다. 나는 이미지의 움직임에 따라 백그라운드를 움직이는 방법을 확신하지 못한다. 각 이미지가 다르게 움직이기 때문입니다.배경이 이미지와 함께 이동합니다.

이 첫 번째 이미지의 움직임이다 :

- (void)loadIllustration1 
{ 
    Sprite *illustration1 = [Sprite spriteWithFile:@"livraison01.png"]; 
    [illustration1 setTag:kTagIllustration1]; 
    //illustration1.position = CGPointMake(540,-40); 
    illustration1.position = CGPointMake(540,-40); 
    illustration1.scale =1.14; 
    id fade = [FadeIn actionWithDuration:1]; 
    //id go = [MoveTo actionWithDuration:2 position:CGPointMake(10,-10)]; 
    id go = [MoveTo actionWithDuration:2 position:CGPointMake(10,-10)]; 
    id seq = [Sequence actions: fade ,go , nil];  
    [illustration1 runAction:seq]; 
    [self addChild:illustration1]; 

    [NSTimer scheduledTimerWithTimeInterval:3.8 target:self selector:@selector(finishIllustrationAnimation1) userInfo:nil repeats:NO]; 
} 

이 두 번째 이미지 :이

- (id)init 
{ 
    if (self = [super init]) 
    { 
     Sprite *background = [Sprite spriteWithFile:@"background.png"]; 
     background.position = CGPointMake(240,160); 
     [background runAction:[FadeIn actionWithDuration:1]]; 
     [self addChild:background]; 

     self.reader = [[BubbleReader alloc] initWithPlistFile:@"BubbleItems.plist"] ; 
     currentIllustration = kTagIllustration1; 
     [self loadIllustration];  
    } 
    return self; 
} 

내가 누구의 도움 appricate 배경의 초기화가

- (void)loadIllustration2 
{ 
    Sprite *illustration1 = (Sprite *)[self getChildByTag:kTagIllustration1]; 
    if (illustration1 != nil) [self removeChildByTag:kTagIllustration1 cleanup:YES]; 
    Sprite *illustration2 = [Sprite spriteWithFile:@"livraison02.png"]; 
    [illustration2 setTag:kTagIllustration2]; 
    illustration2.scale = 0.9; 
    //illustration2.position = CGPointMake(460,135); 
    //this will show the image from down right to up left 
    illustration2.position = CGPointMake(30,240); 
    id fade = [FadeIn actionWithDuration:1]; 
    //id go = [MoveTo actionWithDuration:2 position:CGPointMake(20,305)]; 
    //this will show the image from down right to up left 
    id go = [MoveTo actionWithDuration:2 position:CGPointMake(400,30)]; 
    id seq = [Sequence actions: fade ,go , nil];  
    [illustration2 runAction:seq];  
    [self addChild:illustration2]; 
    [NSTimer scheduledTimerWithTimeInterval:3.8 target:self selector:@selector(finishIllustrationAnimation2) userInfo:nil repeats:NO]; 
} 

입니다

+0

코드의 두 번째 절반에 대한 서식을 확인하십시오. 중간에서 위로 올라간 것 같습니다. – bguiz

답변

0

Y 우리의 코드는 (여기서) 읽는 것을 어렵게하는 방식으로 포맷되어 있습니다. 그러나 단순히 움직일 배경을 말하지 않았던 것 같습니다. 방금 말씀하십시오 :

[background runAction:[FadeIn actionWithDuration:1]]; 

그래서 페이드 인이라고 말하면서 움직이지 말라고 말하면됩니다.

그냥 페이드 인으로 알려줍니다. 코드 형식을 수정해야 더 많은 것을 알 수 있습니다.