Merge pull request #9 from pandamicro/navmesh

Improve bindings for navmesh
This commit is contained in:
jianglong0156 2015-06-18 23:15:05 +08:00
commit 618d8f01e8
5 changed files with 17 additions and 14 deletions

View File

@ -60,21 +60,24 @@ static bool jsb_cocos2dx_navmesh_NavMeshAgent_move(JSContext *cx, uint32_t argc,
cobj->move(arg0, [=](cocos2d::NavMeshAgent *agent, float totalTimeAfterMove)->void{
jsval arg[2];
js_proxy_t *proxy = js_get_or_create_proxy(cx, agent);
js_proxy_t *agentProxy = js_get_or_create_proxy(cx, agent);
if (proxy)
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
arg[0] = OBJECT_TO_JSVAL(agentProxy->obj);
else
arg[0] = JSVAL_NULL;
arg[1] = DOUBLE_TO_JSVAL((double)totalTimeAfterMove);
JS::RootedValue rval(cx);
bool ok = func->invoke(2, arg, &rval);
if (!ok && JS_IsExceptionPending(cx)) {
bool invokeOk = func->invoke(2, arg, &rval);
if (!invokeOk && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
});
return true;
}
JS_ReportError(cx, "jsb_cocos2dx_navmesh_NavMeshAgent_move : wrong number of arguments: %d, was expecting %d or %d", argc, 1, 2);
return false;
}
extern JSObject *jsb_cocos2d_NavMeshAgent_prototype;

View File

@ -9,7 +9,7 @@ jsb.NavMesh.UpdateFlags =
};
cc.NavMeshAgentParam = function(){
jsb.NavMeshAgentParam = function(){
this.radius = 0.6;
this.height = 2;
this.maxAcceleration = 8;
@ -25,16 +25,16 @@ cc.NavMeshAgentParam = function(){
this.queryFilterType = 0;
}
cc.navMeshAgentParam = function(){
return new cc.NavMeshAgentParam();
jsb.navMeshAgentParam = function(){
return new jsb.NavMeshAgentParam();
};
cc.AgentUserData = function(){
jsb.AgentUserData = function(){
this.time = 0;
};
cc.agentUserData = function(){
return new cc.AgentUserData();
jsb.agentUserData = function(){
return new jsb.AgentUserData();
};
jsb.NavMeshAgent.prototype.setUserData = cc.Node.prototype.setUserData;

View File

@ -138,7 +138,7 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
createAgent:function(pos){
var filePath = "Sprite3DTest/girl.c3b";
var param = cc.navMeshAgentParam();
var param = jsb.navMeshAgentParam();
param.radius = 2.0;
param.height = 8.0;
param.maxSpeed = 8.0;
@ -146,7 +146,7 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
var agentNode = jsb.Sprite3D.create(filePath);
agent.setOrientationRefAxes(cc.math.vec3(-1.0, 0.0, 1.0));
var data = cc.agentUserData();
var data = jsb.agentUserData();
agent.setUserData(data);
agentNode.setScale(0.05);
agentNode.addComponent(agent);

@ -1 +1 @@
Subproject commit 301f566839fa6505d225dfc376bc3fab4673204f
Subproject commit 618fce7b257aa5d3c68c5671a9368a4685a6b823

View File

@ -29,7 +29,7 @@ extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s
# what headers to parse
headers = %(cocosdir)s/cocos/navmesh/CCNavMesh.h
cpp_headers = %(jsbdir)s/manual/navmesh/jsb_cocos2dx_navmesh_conversions.h
cpp_headers = navmesh/jsb_cocos2dx_navmesh_conversions.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".