Cocos2d-x: 3.17
frameworks ▸ cocos2d-x ▸ external
frameworks ▸ cocos2d-x ▸ cocos ▸ scripting ▸ lua-bindings ▸ auto
path:frameworks ▸ cocos2d-x ▸ cocos ▸ scripting ▸ lua-bindings ▸ munual
// 1.include lua_fmod_auto.hpp file
#include "scripting/lua-bindings/auto/lua_fmod_auto.hpp"
// 2.register
bool LuaStack::init(void)
{
...
register_all_cocos2dx_fmod(_state);
...
return true;
}
1.cocos2d_libs.xcodeproj ▸ build setting ▸ User Header Search Paths
"$(SRCROOT)/../external/fmod/include/ios"
2.cocos2d_libs.xcodeproj ▸ build setting ▸ Library Search Paths
"$(SRCROOT)/../external/fmod/prebuilt/ios"
package org.cocos2dx.lua;
import android.os.Bundle;
import org.cocos2dx.lib.Cocos2dxActivity;
public class AppActivity extends Cocos2dxActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);
super.onCreate(savedInstanceState);
// Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
if (!isTaskRoot()) {
// Android launched another instance of the root activity into an existing task
// so just quietly finish and go away, dropping the user back into the activity
// at the top of the stack (ie: the last state of this task)
// Don't need to finish it again since it's finished in super.onCreate .
return;
}
// DO OTHER INITIALIZATION BELOW
org.fmod.FMOD.init(this);
}
@Override
protected void onDestroy() {
org.fmod.FMOD.close();
super.onDestroy();
}
static
{
System.loadLibrary("fmod");
}
}
frameworks ▸ cocos2d-x ▸ cocos ▸ scripting ▸ lua-bindings ▸ android.mk
#fmod
LOCAL_SRC_FILES += ../auto/lua_fmod_auto.cpp \
frameworks ▸ cocos2d-x ▸ cocos ▸ android.mk
1.
LOCAL_STATIC_LIBRARIES += fmod_static
2.
$(call import-module,fmod/prebuilt/android)
LOCAL_PATH := $(call my-dir)
#
# FMOD Shared Library
#
include $(CLEAR_VARS)
LOCAL_MODULE := fmod
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfmodL.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := fmod_static
LOCAL_SRC_FILES := ../../FMODAudioEngine.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../../.. \
$(LOCAL_PATH)/../../../../cocos
LOCAL_SHARED_LIBRARIES := fmod
include $(BUILD_STATIC_LIBRARY)
engine = fmod.FMODAudioengine:getInstance()
-- preload
engine:reload(path)
-- play
nSoundID = engine:playSound(path)
-- pause
engine:pauseSound(nSoundID)
-- stop
engine:stopSound(nSoundID)
-- resume
engine:resumeSound(nSoundID)
-- release
engine:releaseSound(path)
[email protected] QQ:9737935