【问题标题】:Corona sdk : stop audio when another starts / launch audio just onceCorona sdk:当另一个启动/启动音频时停止音频
【发布时间】:2023-03-13 22:20:01
【问题描述】:

我想在另一个声音开始播放时停止。

if (event.object1.myName == "obst3") then 
audio.play(colsound)

如果下一个开始,我希望这个停止。

if (event.object1.myName == "t") then
    audio.play(explosion) 

另外,我需要知道如何只发出一次声音(当我的物体与墙壁碰撞时,我需要只听到一次声音,即使玩家再次触摸墙壁。

【问题讨论】:

标签: audio coronasdk


【解决方案1】:

播放每个带有参考 id 值的音频:

    if (event.object1.myName == "obst3") then 
       local isChannel1Playing = audio.isChannelPlaying( 2 )
       if isChannel1Playing then
         audio.stop( playLaserSound2 )
         playLaserSound2 = nil
       end
       playLaserSound1  = audio.play(colsound, { channel=1 })
    end
   if (event.object1.myName == "t") then
      local isChannel1Playing = audio.isChannelPlaying( 1 )
       if isChannel1Playing then
         audio.stop( playLaserSound1 )
         playLaserSound1 = nil
       end
      playLaserSound2 = audio.play(explosion, { channel=2 })
   end

【讨论】:

  • 谢谢@AndroidUser 它有效,你能解释一下 playerLaserSound1 = nil 实用程序吗?
  • 再次清除参考 playerLaserSound1.bcs 您将使用该变量。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-23
  • 2022-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多