diff --git a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp index 42dec115f3..6a6539958f 100644 --- a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp +++ b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp @@ -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; diff --git a/cocos/scripting/js-bindings/script/navmesh/jsb_navmesh.js b/cocos/scripting/js-bindings/script/navmesh/jsb_navmesh.js index 9eba194467..f3a379ec6c 100644 --- a/cocos/scripting/js-bindings/script/navmesh/jsb_navmesh.js +++ b/cocos/scripting/js-bindings/script/navmesh/jsb_navmesh.js @@ -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; diff --git a/tests/js-tests/src/NavMeshTest/NavMeshTest.js b/tests/js-tests/src/NavMeshTest/NavMeshTest.js index 8ad38a8a26..4131d4a37f 100644 --- a/tests/js-tests/src/NavMeshTest/NavMeshTest.js +++ b/tests/js-tests/src/NavMeshTest/NavMeshTest.js @@ -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); diff --git a/tools/bindings-generator b/tools/bindings-generator index 301f566839..618fce7b25 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 301f566839fa6505d225dfc376bc3fab4673204f +Subproject commit 618fce7b257aa5d3c68c5671a9368a4685a6b823 diff --git a/tools/tojs/cocos2dx_navmesh.ini b/tools/tojs/cocos2dx_navmesh.ini index adff64a872..9ae8272478 100644 --- a/tools/tojs/cocos2dx_navmesh.ini +++ b/tools/tojs/cocos2dx_navmesh.ini @@ -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*$".