嘿,我仍然得到一些不想要的声音效果仍然在另一个框架中播放,例如,当我点击我的鼠标左键,这也是我的跳跃按钮,它将播放跳跃的声音,以及播放收集硬币声音,即使我把每个孩子从舞台上删除时,在屏幕上游戏。现在我对声道有点不熟悉了,所以如果需要使用它,请友好一点,并解释:)
在框架1中:
var myMusic1:Sound = new Game_Over_Noise();
var myMusic2:Sound = new Jump_Noise();
var myMusic3:Sound = new Coin_Noise();
var myMusic4:Sound = new Power_Up_Noise();
var myMusic5:Sound = new Theme();
var channel:SoundChannel = myMusic5.play();在第8帧中,游戏屏幕:
function doJump(evt:MouseEvent):void
{
if(!isJumping) //If the player is jumping.
{
jumpPower = 30; //Jump power is equal to 30.
isJumping = true; //isJumping variable is also equal to true.
var channel:SoundChannel = myMusic2.play(); //Play sound effect.
}
}
function update(evt:Event):void
{
if(isJumping) //If the player is jumping.
{
MainChar.y -= jumpPower; //Subtract the value of jumpPower from the player's y co-ordinate.
jumpPower -= 2; //Decrease the value of jumppower by 2.
}
if(MainChar.y + gravity < ground) //If the value of the player's Y co-ordinate and gravity is less than ground.
MainChar.y += gravity; //Then add the value of gravity to the player's Y co-ordinates.
else //else
{
MainChar.y = ground; //The players Y co-ordinate is equal to ground.
isJumping = false; //Make isJumping equal to false.
}
}在第5帧中,游戏通过屏幕:
SoundMixer.stopAll();现在,这停止了主题音乐,而不是音效,现在我实际上不介意主题曲一直在播放,但我希望所有的声音效果(游戏声音)只在游戏中播放。
我知道我的编码并不是最好和高效的,但对我来说它很容易实现,我很感谢你的帮助!
发布于 2015-01-09 00:38:49
在我看来,你需要删除你的事件监听器(他们是活跃的,即使是在某些东西离舞台的时候)。
https://stackoverflow.com/questions/27851295
复制相似问题