mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9 from pandamicro/navmesh
Improve bindings for navmesh
This commit is contained in:
commit
618d8f01e8
|
@ -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{
|
cobj->move(arg0, [=](cocos2d::NavMeshAgent *agent, float totalTimeAfterMove)->void{
|
||||||
jsval arg[2];
|
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)
|
if (proxy)
|
||||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
arg[0] = OBJECT_TO_JSVAL(agentProxy->obj);
|
||||||
else
|
else
|
||||||
arg[0] = JSVAL_NULL;
|
arg[0] = JSVAL_NULL;
|
||||||
arg[1] = DOUBLE_TO_JSVAL((double)totalTimeAfterMove);
|
arg[1] = DOUBLE_TO_JSVAL((double)totalTimeAfterMove);
|
||||||
JS::RootedValue rval(cx);
|
JS::RootedValue rval(cx);
|
||||||
|
|
||||||
bool ok = func->invoke(2, arg, &rval);
|
bool invokeOk = func->invoke(2, arg, &rval);
|
||||||
if (!ok && JS_IsExceptionPending(cx)) {
|
if (!invokeOk && JS_IsExceptionPending(cx)) {
|
||||||
JS_ReportPendingException(cx);
|
JS_ReportPendingException(cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
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;
|
extern JSObject *jsb_cocos2d_NavMeshAgent_prototype;
|
||||||
|
|
|
@ -9,7 +9,7 @@ jsb.NavMesh.UpdateFlags =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cc.NavMeshAgentParam = function(){
|
jsb.NavMeshAgentParam = function(){
|
||||||
this.radius = 0.6;
|
this.radius = 0.6;
|
||||||
this.height = 2;
|
this.height = 2;
|
||||||
this.maxAcceleration = 8;
|
this.maxAcceleration = 8;
|
||||||
|
@ -25,16 +25,16 @@ cc.NavMeshAgentParam = function(){
|
||||||
this.queryFilterType = 0;
|
this.queryFilterType = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.navMeshAgentParam = function(){
|
jsb.navMeshAgentParam = function(){
|
||||||
return new cc.NavMeshAgentParam();
|
return new jsb.NavMeshAgentParam();
|
||||||
};
|
};
|
||||||
|
|
||||||
cc.AgentUserData = function(){
|
jsb.AgentUserData = function(){
|
||||||
this.time = 0;
|
this.time = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
cc.agentUserData = function(){
|
jsb.agentUserData = function(){
|
||||||
return new cc.AgentUserData();
|
return new jsb.AgentUserData();
|
||||||
};
|
};
|
||||||
|
|
||||||
jsb.NavMeshAgent.prototype.setUserData = cc.Node.prototype.setUserData;
|
jsb.NavMeshAgent.prototype.setUserData = cc.Node.prototype.setUserData;
|
||||||
|
|
|
@ -138,7 +138,7 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
|
||||||
|
|
||||||
createAgent:function(pos){
|
createAgent:function(pos){
|
||||||
var filePath = "Sprite3DTest/girl.c3b";
|
var filePath = "Sprite3DTest/girl.c3b";
|
||||||
var param = cc.navMeshAgentParam();
|
var param = jsb.navMeshAgentParam();
|
||||||
param.radius = 2.0;
|
param.radius = 2.0;
|
||||||
param.height = 8.0;
|
param.height = 8.0;
|
||||||
param.maxSpeed = 8.0;
|
param.maxSpeed = 8.0;
|
||||||
|
@ -146,7 +146,7 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
|
||||||
var agentNode = jsb.Sprite3D.create(filePath);
|
var agentNode = jsb.Sprite3D.create(filePath);
|
||||||
agent.setOrientationRefAxes(cc.math.vec3(-1.0, 0.0, 1.0));
|
agent.setOrientationRefAxes(cc.math.vec3(-1.0, 0.0, 1.0));
|
||||||
|
|
||||||
var data = cc.agentUserData();
|
var data = jsb.agentUserData();
|
||||||
agent.setUserData(data);
|
agent.setUserData(data);
|
||||||
agentNode.setScale(0.05);
|
agentNode.setScale(0.05);
|
||||||
agentNode.addComponent(agent);
|
agentNode.addComponent(agent);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 301f566839fa6505d225dfc376bc3fab4673204f
|
Subproject commit 618fce7b257aa5d3c68c5671a9368a4685a6b823
|
|
@ -29,7 +29,7 @@ extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s
|
||||||
# what headers to parse
|
# what headers to parse
|
||||||
headers = %(cocosdir)s/cocos/navmesh/CCNavMesh.h
|
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
|
# 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*$".
|
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||||
|
|
Loading…
Reference in New Issue