2009-12-10 122 views
0

我找不到解決方案!幫助!!!當播放聲音動畫暫停放緩

動畫大小10KB 聲音大小20KB

這裏是代碼:

- (void)setupSounds { 

     NSString * filePath 
     filePath = [[NSBundle mainBundle] pathForResource:@"shake" ofType:@"mp3"]; 
     soundShuffle = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:filePath ]error:nil]; 
     sound.volume = 0.4; 
     [sound prepareToPlay]; 
     [sound setDelegate: self]; 
    } 

    - (void) startAnimation { 

[self.Sound setCurrentTime:0.0]; 
    [self.Sound play]; 

pos1 = CGPointMake(2.0,7.0); 

kid.center = CGPointMake(kid.center.x+pos1.x,kid.center.y+pos1.y); 

    if(kid.center.x > 60 || kid.center.x < 0) 
    pos1.x = -pos1.x; 
    if(kid.center.y > 236 || kid.center.y < 105) 
    pos1.y = -pos1.y; 
    } 

    - (void) playSound { 
     if(self.sound.playing) 
     { 
      [self.sound stop]; 
     } 
     [self.sound setCurrentTime:0.0]; 
     [self.sound play]; 
    } 

    - (void)viewDidLoad { 
     [self setupSounds]; 

    } 
+0

我uptaed功能 – nil 2009-12-10 21:35:04

回答