Jump to content

Panda.js => game.audio.playMusic('music'); on iPhone doesn't work correctly.


Recommended Posts

Hi guys, I'm working on a simple game for learning purpose only.
I made a simple menù (Main Scene), by pressing on "Button START" the Main Scene will change to the Game one.
At the moment by pressing a button, the sprite moves in both direction, adding 10px to its current position and simultaneously a sound will be reproduced.
For this last step, I used the game.audio.playSound('step') instruction, and it works.
I tried to add a music in background for the Game Scene, but the music, on iOS, starts only after the first "touch" on the button.
I used at the end of init function, this instruction:
/* play audio */        game.audio.musicVolume = 0.1;        game.audio.playMusic('music');

This is the whole Game Scene code:

game.createScene('Game', {    backgroundColor: 0xff0000,    	init: function() {                var logo = new game.Sprite('logo.png').center().addTo(this.stage);        logo.interactive = true;                var button = new game.Sprite('button.png');        button.position.set(100, 100);        this.stage.addChild(button);        button.interactive = true;               button.touchstart = function () {         //this.remove();         var newposx = logo.position.x + 10;         //alert(newposx);         var newposy = logo.position.y + 10;         //alert(newposy);         logo.position.set(newposx, newposy);         this.stage.addChild(logo);                  game.audio.playSound('step');                    }            /* play audio */        game.audio.musicVolume = 0.1;        game.audio.playMusic('music');    }});


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...