Phempt Posted September 27, 2014 Share Posted September 27, 2014 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'); }}); Quote Link to comment Share on other sites More sharing options...
Phempt Posted September 28, 2014 Author Share Posted September 28, 2014 Using Phonegap instead of Safari Mobile (iOS) it works. This is so strange, maybe a possible Panda.js bug or a Safari mobile limitation? Quote Link to comment Share on other sites More sharing options...
enpu Posted September 30, 2014 Share Posted September 30, 2014 On iOS Safari, you must first "unlock" audio with user touch. Quote Link to comment Share on other sites More sharing options...
Phempt Posted September 30, 2014 Author Share Posted September 30, 2014 Ok the important thing is that through Phonegap it works I'm going to finish my first game using pandajs ^^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.