首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >声音仍在另一帧中播放

声音仍在另一帧中播放
EN

Stack Overflow用户
提问于 2015-01-08 23:16:08
回答 1查看 34关注 0票数 1

嘿,我仍然得到一些不想要的声音效果仍然在另一个框架中播放,例如,当我点击我的鼠标左键,这也是我的跳跃按钮,它将播放跳跃的声音,以及播放收集硬币声音,即使我把每个孩子从舞台上删除时,在屏幕上游戏。现在我对声道有点不熟悉了,所以如果需要使用它,请友好一点,并解释:)

在框架1中:

代码语言:javascript
复制
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帧中,游戏屏幕:

代码语言:javascript
复制
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帧中,游戏通过屏幕:

代码语言:javascript
复制
SoundMixer.stopAll();

现在,这停止了主题音乐,而不是音效,现在我实际上不介意主题曲一直在播放,但我希望所有的声音效果(游戏声音)只在游戏中播放。

我知道我的编码并不是最好和高效的,但对我来说它很容易实现,我很感谢你的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-09 00:38:49

在我看来,你需要删除你的事件监听器(他们是活跃的,即使是在某些东西离舞台的时候)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27851295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档