add cpp code for sound calls
This commit is contained in:
parent
584b48c3ab
commit
47c632946d
16
proj.ios/BridgeDelegate.h
Normal file
16
proj.ios/BridgeDelegate.h
Normal file
@ -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 */
|
22
proj.ios/BridgeDelegate.mm
Normal file
22
proj.ios/BridgeDelegate.mm
Normal file
@ -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];
|
||||
}
|
@ -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 = "<group>"; };
|
||||
AC67C880211C8E24003AA164 /* gunshot_sound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = gunshot_sound.mp3; sourceTree = "<group>"; };
|
||||
AC67C881211C8E24003AA164 /* background_sound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = background_sound.mp3; sourceTree = "<group>"; };
|
||||
ACC6F8372121E8DF00CEDC5C /* SoundCalls.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SoundCalls.m; sourceTree = "<group>"; };
|
||||
ACC6F8392121E8ED00CEDC5C /* SoundCalls.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SoundCalls.h; sourceTree = "<group>"; };
|
||||
AC8032242122F8B100DEA5AC /* SoundCalls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SoundCalls.cpp; sourceTree = "<group>"; };
|
||||
AC8032252122F8B100DEA5AC /* SoundCalls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SoundCalls.h; path = ../../../../ios/MediaPlayerC/MediaPlayerC/SoundCalls.h; sourceTree = "<group>"; };
|
||||
AC8032282122F8DC00DEA5AC /* BridgeDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgeDelegate.mm; sourceTree = "<group>"; };
|
||||
AC8032292122F8DD00DEA5AC /* BridgeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgeDelegate.h; sourceTree = "<group>"; };
|
||||
ACC6F8372121E8DF00CEDC5C /* Sounds.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Sounds.m; sourceTree = "<group>"; };
|
||||
ACC6F8392121E8ED00CEDC5C /* Sounds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Sounds.h; sourceTree = "<group>"; };
|
||||
/* 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 = "<group>";
|
||||
@ -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 = "<group>";
|
||||
};
|
||||
AC8032272122F8C500DEA5AC /* Bridages */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AC8032292122F8DD00DEA5AC /* BridgeDelegate.h */,
|
||||
AC8032282122F8DC00DEA5AC /* BridgeDelegate.mm */,
|
||||
);
|
||||
name = Bridages;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* 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;
|
||||
};
|
||||
|
22
proj.ios/SoundCalls.cpp
Normal file
22
proj.ios/SoundCalls.cpp
Normal file
@ -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();
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#define ShareSoundCalls [SoundCalls shareInstance]
|
||||
#define ShareSounds [Sounds shareInstance]
|
||||
|
||||
@interface SoundCalls : NSObject
|
||||
@interface Sounds : NSObject
|
||||
|
||||
+ (instancetype)shareInstance;
|
||||
|
@ -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];
|
Loading…
Reference in New Issue
Block a user