开发者

How can I sync background music to visuals on the screen?

开发者 https://www.devze.com 2023-02-25 01:31 出处:网络
I\'m creating a guitar hero type game for my class and I\'m having开发者_JS百科 issues syncing the music with the moving notes. I open a thread and sleep for a few seconds to start the song so that it

I'm creating a guitar hero type game for my class and I'm having开发者_JS百科 issues syncing the music with the moving notes. I open a thread and sleep for a few seconds to start the song so that it will wait for the notes to move across the screen. That specific sleep time works for the simulator but not my actual iPod. And it seems when I first load the program into the simulator the timing is off.

Im using the the AVAudioPlayer class for the music.

Thank you for any insight!


Calling prepareToPlay before play should minimise any lag so that you don't need to do that sleep operation at all. Once prepareToPlay has returned start your thread and call play and you should be pretty much in sync.

0

精彩评论

暂无评论...
验证码 换一张
取 消