add sounds
This commit is contained in:
1 parent
fe73d7bec9
commit
26b6632158
13 files changed
+123
-21
No files matched your search
@@ -60,6 +60,8 @@ add_library( # Sets the name of the library.
|
||||
${JNI_PATH}/main_code.cpp
|
||||
${JNI_PATH}/match3/match3field.cpp
|
||||
${JNI_PATH}/android_api.cpp
|
||||
${JNI_PATH}/Sounds.cpp
|
||||
|
||||
)
|
||||
|
||||
add_library( engine
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.Calendar;
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
import com.fishrungames.crystalofrhylil.sounds.JniSoundCalls;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
@@ -58,6 +60,7 @@ class GLView extends GLViewAncestor
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height)
|
||||
{
|
||||
JniWrapper.Init(width,height);
|
||||
JniSoundCalls.init();
|
||||
}
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config)
|
||||
|
||||
+12
@@ -21,6 +21,8 @@ import android.view.MotionEvent;
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
|
||||
private static MainActivity instance;
|
||||
|
||||
GLView mView;
|
||||
|
||||
@Override
|
||||
@@ -29,6 +31,8 @@ public class MainActivity extends Activity
|
||||
|
||||
super.onCreate(icicle);
|
||||
|
||||
instance = this;
|
||||
|
||||
EngineWrapper.LoadSalmonEngineLibrary();
|
||||
EngineWrapper.SetActivityInstance(this);
|
||||
EngineWrapper.SetupEnviroment();
|
||||
@@ -88,6 +92,14 @@ public class MainActivity extends Activity
|
||||
EngineWrapper.ProcessKeyDown(keyCode, event);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public static MainActivity getInstance() {
|
||||
if (instance == null) {
|
||||
throw new RuntimeException("error GL2JNIActivity getInstance() - you are trying to get activity instance when it is not created or already destroyed");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//package com.fishrungames.crystalofrhylil;
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.fishrungames.crystalofrhylil.sounds;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
|
||||
import com.fishrungames.crystalofrhylil.MainActivity;
|
||||
import com.fishrungames.crystalofrhylil.R;
|
||||
|
||||
public class JniSoundCalls {
|
||||
|
||||
native public static void initJniSounds();
|
||||
|
||||
private static MediaPlayer backgroundPlayer = null;
|
||||
private static MediaPlayer gunshotPlayer = null;
|
||||
|
||||
public static void init() {
|
||||
initJniSounds();
|
||||
}
|
||||
|
||||
public static void JniPlayBackgroundSound() {
|
||||
backgroundPlayer = MediaPlayer.create(MainActivity.getInstance(), R.raw.background_sound);
|
||||
backgroundPlayer.setLooping(true);
|
||||
backgroundPlayer.start();
|
||||
}
|
||||
|
||||
public static void JniStopBackgroundSound() {
|
||||
if (backgroundPlayer != null) {
|
||||
backgroundPlayer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public static void JniPlayGunshotSound() {
|
||||
gunshotPlayer = MediaPlayer.create(MainActivity.getInstance(), R.raw.gunshot_sound);
|
||||
gunshotPlayer.setLooping(false);
|
||||
gunshotPlayer.start();
|
||||
}
|
||||
|
||||
public static void JniStopGunshotSound() {
|
||||
if (gunshotPlayer != null) {
|
||||
gunshotPlayer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user