diff --git a/www/js/app.js b/www/js/app.js index 534dd82..a792b1e 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -113,7 +113,8 @@ angular.module('kinderspiel', ['ionic', 'ngCordova','ngAnimate', 'ngDraggable', url: '/home', abstract: false, templateUrl: 'templates/home.html', - controller: 'home' + controller: 'home', + reload: true }) .state('suchspiel', { url: '/suchspiel', diff --git a/www/js/home_controller.js b/www/js/home_controller.js index cbb117d..593337f 100644 --- a/www/js/home_controller.js +++ b/www/js/home_controller.js @@ -1,4 +1,4 @@ -appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia, $state, backgroundsounds_mediahandler, $timeout, $http ) { +appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $cordovaMedia, $state, backgroundsounds_mediahandler, $timeout, $http ) { /* * Mentor-Anitmation ausschalten @@ -10,15 +10,30 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia $scope.CSSKornspeicher=false; $scope.baumhauszufallaction=99; + + //Globale-Sounddatei + var mentorsound=''; + var boingsound=''; + + var mentor_is_speakting=false; + var boing_is_sounding=false; + + $scope.$on("$ionicView.beforeEnter", function(event, data){ + /* + * Hintergrundbild setzen + */ + $rootScope.backgroundimage = "img/Background/background.svg"; + }); + + /* * Hintergrundmusik laden und starten */ $ionicPlatform.ready(function() { - //Globale-Sounddatei - var gamesound=''; $scope.baumhaus_action=[]; $scope.mediastartesuchspiel=''; + $scope.boingsound_action=[]; /* * Spiele IntroSounds laden @@ -30,6 +45,9 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia if (data[i].type=='baumhaus'){ $scope.baumhaus_action.push(data[i].sound); } + else if (data[i].type=='boingsound'){ + $scope.boingsound_action.push(data[i].sound); + } else if (data[i].type=='startgamesuchspiel'){ $scope.mediastartesuchspiel=data[i].sound; } @@ -51,7 +69,8 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia $scope.suchspiel_intro = function(){ $scope.CSSKlickSuchspiel=true; $scope.showmentor=true; - playsound($scope.mediastartesuchspiel, suchspiel_intro_finish,'1.0'); + mentor_is_speakting=false; + playsound('mentorsound', $scope.mediastartesuchspiel, suchspiel_intro_finish,'1.0'); } /* @@ -60,7 +79,7 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia function suchspiel_intro_finish() { //Soundfile freigeben - gamesound.release(); + mentorsound.release(); $scope.CSSKlickSuchspiel=false; $scope.showmentor=false; @@ -69,6 +88,7 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia $scope.animate_farmhaus=function(){ $scope.CSSFarmhaus=true; + playsound('boingsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], boingsound_stop,'1.0'); $timeout(function () { $scope.CSSFarmhaus=false; }, 2000); @@ -77,6 +97,7 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia $scope.animate_windrad=function(){ $scope.CSSWindrad=true; + playsound('boingsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], boingsound_stop,'1.0'); $timeout(function () { $scope.CSSWindrad=false; }, 2000); @@ -87,6 +108,7 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia //SetBackgroundpic //$rootScope.backgroundimage = "img/ufo.png"; $scope.CSSKornspeicher=true; + playsound('boingsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], boingsound_stop,'1.0'); $timeout(function () { $scope.CSSKornspeicher=false; }, 2000); @@ -97,27 +119,78 @@ appControllers.controller('home', function($scope, $ionicPlatform, $cordovaMedia $scope.baumhauszufallaction=getRandomInt(1,2); if ($scope.baumhauszufallaction==2){ $scope.showmentor=true; - playsound($scope.baumhaus_action[getRandomInt(0, $scope.baumhaus_action.length - 1)], baumhaus_mentor,'1.0'); + playsound('mentorsound', $scope.baumhaus_action[getRandomInt(0, $scope.baumhaus_action.length - 1)], baumhaus_mentor,'1.0'); } } /* * Play-Sound */ - function playsound(soundfile, callbackfunction, volume){ + function playsound(playtype, soundfile, callbackfunction, volume){ $ionicPlatform.ready(function() { - gamesound = new Media(soundfile, callbackfunction ,null); - gamesound.play(); - gamesound.setVolume(volume); + + + if (playtype=='boingsound'){ + + + if (boing_is_sounding==false){ + + try{ + + //versuchen Soundfile freizugeben + boingsound.release(); + } + catch(e){ + + //Soundfile Objekt gabs nicht oder Freigabefehler + console.log("Sounddatei nicht da"); + } + + boingsound = new Media(soundfile, callbackfunction ,null); + boingsound.play(); + boingsound.setVolume(volume); + boing_is_sounding=true; + } + } + else if (playtype=='mentorsound'){ + + if (mentor_is_speakting==false){ + + try{ + + //versuchen Soundfile freizugeben + mentorsound.release(); + + } + catch(e){ + + //Soundfile Objekt gabs nicht oder Freigabefehler + console.log("Sounddatei nicht da"); + } + + mentorsound = new Media(soundfile, callbackfunction ,null); + mentorsound.play(); + mentorsound.setVolume(volume); + mentor_is_speakting=true; + } + } + }); } + function boingsound_stop(){ + //Soundfile freigeben + boingsound.release(); + boing_is_sounding=false; + } + + function baumhaus_mentor(){ //Soundfile freigeben - gamesound.release(); - + mentorsound.release(); + mentor_is_speakting=false; //Baumhausmentor ausblenden $timeout(function () { $scope.showmentor=false; diff --git a/www/js/minispiel1_controller.js b/www/js/minispiel1_controller.js index 03438d8..0cd1fcb 100644 --- a/www/js/minispiel1_controller.js +++ b/www/js/minispiel1_controller.js @@ -14,6 +14,14 @@ $scope.bin_am_lachen=false; var gamesound=''; var lachensound=''; + +$scope.$on("$ionicView.beforeEnter", function(event, data){ + /* + * Hintergrundbild setzen + */ + $rootScope.backgroundimage = "spielsets/minispielset1/images/background.png"; +}); + $ionicPlatform.ready(function() { /* @@ -24,11 +32,6 @@ $ionicPlatform.ready(function() { $scope.gamesounds=[]; - /* - * Hintergrundbild setzen - */ - $rootScope.backgroundimage = "spielsets/minispielset1/images/background.png"; - /* * Spiele IntroSounds laden * Typen: successsound -> Bravo, super, tollgemacht Sounds diff --git a/www/js/suchspiel_controller.js b/www/js/suchspiel_controller.js index 94cac77..c996485 100644 --- a/www/js/suchspiel_controller.js +++ b/www/js/suchspiel_controller.js @@ -1,4 +1,4 @@ -appControllers.controller('Suchspiel', function($scope, $ionicPlatform, $cordovaMedia, backgroundsounds_mediahandler, $state, $timeout,$q, $http) { +appControllers.controller('Suchspiel', function($scope, $rootScope, $ionicPlatform, $cordovaMedia, backgroundsounds_mediahandler, $state, $timeout,$q, $http) { /* @@ -51,6 +51,13 @@ $scope.gamelock=true; $scope.rundenstart = ''; $scope.rundenende = ''; +$scope.$on("$ionicView.beforeEnter", function(event, data){ + /* + * Hintergrundbild setzen + */ + $rootScope.backgroundimage = "img/Background/background.svg"; +}); + $ionicPlatform.ready(function() { /* diff --git a/www/sounds/homescreen_boing1.mp3 b/www/sounds/homescreen_boing1.mp3 new file mode 100644 index 0000000..db8203a Binary files /dev/null and b/www/sounds/homescreen_boing1.mp3 differ diff --git a/www/sounds/homescreen_boing2.mp3 b/www/sounds/homescreen_boing2.mp3 new file mode 100644 index 0000000..4627846 Binary files /dev/null and b/www/sounds/homescreen_boing2.mp3 differ diff --git a/www/sounds/homescreen_boing3.mp3 b/www/sounds/homescreen_boing3.mp3 new file mode 100644 index 0000000..5cbfd17 Binary files /dev/null and b/www/sounds/homescreen_boing3.mp3 differ diff --git a/www/spielsets/introsounds.json b/www/spielsets/introsounds.json index 49eea98..b15a4b5 100644 --- a/www/spielsets/introsounds.json +++ b/www/spielsets/introsounds.json @@ -4,5 +4,8 @@ {"id": 2, "type": "baumhaus", "sound": "/android_asset/www/sounds/baumhaus_action_3.mp3"}, {"id": 3, "type": "baumhaus", "sound": "/android_asset/www/sounds/baumhaus_action_4.mp3"}, {"id": 4, "type": "startgamesuchspiel", "sound": "/android_asset/www/sounds/spiel_intro.mp3"}, - {"id": 5, "type": "backgroundmusic", "sound": "/android_asset/www/sounds/background/background4.mid"} + {"id": 5, "type": "backgroundmusic", "sound": "/android_asset/www/sounds/background/background4.mid"}, + {"id": 6, "type": "boingsound", "sound": "/android_asset/www/sounds/homescreen_boing1.mp3"}, + {"id": 7, "type": "boingsound", "sound": "/android_asset/www/sounds/homescreen_boing2.mp3"}, + {"id": 8, "type": "boingsound", "sound": "/android_asset/www/sounds/homescreen_boing3.mp3"} ] \ No newline at end of file