Iphone 创建一个类似吉他英雄的应用程序

Iphone 创建一个类似吉他英雄的应用程序,iphone,Iphone,我想创建一个像吉他英雄游戏一样的应用程序。我有六个按钮,分别是a1,a2,a3,a4,a5,a6,用来播放声音。然后,我演奏一种由吉他弦组成的音乐 我的问题是如何创建一个函数来跟踪播放的音乐 @德里克:我很抱歉我的英语不好 现在,我用IB创建了六个按钮,每个按钮都有不同的声音。我使用IBAction创建按钮,并使用AVAudioPlayer播放声音。这是我的代码: ` av1-av5是吉他弦,av6是吉他音乐(播放30秒)。根据这段代码,当音乐播放时,我如何使播放按钮跟随另一个按钮?同意德里克的

我想创建一个像吉他英雄游戏一样的应用程序。我有六个按钮,分别是a1,a2,a3,a4,a5,a6,用来播放声音。然后,我演奏一种由吉他弦组成的音乐

我的问题是如何创建一个函数来跟踪播放的音乐

@德里克:我很抱歉我的英语不好

现在,我用IB创建了六个按钮,每个按钮都有不同的声音。我使用IBAction创建按钮,并使用AVAudioPlayer播放声音。这是我的代码: `


av1-av5是吉他弦,av6是吉他音乐(播放30秒)。根据这段代码,当音乐播放时,我如何使播放按钮跟随另一个按钮?

同意德里克的观点。我们需要更多的细节。您的应用程序正在播放音乐吗?是否由外部应用程序播放?你说的“跟着音乐走”是什么意思?你给我们的细节越多,我们帮助你的机会就越大。很抱歉我的英语不好。现在,我用IB创建了六个按钮,每个按钮都有不同的声音。我使用IBAction创建按钮,并使用AVAudioPlayer播放声音。这是我的代码:in.h-(iAction)one:(id)发送方;
in .h
.................{
       AVAudioPlayer *av1, *av2, *av3, *av4, *av5, *av6;
}

@property (nonatomic, retain) AVAudioPlayer *av1, *av2, *av3, *av4, *av5, *av6;

-(IBAction)one:(id)sender;
-(IBAction)two:(id)sender;
-(IBAction)three:(id)sender;
-(IBAction)four:(id)sender;
-(IBAction)five:(id)sender;
-(IBAction)six:(id)sender;
-(IBAction)play:(id)sender;

in.m


- (void)viewDidLoad {
    [super viewDidLoad];

    //load file audio dan persiapkan untuk play

    //saron1
    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"sp1" ofType:@"wav"];
    av1 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path1] error:NULL];
    av1.delegate = self;
    [av1 setVolume:1.0];
    [av1 prepareToPlay];

    //saron2
    NSString *path2 = [[NSBundle mainBundle] pathForResource:@"sp2" ofType:@"wav"];
    av2 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path2] error:NULL];
    av2.delegate = self;
    [av2 setVolume:1.0];
    [av2 prepareToPlay];

    //saron3
    NSString *path3 = [[NSBundle mainBundle] pathForResource:@"sp3" ofType:@"wav"];
    av3 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path3] error:NULL];
    av3.delegate = self;
    [av3 setVolume:1.0];
    [av3 prepareToPlay];

    //saron4
    NSString *path4 = [[NSBundle mainBundle] pathForResource:@"sp4" ofType:@"wav"];
    av4 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path4] error:NULL];
    av4.delegate = self;
    [av4 setVolume:1.0];
    [av4 prepareToPlay];

    //saron5
    NSString *path5 = [[NSBundle mainBundle] pathForResource:@"sp5" ofType:@"wav"];
    av5 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path5] error:NULL];
    av5.delegate = self;
    [av5 setVolume:1.0];
    [av5 prepareToPlay];

    //saron6
    NSString *path6 = [[NSBundle mainBundle] pathForResource:@"sp6" ofType:@"wav"];
    av6 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path6] error:NULL];
    av6.delegate = self;
    [av6 setVolume:1.0];
    [av6 prepareToPlay];
}

- (IBAction)one:(id)sender{
    [av1 play];
}

- (IBAction)two:(id)sender{
    [av2 play];
}

- (IBAction)three:(id)sender{
    [av3 play];
}

- (IBAction)four:(id)sender{
    [av4 play];
}

- (IBAction)five:(id)sender{
    [av5 play];
}

- (IBAction)six:(id)sender{
    [av6 play];
}