LoginSignup
6
6

More than 5 years have passed since last update.

Coronaコネタ集

Last updated at Posted at 2013-12-16

(1)
音楽を聞きながらゲームできるようにしてほしい、と言われて、よくやり方わからず無視してたのですが…
フォーラムに載ってました。
main.luaとかに以下のようにかいておく。

if audio.supportsSessionProperty == true then
    audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)
end

--起動時/復帰時に音楽が鳴っていたら止める。
local onSystem = function( event )
    if event.type == "applicationStart" or event.type == "applicationResume" then 
    if audio.supportsSessionProperty == true then   
            if not(audio.getSessionProperty(audio.OtherAudioIsPlaying) == 0) then
                audio.stop()
            end
    end
    end
end
Runtime:addEventListener( "system", onSystem )

で、音楽をならす関数などで、以下のように実装する

       local function playBgm()
            if audio.supportsSessionProperty == true then   
                 if not(audio.getSessionProperty(audio.OtherAudioIsPlaying) == 0) then
                    return false
                 end
         end
             --ここに、BGMならす処理
        end

公式ドキュメントに載ってない気がするんですよね….。

(2)

system.setAccelerometerInterval(10)     
system.setGyroscopeInterval    (10)

ジャイロとか加速度とか使わないなら、こうしておくと電池の持ちがよくなるらしい。
これは公式にも載ってる。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6