Problema de sonido. En el bucle "for", se ha asignado un sonido cuando el automóvil golpea el hitbox del paquete a tomar ('pacz'). Esto se cuenta como un punto. Entonces el juego de sonido: 'bien'. Individualmente para cada paquete recogido. El problema surge cuando el jugador recolecta los 9 paquetes. El sonido "bueno" se enciende muchas veces al mismo tiempo. ¿Hay alguna manera de hacer que el sonido del paquete de 9 suene "bien" una vez al final del juego?
var root = this var collectedBoxes = 0 root.mainPacz.gotoAndStop(boxArray[0]) carCollisionSetup() boxCollisionSetup() var gameover = false function boxCollisionCheck() { let carBounds = root.car.getTransformedBounds(); let infoBox = root.mainPacz for (i = 1; i < 10; i++) { let boxBounds = root['pacz' + i].getTransformedBounds() if (carBounds.intersects(boxBounds) && infoBox.timeline.position == root['pacz' + i].timeline.position) { takeAnim(root['pacz' + i]) collectedBoxes++ createjs.Sound.play('good') console.log('good w pacz') if (collectedBoxes < 9) { infoBox.gotoAndStop(boxArray[collectedBoxes]) } else { if(!gameover)winFunction() console.log(winFunction) console.log('wrong pacz else') } } } } function winFunction() { gameover = true console.log("=========WIN========") setTimeout (() =>{ createjs.Sound.play('swietnie') },1500) setTimeout (() =>{ root.play(); },5000) stopCycle() root.stoper.play() //clearInterval(carPosChange) //timerTimeMS = 0 } //ANCHOR Handling losing function loseFunction() { console.log("=========LOSE========") }El final del juego con sonidos parece (estos "consol.log" se llaman muchas veces): ingrese la descripción de la imagen aquí