• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

A sound won't play

Paul59

Active member
CX Code Contributor
Joined
Dec 13, 2018
Messages
384
I have this bit of code:
Cerberus:
Function Init:Void()

    goSound = LoadSound("sounds/gameover.ogg")
    ' play game over 'music' once
    SetChannelVolume(3, sfxVolume)
    PlaySound(goSound, 3, 0)

    state = GAME_OVER

End

But for some reason the sound just will not play. I've tried making goSound global in case going out of scope has some effect, using a different channel, pausing and resuming the channel, setting the volume as 1.0 in code, but still no joy. I've tried both ogg and wav formats and the result is the same - no sound.

The files play properly in Cerberus' previewer and external players. I've added a debuglog message to check that this code is being called - it is. Once the state is changed to GAME_OVER it returns immediately to the main loop which continues to call the gameover.cxs update and rendering fuctions. There is no sound related code in any of those functions/loops.

The bizarre thing is, if I change the above code to play the file as music it works perfectly! (I don't want it to repeat which is why i'm trying to play it as a sound).

If anyone can make a suggestion in the next hour or two before I need to package up the game for the LD44 Compo I'd appreciate the help :D
 
Cerberus:
Function PlayMusic : Int ( path:String, flags:Int=1 )

Set the flags to 0 and it won't loop.

But for some reason the sound just will not play.
Did you check if goSound isn't Null?
 
Cerberus:
Function PlayMusic : Int ( path:String, flags:Int=1 )
Set the flags to 0 and it won't loop.

Arghhh, silly me, why didn't I see that before, must have been sometime since I looked at PlayMusic so assumed it was only for looping!

Just checked and goSound is not null so I have no idea what the issue is. Doesn't matter, I'll used PlaySound() - thanks Mike :D
 
Also see this app config setting:

Cerberus:
#HTML5_WEBAUDIO_ENABLED=True

In general, wav files are better for short sounds on html. Off is more for music.
 
Back
Top Bottom