Created
November 11, 2015 21:48
-
-
Save picopicolab/b4e55bc37dc5b4ba85d6 to your computer and use it in GitHub Desktop.
音声ファイル再生サンプル実装(Music インターフェイス利用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.picopicolab.games.demo; | |
import com.badlogic.gdx.ApplicationAdapter; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.audio.Music; | |
import com.badlogic.gdx.graphics.FPSLogger; | |
import com.badlogic.gdx.graphics.GL20; | |
/** | |
* 音声ファイル再生サンプル実装(Music インターフェイス利用) | |
*/ | |
public class DemoGame extends ApplicationAdapter { | |
private Music music; | |
private FPSLogger logger; | |
@Override | |
public void create() { | |
music = Gdx.audio.newMusic(Gdx.files.internal("shotgun.wav")); // 音声ファイルの読込 | |
logger = new FPSLogger(); | |
} | |
@Override | |
public void render() { | |
Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
if (Gdx.input.justTouched()) { | |
// 画面がタップされた場合 | |
if (!music.isPlaying()) { | |
// 再生中でない場合 | |
music.play(); | |
} | |
} | |
// FPS 出力 | |
logger.log(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment