とにかく、タイマーコマンドに与える必要があるイベントを完全には理解していません.オンラインのどこにも何時間も検索した場所はありません. だから私は、ほとんどの人が「USEREVENT + 1」を使用していると思われるものを使用しました。正しいかどうかわかりませんが、タイマーが機能していません。私はそれを正しく使用していますか?これが私のコードです:
nyansecond=462346
nyanint=0
spin=0
aftin=452345
def nyanmusic(nyansecond,nyanint,spin):
if nyanint == 0:
nyansound.play()
nyanint= 1
elif nyanint == 1:
nyansecond = pygame.time.set_timer(USEREVENT+1,7000)
if nyansecond < 200 and spin == 1:
spin = 0
nyansecond = pygame.time.set_timer(USEREVENT+1,7000)
elif nyansecond > 6500 and nyansecond < 100000 and spin == 0:
spin = 1
nyansoundm.play()
return nyansecond,nyanint,spin
次に、実装した 2 番目のページのコードに定義します (問題なく動作します)。nyansound を実行しますが、6.5 秒 (6500 ミリ秒) 後に nyansoundm を実行しません。より複雑なものに移る前に、python と pygame の基本を学ぶのに役立つように、このプログラムを作成しています。YouTube にアクセスして貴重な帯域幅を浪費することなく、ニャンキャットや他のループ曲を聴きたいときにも使用できます。しかし、それについて心配する必要はありません。
ああ、これは私がループに入れたコードですが、これはあまり重要ではないと思います:
#music
nyansecond,nyanint,spin = nyanmusic(nyansecond,nyanint,spin)