Skip to content

Game resets when looping background music #310

@GotAnySnacks

Description

@GotAnySnacks

I'm currently loading background music into games using the following commands:

this.bgm = game.assets["mp3 file"];
this.bgm.play();

I've seen a few places online recommend the following as a workaround for enchant.js not having a built in looping function for sounds:
if (this.bgm.currentTime >= this.bgm.duration)
this.bgm.play();

This would be placed in the enterframe event of the scene where this.bgm was declared. However, once it calls, the entire game is reset along with the music. I've tried it on a few different programs & all desktop browsers as a test, although it could still be an error on my end. Is this something that's been reported before? Or am I just using a very out of date method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions