オーディオ入力に基づいて配列を保存し、録音の再生中に入力に対応するアニメーション フレームを再生しようとしています。
コードは、しばらくするとシミュレーターでクラッシュして強調表示されることを除いて、現在まで機能しています。
"CCLOG(@"adding image: %@", characterImageString);";
これとともに:
EXC_BAD_ACCESS (code=1, address=0xd686be8)
これは私が知っているメモリ管理ですが、私は完全に困惑しています。
if(isRecording){
int myInt;
NSString * characterImageString;
//get a number based on the volume input
float f = audioMonitorResults * 200; //convert max(0.06) to 12
f=((f/12)*10);
NSNumber *myNumber = [NSNumber numberWithDouble:(f+0.5)];
myInt = [myNumber intValue] + 1;
//create the image file name from the intiger we
//created from the audiomonitor results
if(myInt < 10){
characterImageString = [NSString stringWithFormat:@"fungus000%i.png",myInt];
} else if (myInt == 10){
characterImageString = [NSString stringWithFormat:@"fungus00%i.png",myInt];
}
CCLOG(@"adding image: %@", characterImageString);
//add each frame
[animationSequence addObject:characterImageString];
// print array contents
NSLog(@"animationSequence Array: %@", animationSequence);
// print array size
NSLog(@"animationSequence Number of Objects in Array: %u", [animationSequence count]); }
これは、オーディオの再生中に再生されるコードです。
-(void) updateAnimation:(ccTime) delta{
myFrame ++;
NSString *imageToDisplay;
imageToDisplay = animationSequence[myFrame];
CCTexture2D *currentTextureToDisplay = [[CCTextureCache sharedTextureCache] addImage:imageToDisplay];
[character setTexture:currentTextureToDisplay];
CCLOG(@"current texture to display: %@", currentTextureToDisplay);
if (myFrame >= [animationSequence count]) {
[self unschedule:@selector(updateAnimation:)];
}