mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Merge pull request #909 from dumganhar/jsb2.0
Supports cocos analytics for Android. iOS support is on the road.
This commit is contained in:
@@ -67,23 +67,25 @@ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxJavascriptJavaBridge_evalSt
|
||||
class JavaScriptJavaBridge
|
||||
{
|
||||
public:
|
||||
typedef enum : char
|
||||
enum class ValueType: char
|
||||
{
|
||||
TypeInvalid = -1,
|
||||
TypeVoid = 0,
|
||||
TypeInteger = 1,
|
||||
TypeFloat = 2,
|
||||
TypeBoolean = 3,
|
||||
TypeString = 4,
|
||||
TypeVector = 5,
|
||||
TypeFunction= 6,
|
||||
} ValueType;
|
||||
INVALID,
|
||||
VOID,
|
||||
INTEGER,
|
||||
LONG,
|
||||
FLOAT,
|
||||
BOOLEAN,
|
||||
STRING,
|
||||
VECTOR,
|
||||
FUNCTION
|
||||
};
|
||||
|
||||
typedef std::vector<ValueType> ValueTypes;
|
||||
|
||||
typedef union
|
||||
{
|
||||
int intValue;
|
||||
long longValue;
|
||||
float floatValue;
|
||||
int boolValue;
|
||||
std::string *stringValue;
|
||||
@@ -98,7 +100,7 @@ public:
|
||||
, m_className(className)
|
||||
, m_methodName(methodName)
|
||||
, m_methodSig(methodSig)
|
||||
, m_returnType(TypeVoid)
|
||||
, m_returnType(ValueType::VOID)
|
||||
, m_argumentsCount(0)
|
||||
, m_retjstring(NULL)
|
||||
, m_env(NULL)
|
||||
@@ -122,7 +124,7 @@ public:
|
||||
return m_env;
|
||||
}
|
||||
|
||||
int argumentTypeAtIndex(size_t index) {
|
||||
ValueType argumentTypeAtIndex(size_t index) {
|
||||
return m_argumentsType.at(index);
|
||||
}
|
||||
|
||||
@@ -170,7 +172,7 @@ public:
|
||||
|
||||
JavaScriptJavaBridge::CallInfo::~CallInfo()
|
||||
{
|
||||
if (m_returnType == TypeString && m_ret.stringValue)
|
||||
if (m_returnType == ValueType::STRING && m_ret.stringValue)
|
||||
{
|
||||
delete m_ret.stringValue;
|
||||
}
|
||||
@@ -180,23 +182,27 @@ bool JavaScriptJavaBridge::CallInfo::execute()
|
||||
{
|
||||
switch (m_returnType)
|
||||
{
|
||||
case JavaScriptJavaBridge::TypeVoid:
|
||||
case JavaScriptJavaBridge::ValueType::VOID:
|
||||
m_env->CallStaticVoidMethod(m_classID, m_methodID);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeInteger:
|
||||
case JavaScriptJavaBridge::ValueType::INTEGER:
|
||||
m_ret.intValue = m_env->CallStaticIntMethod(m_classID, m_methodID);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeFloat:
|
||||
case JavaScriptJavaBridge::ValueType::LONG:
|
||||
m_ret.longValue = m_env->CallStaticLongMethod(m_classID, m_methodID);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::ValueType::FLOAT:
|
||||
m_ret.floatValue = m_env->CallStaticFloatMethod(m_classID, m_methodID);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeBoolean:
|
||||
case JavaScriptJavaBridge::ValueType::BOOLEAN:
|
||||
m_ret.boolValue = m_env->CallStaticBooleanMethod(m_classID, m_methodID);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeString:
|
||||
case JavaScriptJavaBridge::ValueType::STRING:
|
||||
{
|
||||
m_retjstring = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID);
|
||||
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjstring);
|
||||
@@ -227,23 +233,27 @@ bool JavaScriptJavaBridge::CallInfo::executeWithArgs(jvalue *args)
|
||||
{
|
||||
switch (m_returnType)
|
||||
{
|
||||
case JavaScriptJavaBridge::TypeVoid:
|
||||
case JavaScriptJavaBridge::ValueType::VOID:
|
||||
m_env->CallStaticVoidMethodA(m_classID, m_methodID, args);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeInteger:
|
||||
case JavaScriptJavaBridge::ValueType::INTEGER:
|
||||
m_ret.intValue = m_env->CallStaticIntMethodA(m_classID, m_methodID, args);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeFloat:
|
||||
case JavaScriptJavaBridge::ValueType::LONG:
|
||||
m_ret.longValue = m_env->CallStaticIntMethodA(m_classID, m_methodID, args);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::ValueType::FLOAT:
|
||||
m_ret.floatValue = m_env->CallStaticFloatMethodA(m_classID, m_methodID, args);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeBoolean:
|
||||
case JavaScriptJavaBridge::ValueType::BOOLEAN:
|
||||
m_ret.boolValue = m_env->CallStaticBooleanMethodA(m_classID, m_methodID, args);
|
||||
break;
|
||||
|
||||
case JavaScriptJavaBridge::TypeString:
|
||||
case JavaScriptJavaBridge::ValueType::STRING:
|
||||
{
|
||||
m_retjstring = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args);
|
||||
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjstring);
|
||||
@@ -281,7 +291,7 @@ bool JavaScriptJavaBridge::CallInfo::validateMethodSig()
|
||||
while (pos < len && m_methodSig[pos] != ')')
|
||||
{
|
||||
JavaScriptJavaBridge::ValueType type = checkType(m_methodSig, &pos);
|
||||
if (type == TypeInvalid) return false;
|
||||
if (type == ValueType::INVALID) return false;
|
||||
|
||||
m_argumentsCount++;
|
||||
m_argumentsType.push_back(type);
|
||||
@@ -304,41 +314,43 @@ JavaScriptJavaBridge::ValueType JavaScriptJavaBridge::CallInfo::checkType(const
|
||||
switch (sig[*pos])
|
||||
{
|
||||
case 'I':
|
||||
return JavaScriptJavaBridge::TypeInteger;
|
||||
return JavaScriptJavaBridge::ValueType::INTEGER;
|
||||
case 'J':
|
||||
return JavaScriptJavaBridge::ValueType::LONG;
|
||||
case 'F':
|
||||
return JavaScriptJavaBridge::TypeFloat;
|
||||
return JavaScriptJavaBridge::ValueType::FLOAT;
|
||||
case 'Z':
|
||||
return JavaScriptJavaBridge::TypeBoolean;
|
||||
return JavaScriptJavaBridge::ValueType::BOOLEAN;
|
||||
case 'V':
|
||||
return JavaScriptJavaBridge::TypeVoid;
|
||||
return JavaScriptJavaBridge::ValueType::VOID;
|
||||
case 'L':
|
||||
size_t pos2 = sig.find_first_of(';', *pos + 1);
|
||||
if (pos2 == std::string::npos)
|
||||
{
|
||||
m_error = JSJ_ERR_INVALID_SIGNATURES;
|
||||
return TypeInvalid;
|
||||
return ValueType::INVALID;
|
||||
}
|
||||
|
||||
const std::string t = sig.substr(*pos, pos2 - *pos + 1);
|
||||
if (t.compare("Ljava/lang/String;") == 0)
|
||||
{
|
||||
*pos = pos2;
|
||||
return TypeString;
|
||||
return ValueType::STRING;
|
||||
}
|
||||
else if (t.compare("Ljava/util/Vector;") == 0)
|
||||
{
|
||||
*pos = pos2;
|
||||
return TypeVector;
|
||||
return ValueType::VECTOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_error = JSJ_ERR_TYPE_NOT_SUPPORT;
|
||||
return TypeInvalid;
|
||||
return ValueType::INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
m_error = JSJ_ERR_TYPE_NOT_SUPPORT;
|
||||
return TypeInvalid;
|
||||
return ValueType::INVALID;
|
||||
}
|
||||
|
||||
|
||||
@@ -403,16 +415,19 @@ bool JavaScriptJavaBridge::convertReturnValue(ReturnValue retValue, ValueType ty
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case JavaScriptJavaBridge::TypeInteger:
|
||||
case JavaScriptJavaBridge::ValueType::INTEGER:
|
||||
ret->setInt32(retValue.intValue);
|
||||
break;
|
||||
case JavaScriptJavaBridge::TypeFloat:
|
||||
case JavaScriptJavaBridge::ValueType::LONG:
|
||||
ret->setLong(retValue.longValue);
|
||||
break;
|
||||
case JavaScriptJavaBridge::ValueType::FLOAT:
|
||||
ret->setFloat(retValue.floatValue);
|
||||
break;
|
||||
case JavaScriptJavaBridge::TypeBoolean:
|
||||
case JavaScriptJavaBridge::ValueType::BOOLEAN:
|
||||
ret->setBoolean(retValue.boolValue);
|
||||
break;
|
||||
case JavaScriptJavaBridge::TypeString:
|
||||
case JavaScriptJavaBridge::ValueType::STRING:
|
||||
ret->setString(*retValue.stringValue);
|
||||
break;
|
||||
default:
|
||||
@@ -497,26 +512,33 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State& s)
|
||||
int index = i + 3;
|
||||
switch (call.argumentTypeAtIndex(i))
|
||||
{
|
||||
case JavaScriptJavaBridge::TypeInteger:
|
||||
case JavaScriptJavaBridge::ValueType::INTEGER:
|
||||
{
|
||||
int integer = 0;
|
||||
seval_to_int32(args[index], &integer);
|
||||
jargs[i].i = integer;
|
||||
break;
|
||||
}
|
||||
case JavaScriptJavaBridge::TypeFloat:
|
||||
case JavaScriptJavaBridge::ValueType::LONG:
|
||||
{
|
||||
long longVal = 0L;
|
||||
seval_to_long(args[index], &longVal);
|
||||
jargs[i].j = longVal;
|
||||
break;
|
||||
}
|
||||
case JavaScriptJavaBridge::ValueType::FLOAT:
|
||||
{
|
||||
float floatNumber = 0.0f;
|
||||
seval_to_float(args[index], &floatNumber);
|
||||
jargs[i].f = floatNumber;
|
||||
break;
|
||||
}
|
||||
case JavaScriptJavaBridge::TypeBoolean:
|
||||
case JavaScriptJavaBridge::ValueType::BOOLEAN:
|
||||
{
|
||||
jargs[i].z = args[index].isBoolean() && args[index].toBoolean() ? JNI_TRUE : JNI_FALSE;
|
||||
break;
|
||||
}
|
||||
case JavaScriptJavaBridge::TypeString:
|
||||
case JavaScriptJavaBridge::ValueType::STRING:
|
||||
default:
|
||||
std::string str;
|
||||
seval_to_std_string(args[index], &str);
|
||||
|
||||
@@ -51,3 +51,5 @@ if (window.dragonBones) {
|
||||
}
|
||||
|
||||
require("script/jsb_audioengine.js");
|
||||
require("script/jsb_cocosanalytics.js");
|
||||
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
(function(){
|
||||
|
||||
var sys = cc.sys;
|
||||
var platform = sys.platform;
|
||||
|
||||
// Only android and iOS support cocos analytics
|
||||
if (platform === sys.ANDROID) {
|
||||
|
||||
cocosAnalytics = {};
|
||||
|
||||
var cls_CAAccount = "com/cocos/analytics/CAAccount";
|
||||
var cls_CAAgent = "com/cocos/analytics/CAAgent";
|
||||
var cls_CAEvent = "com/cocos/analytics/CAEvent";
|
||||
var cls_CAItem = "com/cocos/analytics/CAItem";
|
||||
var cls_CALevels = "com/cocos/analytics/CALevels";
|
||||
var cls_CAPayment = "com/cocos/analytics/CAPayment";
|
||||
var cls_CATask = "com/cocos/analytics/CATask";
|
||||
var cls_CAVirtual = "com/cocos/analytics/CAVirtual";
|
||||
|
||||
var cls_CAAgentWrapper = "org/cocos2dx/lib/CAAgentWrapper";
|
||||
|
||||
cocosAnalytics.init = function(info) {
|
||||
if (info && info.appID && info.appSecret && info.channel) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAgentWrapper,
|
||||
"init", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
info.channel, info.appID, info.appSecret);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.init are wrong!");
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CAAccount = {
|
||||
loginStart: function() {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "loginStart", "()V");
|
||||
},
|
||||
|
||||
loginSuccess: function(info) {
|
||||
if (info && info.userID) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "loginSuccess", "(Ljava/lang/String;)V", info.userID);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAAccount.loginSuccess are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
loginFailed: function() {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "loginFailed", "()V");
|
||||
},
|
||||
|
||||
logout: function(info) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "logout", "()V");
|
||||
},
|
||||
|
||||
setAccountType: function(type) {
|
||||
if (type) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "setAccountType", "(Ljava/lang/String;)V", type);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAAccount.setAccountType are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
setAge: function(age) {
|
||||
if (age) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "setAge", "(I)V", age);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CAAccount.setAge is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
setGender: function(gender) {
|
||||
if (gender) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "setGender", "(I)V", gender);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CAAccount.setGender is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
setLevel: function(level) {
|
||||
if (level) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount, "setLevel", "(I)V", level);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CAAccount.setLevel is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
createRole: function(info) {
|
||||
if (info && info.roleID && info.userName && info.race && info['class'] && info.gameServer) {
|
||||
jsb.reflection.callStaticMethod(cls_CAAccount,
|
||||
"createRole", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
info.roleID, info.userName, info.race, info['class'], info.gameServer);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAAccount.createRole are wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CAEvent = {
|
||||
onEvent: function(info) {
|
||||
if (info && info.eventName) {
|
||||
jsb.reflection.callStaticMethod(cls_CAEvent, "onEvent", "(Ljava/lang/String;)V", info.eventName);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CAEvent.onEvent is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
onEventStart: function(info) {
|
||||
if (info && info.eventName) {
|
||||
jsb.reflection.callStaticMethod(cls_CAEvent, "onEventStart", "(Ljava/lang/String;)V", info.eventName);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CAEvent.onEventStart is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
onEventEnd: function(info) {
|
||||
if (info && info.eventName) {
|
||||
jsb.reflection.callStaticMethod(cls_CAEvent, "onEventEnd", "(Ljava/lang/String;)V", info.eventName);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CAEvent.onEventEnd is wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CAPayment = {
|
||||
payBegin: function(info) {
|
||||
if (info && info.amount && info.orderID && info.payType && info.iapID && info.currencyType) {
|
||||
jsb.reflection.callStaticMethod(cls_CAPayment,
|
||||
"payBegin", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
info.amount, info.orderID, info.payType, info.iapID, info.currencyType);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAPayment.payBegin are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
paySuccess: function(info) {
|
||||
if (info && info.amount && info.orderID && info.payType && info.iapID && info.currencyType) {
|
||||
jsb.reflection.callStaticMethod(cls_CAPayment,
|
||||
"paySuccess", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
info.amount, info.orderID, info.payType, info.iapID, info.currencyType);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAPayment.paySuccess are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
payFailed: function(info) {
|
||||
if (info && info.amount && info.orderID && info.payType && info.iapID && info.currencyType) {
|
||||
jsb.reflection.callStaticMethod(cls_CAPayment,
|
||||
"payFailed", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
info.amount, info.orderID, info.payType, info.iapID, info.currencyType);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAPayment.payFailed are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
payCanceled: function(info) {
|
||||
if (info && info.amount && info.orderID && info.payType && info.iapID && info.currencyType) {
|
||||
jsb.reflection.callStaticMethod(cls_CAPayment,
|
||||
"payCanceled", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
info.amount, info.orderID, info.payType, info.iapID, info.currencyType);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAPayment.payCanceled are wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CALevels = {
|
||||
begin: function(info) {
|
||||
if (info && info.level) {
|
||||
jsb.reflection.callStaticMethod(cls_CALevels, "begin", "(Ljava/lang/String;)V", info.level);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CALevels.begin is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
complete: function(info) {
|
||||
if (info && info.level) {
|
||||
jsb.reflection.callStaticMethod(cls_CALevels, "complete", "(Ljava/lang/String;)V", info.level);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CALevels.complete is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
failed: function(info) {
|
||||
if (info && info.level) {
|
||||
info.reason = info.reason || "";
|
||||
jsb.reflection.callStaticMethod(cls_CALevels, "failed", "(Ljava/lang/String;Ljava/lang/String;)V", info.level, info.reason);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CALevels.failed are wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CATaskType = {
|
||||
GuideLine: 1,
|
||||
MainLine: 2,
|
||||
BranchLine: 3,
|
||||
Daily: 4,
|
||||
Activity: 5,
|
||||
Other: 100
|
||||
};
|
||||
|
||||
cocosAnalytics.CATask = {
|
||||
|
||||
begin: function(info) {
|
||||
if (info && info.taskID && info.type) {
|
||||
jsb.reflection.callStaticMethod(cls_CATask, "begin", "(Ljava/lang/String;I)V", info.taskID, info.type);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CATask.begin are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
complete: function(info) {
|
||||
if (info && info.taskID) {
|
||||
jsb.reflection.callStaticMethod(cls_CATask, "complete", "(Ljava/lang/String;)V", info.taskID);
|
||||
} else {
|
||||
console.error("The argument passed to cocosAnalytics.CATask.complete is wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
failed: function(info) {
|
||||
if (info && info.taskID) {
|
||||
info.reason = info.reason || "";
|
||||
jsb.reflection.callStaticMethod(cls_CATask, "failed", "(Ljava/lang/String;Ljava/lang/String;)V", info.taskID, info.reason);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CATask.failed are wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CAItem = {
|
||||
buy: function(info) {
|
||||
if (info && info.itemID && info.itemType && info.itemCount && info.virtualCoin && info.virtualType && info.consumePoint) {
|
||||
jsb.reflection.callStaticMethod(cls_CAItem, "buy", "(Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;Ljava/lang/String;)V",
|
||||
info.itemID, info.itemType, info.itemCount, info.virtualCoin, info.virtualType, info.consumePoint);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAItem.buy are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
get: function(info) {
|
||||
if (info && info.itemID && info.itemType && info.itemCount && info.reason) {
|
||||
jsb.reflection.callStaticMethod(cls_CAItem, "get", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V",
|
||||
info.itemID, info.itemType, info.itemCount, info.reason);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAItem.get are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
consume: function(info) {
|
||||
if (info && info.itemID && info.itemType && info.itemCount && info.reason) {
|
||||
jsb.reflection.callStaticMethod(cls_CAItem, "consume", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V",
|
||||
info.itemID, info.itemType, info.itemCount, info.reason);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAItem.consume are wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cocosAnalytics.CAVirtual = {
|
||||
setVirtualNum: function(info) {
|
||||
if (info && info.type && info.count) {
|
||||
jsb.reflection.callStaticMethod(cls_CAVirtual, "setVirtualNum", "(Ljava/lang/String;J)V",
|
||||
info.type, info.count);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAVirtual.setVirtualNum are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
get: function(info) {
|
||||
if (info && info.type && info.count && info.reason) {
|
||||
jsb.reflection.callStaticMethod(cls_CAVirtual, "get", "(Ljava/lang/String;JLjava/lang/String;)V",
|
||||
info.type, info.count, info.reason);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAVirtual.get are wrong!");
|
||||
}
|
||||
},
|
||||
|
||||
consume: function(info) {
|
||||
if (info && info.type && info.count && info.reason) {
|
||||
jsb.reflection.callStaticMethod(cls_CAVirtual, "consume", "(Ljava/lang/String;JLjava/lang/String;)V",
|
||||
info.type, info.count, info.reason);
|
||||
} else {
|
||||
console.error("The arguments passed to cocosAnalytics.CAVirtual.consume are wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} else if (platform === sys.IPAD || platform === sys.IPHONE) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user