added example sounds for JNI calls
This commit is contained in:
parent
69cb2f7cd3
commit
128c330f48
@ -21,6 +21,8 @@ import android.view.MotionEvent;
|
||||
public class GL2JNIActivity extends Activity
|
||||
{
|
||||
|
||||
private static GL2JNIActivity instance;
|
||||
|
||||
GLView mView;
|
||||
|
||||
@Override
|
||||
@ -29,6 +31,8 @@ public class GL2JNIActivity extends Activity
|
||||
|
||||
super.onCreate(icicle);
|
||||
|
||||
instance = this;
|
||||
|
||||
EngineWrapper.LoadSalmonEngineLibrary();
|
||||
EngineWrapper.SetActivityInstance(this);
|
||||
EngineWrapper.SetupEnviroment();
|
||||
@ -88,4 +92,9 @@ public class GL2JNIActivity extends Activity
|
||||
EngineWrapper.ProcessKeyDown(keyCode, event);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public static GL2JNIActivity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package fishrungames.doublehitballs.sounds;
|
||||
|
||||
public interface JniSoundCalls {
|
||||
|
||||
void playBackgroundSound();
|
||||
void stopBackgroundSound();
|
||||
|
||||
void playGunshotSound();
|
||||
void stopGunshotSound();
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package fishrungames.doublehitballs.sounds;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
|
||||
import fishrungames.doublehitballs.GL2JNIActivity;
|
||||
import fishrungames.doublehitballs.R;
|
||||
|
||||
/**
|
||||
* example sounds for JNI calls
|
||||
* @author Artem Budarin
|
||||
* Created by Artem Budarin on 06.08.2018.
|
||||
*/
|
||||
|
||||
public class JniSoundCallsImpl implements JniSoundCalls {
|
||||
|
||||
private MediaPlayer backgroundPlayer = null;
|
||||
private MediaPlayer gunshotPlayer = null;
|
||||
|
||||
@Override
|
||||
public void playBackgroundSound() {
|
||||
backgroundPlayer = MediaPlayer.create(GL2JNIActivity.getInstance(), R.raw.background_sound);
|
||||
backgroundPlayer.setLooping(true);
|
||||
backgroundPlayer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopBackgroundSound() {
|
||||
if (backgroundPlayer != null) {
|
||||
backgroundPlayer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playGunshotSound() {
|
||||
gunshotPlayer = MediaPlayer.create(GL2JNIActivity.getInstance(), R.raw.gunshot_sound);
|
||||
gunshotPlayer.setLooping(false);
|
||||
gunshotPlayer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopGunshotSound() {
|
||||
if (gunshotPlayer != null) {
|
||||
gunshotPlayer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
BIN
proj.android-studio/app/src/main/res/raw/background_sound.mp3
Executable file
BIN
proj.android-studio/app/src/main/res/raw/background_sound.mp3
Executable file
Binary file not shown.
BIN
proj.android-studio/app/src/main/res/raw/gunshot_sound.mp3
Executable file
BIN
proj.android-studio/app/src/main/res/raw/gunshot_sound.mp3
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user