嘿我仍然会在另一帧中播放一些不需要的声音效果,例如当我点击我的鼠标左键时,这也是我的跳跃按钮,它会播放跳跃声音以及播放收集硬币的声音很奇怪当我通过屏幕进入游戏时,我将每个孩子从舞台上移除。 现在我对音频通道有点不熟悉,所以如果需要使用,请善待并解释:)
第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();
现在这停止了主题音乐,而不是声音效果,现在我真的不介意主题曲调一直播放,但我希望所有声音效果(游戏声音)只能在游戏中播放。
我知道我的编码不是最好和最有效的,但它对我来说很容易读,我很感激帮助! :d
答案 0 :(得分:0)
在我看来,你需要删除你的事件监听器(即使有些东西在场外,它们也是活跃的)。