私は単純なゲームに取り組んでいて、すべての画面がタッチされた後、小さなUIImageViewでアニメーションが起こっています。これは非常にうまく起こり、アプリケーションはタイマーとしてCADisplayLinkで円滑に動作しています。AVAudioPlayerが時々アプリを突き上げる
私はAVAudioPlayerのような音を想像すると1秒lenghですべてのタッチ後に再生するmp3ファイルを追加しました:だから私は触れて初めて画面最初のしゃっくりがより少ないため、アプリの凍結を起こるのBip
私はそれがサウンドがメモリを割り当てるのは初めてです。
3秒以上前にタッチすると再び画面に触れると問題が発生しますが、アプリがヒップアップしませんが、4秒以上待つと、タッチするたびにアプリがうまく始まります。
タッチするたびに3秒以上前に何度も何度も繰り返しタッチすると、アプリはうまくいきませんが、タッチしてから4秒後にアプリが起き上がります。
何か問題は解決できますか?
@property (nonatomic, strong) AVAudioPlayer *mySound;
- (void)viewDidLoad {
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"bip" ofType:@"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
self.mySound = newPlayer;
[mySound prepareToPlay];
[mySound setDelegate:self];
}
とタッチが
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x < viewWidth/2) {
[mySound play];
} else {
[mySound play];
}
}
ボタンにある他のコードを表示できますか? – Ro4ch
私はボタンを一切使用せず、画面のどこにでも触れるだけです。私はあなたのために私の質問を編集しました。 –