plugins:
夸平台付费、一些分享、用户数据信息统计。
1.ios引进文件
1.用 python 脚本创建多平台工程。
2. 引进 -ObjC
3.添加关联的文件 目录
4.
/Users/admin/Downloads/project/cocos2d-x-2.2/plugin 此目录下的 ios 工程都拖到你创建的工程下面。
5.关联的库添加进来
参考网址: http://blog.csdn.net/emcodelin/article/details/9381481
6. 引进 jsbindings
/Users/admin/Downloads/project/cocos2d-x-2.2/plugin/jsbindings
AppDelegate.h
不引进下面的东西会报错
#include "jsb_pluginx_protocols_auto.hpp" //头文件
#include "jsb_pluginx_extension_registration.h"
7.代码:
#include "jsb_pluginx_protocols_auto.hpp"
#include "jsb_pluginx_extension_registration.h"
AppDelegate.cpp
bool AppDelegate::applicationDidFinishLaunching()
{
。。。
sc->addRegisterCallback(register_all_pluginx_protocols);
sc->addRegisterCallback(register_pluginx_js_extensions);
}void AppDelegate::applicationDidEnterBackground()
{
ScriptingCore* sc = ScriptingCore::getInstance();
jsval nsval;
JS_GetProperty(sc->getGlobalContext(), sc->getGlobalObject(), "plugin", &nsval);
if (nsval != JSVAL_VOID) {
sc->executeFunctionWithOwner(nsval, "onApplicationDidEnterBackground");
}
}
void AppDelegate::applicationWillEnterForeground()
{
ScriptingCore* sc = ScriptingCore::getInstance();
jsval nsval;
JS_GetProperty(sc->getGlobalContext(), sc->getGlobalObject(), "plugin", &nsval);
if (nsval != JSVAL_VOID) {
sc->executeFunctionWithOwner(nsval, "onApplicationWillEnterForeground");
}
}
main.js
if(plugin){
plugin.onApplicationDidEnterBackground = function() {
cc.log(" plugin.onApplicationDidEnterBackground.");
};
plugin.onApplicationWillEnterForeground = function() {
cc.log("plugin.onApplicationWillEnterForegro.");
};
}