Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Background music help please

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7246

    Jeff

    I added this to level.qml in flappy bird

      BackgroundMusic {
        id: backgroundMusic
        source: "../audio/music.mp3"
        // autoPlay: true - this is set by default
      }

    and it plays great but im not sure where to put an imagebutton so I can call the states for pause and play. I tried to do it in gamescene.qml but no luck..i don’t even know if Im doing the right code. thanks for the help all

    #7254

    Christian
    Felgo Team
    #7255

    Jeff

    hey, I looked at the examples but I still cannot find where they show how to mute the music with a button. I have added the above code to level.qml and it works but I need to add an icon on the screen to pause the music and to play it when clicked again. are you able to give me an example where to put the codes…is it in the gamescene.qml? do I have to create new fucntions for the backgroundmusic code? thanks

    #7256

    Alex
    Felgo Team

    Hi,

    the code could look like this:

    ImageButton {
        onClicked: {
          //the settings.musicEnabled flag enables/disables the background music, and also stores this in the database, so the music stays enabled/disabled on the next app start
          settings.musicEnabled = !settings.musicEnabled
        }
        // change the source to display different images in case the music is enabled or disabled
        source: settings.musicEnabled ? "music_on.png" : "music_off.png"
      }

    Of course you will have to add the images for the button (in my example music_on.png and music_off.png) to the spritesheet.

    Hope this helps.
    Cheers,
    Alex

    • This reply was modified 10 years ago by  Alex.
    #7258

    Jeff

    hey thank you so much…the code works under menu.qml but I cannot get it to work under gamescene…any ideas?

    #7259

    Jeff

    I got it, I put it in the main.qml instead. thanks

Viewing 6 posts - 1 through 6 (of 6 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded