Hi Everyone,
Hope you are well and everything is okay. I'm a bit confused by the following and just wondering what the answer is
If you take the following bit of code and add your own jump and music ogg files :-)
Import playniax.ignition.framework.sound ' Import the sound module.
Import "data/jump.ogg"
Import "data/petersburger.ogg"
Global testSound:Sound
Global music:Sound
Global IsJumpSound:Int = 0
Global isMusicOn:Int = 0
Function Main ()
New MyApp
End Function
Class MyApp Extends App
Method OnCreate ()
testSound=LoadSound("jump.ogg")
If testSound = Null Then Print "Sound not opened"
music = LoadSound("petersburger.ogg")
If music = Null Then Print "Music not opened"
iSetSFXChannels (4) ' Set maximum of sfx channels (channels are rotated).
SetUpdateRate (60)
End Method
Method OnRender ()
Cls
DrawText "current volume: " + iGetSFXVolume (), 0, 0 ' Display the sfx main volume.
DrawText "Press space to play sound.", 0, 32
End Method
Method OnUpdate ()
If KeyHit (KEY_SPACE)
iPlaySound testSound ' Play sfx sound.
End If
If isMusicOn = 0 Then
iPlaySound music, 1, 1 ' Play music
Print "Playing theme music"
isMusicOn = isMusicOn + 1
Endif
End Method
End Class
Now if you press space 5 times, it cuts off the "music" part. How can I have it, so it does not do this. If I just comment out iSetSFXChannels (4), it will cut off the music at 9 spaces.
Please could someone help me understand this
Many thanks
Kind Regards
|