2009-11-17 7 views
1

J'ai 4 images et un arrière-plan. Je suis déjà sur le point d'animer l'image pour bouger en conséquence. Mais l'arrière-plan ne bouge pas. Je ne suis pas sûr de savoir comment faire bouger le fond en fonction du mouvement des images. Parce que chacune des images se déplace différemment.fond se déplace avec l'image

c'est première image en mouvement:

- (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]; 
} 

c'est deuxième image:

- (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]; 
} 

c'est le initialiseur de l'arrière-plan

- (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; 
} 

J'appricate l'aide de personne

+0

Vérifiez votre formatage pour la seconde moitié du code, il semble être détruit à mi-chemin à travers – bguiz

Répondre

0

Y notre code est formaté (ici) d'une manière qui le rend difficile à lire, mais il semble que vous n'avez simplement pas dit au backbground de se déplacer. Vous venez de le dire:

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

Donc vous lui dites de fondre, mais de ne pas bouger. Ce qui indique simplement qu'il doit se fondre. Vous devez corriger le formatage de votre code pour en savoir plus.

Questions connexes