diff --git a/proj.ios/BridgeDelegate.h b/proj.ios/BridgeDelegate.h new file mode 100644 index 0000000..7f1ba99 --- /dev/null +++ b/proj.ios/BridgeDelegate.h @@ -0,0 +1,16 @@ +#ifndef BridgeDelegate_h +#define BridgeDelegate_h + +class BridgeDelegate +{ + +public: + + static void playBackgroundSound(); + static void stopBackgroundSound(); + static void playGunshotSound(); + static void stopGunshotSound(); + +}; + +#endif /* BridgeDelegate_h */ diff --git a/proj.ios/BridgeDelegate.mm b/proj.ios/BridgeDelegate.mm new file mode 100644 index 0000000..f1280b2 --- /dev/null +++ b/proj.ios/BridgeDelegate.mm @@ -0,0 +1,22 @@ +#include "BridgeDelegate.h" +#import "Sounds.h" + +void BridgeDelegate::playBackgroundSound() +{ + [ShareSounds playBackgroundSound]; +} + +void BridgeDelegate::stopBackgroundSound() +{ + [ShareSounds stopBackgroundSound]; +} + +void BridgeDelegate::playGunshotSound() +{ + [ShareSounds playGunshotSound]; +} + +void BridgeDelegate::stopGunshotSound() +{ + [ShareSounds stopGunshotSound]; +} diff --git a/proj.ios/Double Hit Balls.xcodeproj/project.pbxproj b/proj.ios/Double Hit Balls.xcodeproj/project.pbxproj index 75e0fdb..7458ca2 100755 --- a/proj.ios/Double Hit Balls.xcodeproj/project.pbxproj +++ b/proj.ios/Double Hit Balls.xcodeproj/project.pbxproj @@ -36,7 +36,9 @@ AC67C87F211C8DE3003AA164 /* NativeSoundCallsImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC67C87E211C8DE3003AA164 /* NativeSoundCallsImpl.swift */; }; AC67C882211C8E24003AA164 /* gunshot_sound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = AC67C880211C8E24003AA164 /* gunshot_sound.mp3 */; }; AC67C883211C8E24003AA164 /* background_sound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = AC67C881211C8E24003AA164 /* background_sound.mp3 */; }; - ACC6F8382121E8DF00CEDC5C /* SoundCalls.m in Sources */ = {isa = PBXBuildFile; fileRef = ACC6F8372121E8DF00CEDC5C /* SoundCalls.m */; }; + AC8032262122F8B100DEA5AC /* SoundCalls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC8032242122F8B100DEA5AC /* SoundCalls.cpp */; }; + AC80322A2122F8DD00DEA5AC /* BridgeDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC8032282122F8DC00DEA5AC /* BridgeDelegate.mm */; }; + ACC6F8382121E8DF00CEDC5C /* Sounds.m in Sources */ = {isa = PBXBuildFile; fileRef = ACC6F8372121E8DF00CEDC5C /* Sounds.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -112,8 +114,12 @@ AC67C87E211C8DE3003AA164 /* NativeSoundCallsImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeSoundCallsImpl.swift; sourceTree = ""; }; AC67C880211C8E24003AA164 /* gunshot_sound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = gunshot_sound.mp3; sourceTree = ""; }; AC67C881211C8E24003AA164 /* background_sound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = background_sound.mp3; sourceTree = ""; }; - ACC6F8372121E8DF00CEDC5C /* SoundCalls.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SoundCalls.m; sourceTree = ""; }; - ACC6F8392121E8ED00CEDC5C /* SoundCalls.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SoundCalls.h; sourceTree = ""; }; + AC8032242122F8B100DEA5AC /* SoundCalls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SoundCalls.cpp; sourceTree = ""; }; + AC8032252122F8B100DEA5AC /* SoundCalls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SoundCalls.h; path = ../../../../ios/MediaPlayerC/MediaPlayerC/SoundCalls.h; sourceTree = ""; }; + AC8032282122F8DC00DEA5AC /* BridgeDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgeDelegate.mm; sourceTree = ""; }; + AC8032292122F8DD00DEA5AC /* BridgeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgeDelegate.h; sourceTree = ""; }; + ACC6F8372121E8DF00CEDC5C /* Sounds.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Sounds.m; sourceTree = ""; }; + ACC6F8392121E8ED00CEDC5C /* Sounds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Sounds.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -230,6 +236,7 @@ 4CE6A9E315B2F9A4006A3965 /* Game */ = { isa = PBXGroup; children = ( + AC8032272122F8C500DEA5AC /* Bridages */, AC67C87B211C8DB6003AA164 /* sounds */, 74C3AE251E2E2A40003C07F2 /* creditscode.cpp */, 74C3AE261E2E2A40003C07F2 /* creditscode.h */, @@ -242,6 +249,8 @@ 74C3AE2D1E2E2A40003C07F2 /* menucode.h */, 84D0FECA1E274EBC00EC3FE5 /* main_code.cpp */, 84D0FECB1E274EBC00EC3FE5 /* main_code.h */, + AC8032242122F8B100DEA5AC /* SoundCalls.cpp */, + AC8032252122F8B100DEA5AC /* SoundCalls.h */, ); name = Game; sourceTree = ""; @@ -259,12 +268,21 @@ children = ( AC67C87C211C8DD3003AA164 /* NativeSoundCalls.swift */, AC67C87E211C8DE3003AA164 /* NativeSoundCallsImpl.swift */, - ACC6F8372121E8DF00CEDC5C /* SoundCalls.m */, - ACC6F8392121E8ED00CEDC5C /* SoundCalls.h */, + ACC6F8372121E8DF00CEDC5C /* Sounds.m */, + ACC6F8392121E8ED00CEDC5C /* Sounds.h */, ); name = sounds; sourceTree = ""; }; + AC8032272122F8C500DEA5AC /* Bridages */ = { + isa = PBXGroup; + children = ( + AC8032292122F8DD00DEA5AC /* BridgeDelegate.h */, + AC8032282122F8DC00DEA5AC /* BridgeDelegate.mm */, + ); + name = Bridages; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -370,10 +388,11 @@ buildActionMask = 2147483647; files = ( 74EEBAEF1E2D13A6004C6C65 /* AppDelegate.swift in Sources */, - ACC6F8382121E8DF00CEDC5C /* SoundCalls.m in Sources */, + ACC6F8382121E8DF00CEDC5C /* Sounds.m in Sources */, 74C3AE2E1E2E2A40003C07F2 /* creditscode.cpp in Sources */, 74C3AE2F1E2E2A40003C07F2 /* gamecode.cpp in Sources */, AC67C87D211C8DD3003AA164 /* NativeSoundCalls.swift in Sources */, + AC80322A2122F8DD00DEA5AC /* BridgeDelegate.mm in Sources */, 74EEBAF11E2D1C7C004C6C65 /* CustomGLKView.swift in Sources */, 84D0FECC1E274EBC00EC3FE5 /* main_code.cpp in Sources */, 74C3AE301E2E2A40003C07F2 /* loadingcode.cpp in Sources */, @@ -382,6 +401,7 @@ 74C3AE311E2E2A40003C07F2 /* menucode.cpp in Sources */, AC67C87F211C8DE3003AA164 /* NativeSoundCallsImpl.swift in Sources */, 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */, + AC8032262122F8B100DEA5AC /* SoundCalls.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/proj.ios/SoundCalls.cpp b/proj.ios/SoundCalls.cpp new file mode 100644 index 0000000..e0aee78 --- /dev/null +++ b/proj.ios/SoundCalls.cpp @@ -0,0 +1,22 @@ +#include "SoundCalls.h" +#include "BridgeDelegate.h" + +void SoundCalls::playBackgroundSound() +{ + BridgeDelegate::playGunshotSound(); +} + +void SoundCalls::stopBackgroundSound() +{ + BridgeDelegate::stopBackgroundSound(); +} + +void SoundCalls::playGunshotSound() +{ + BridgeDelegate::playGunshotSound(); +} + +void SoundCalls::stopGunshotSound() +{ + BridgeDelegate::stopGunshotSound(); +} diff --git a/proj.ios/SoundCalls.h b/proj.ios/Sounds.h similarity index 72% rename from proj.ios/SoundCalls.h rename to proj.ios/Sounds.h index a643d7c..fe1f701 100644 --- a/proj.ios/SoundCalls.h +++ b/proj.ios/Sounds.h @@ -1,9 +1,9 @@ #import #import -#define ShareSoundCalls [SoundCalls shareInstance] +#define ShareSounds [Sounds shareInstance] -@interface SoundCalls : NSObject +@interface Sounds : NSObject + (instancetype)shareInstance; diff --git a/proj.ios/SoundCalls.m b/proj.ios/Sounds.m similarity index 92% rename from proj.ios/SoundCalls.m rename to proj.ios/Sounds.m index e4dce98..6f0c609 100644 --- a/proj.ios/SoundCalls.m +++ b/proj.ios/Sounds.m @@ -1,6 +1,6 @@ -#import "SoundCalls.h" +#import "Sounds.h" -@interface SoundCalls () +@interface Sounds () @property (nonatomic, strong) AVAudioPlayer* backgroundPlayer; @@ -8,9 +8,9 @@ @end -@implementation SoundCalls +@implementation Sounds -static SoundCalls *_shareInstance; +static Sounds *_shareInstance; +(instancetype)shareInstance { _shareInstance = [[super allocWithZone:NULL] init];