mirror of https://github.com/axmolengine/axmol.git
issue #3401: physical lua banding script and auto script
This commit is contained in:
parent
1900366c77
commit
0a06d93328
|
@ -1 +1 @@
|
|||
812ab716d10a52b752f0d15b2393b2b0a7c8e969
|
||||
a3e4511d559fcc89e5789f2cc4fe2afafad3aec9
|
|
@ -229,7 +229,7 @@ void PhysicsShape::setFriction(float friction)
|
|||
}
|
||||
|
||||
|
||||
Point* PhysicsShape::recenterPoints(Point* points, int count, const Point& center)
|
||||
void PhysicsShape::recenterPoints(Point* points, int count, const Point& center)
|
||||
{
|
||||
cpVect* cpvs = new cpVect[count];
|
||||
cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count));
|
||||
|
@ -243,8 +243,6 @@ Point* PhysicsShape::recenterPoints(Point* points, int count, const Point& cente
|
|||
points[i] += center;
|
||||
}
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
Point PhysicsShape::getPolyonCenter(const Point* points, int count)
|
||||
|
@ -655,6 +653,15 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material
|
|||
return false;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgeBox::getPoints(cocos2d::Point *outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
{
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a);
|
||||
}
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeBox
|
||||
PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
{
|
||||
|
@ -712,6 +719,15 @@ Point PhysicsShapeEdgePolygon::getCenter()
|
|||
return _center;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgePolygon::getPoints(cocos2d::Point *outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
{
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a);
|
||||
}
|
||||
}
|
||||
|
||||
int PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
{
|
||||
return static_cast<int>(_info->getShapes().size() + 1);
|
||||
|
@ -773,6 +789,17 @@ Point PhysicsShapeEdgeChain::getCenter()
|
|||
return _center;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgeChain::getPoints(Point* outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
{
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a);
|
||||
}
|
||||
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_info->getShapes().back())->a);
|
||||
}
|
||||
|
||||
int PhysicsShapeEdgeChain::getPointsCount() const
|
||||
{
|
||||
return static_cast<int>(_info->getShapes().size() + 1);
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
bool containsPoint(const Point& point) const;
|
||||
|
||||
/** move the points to the center */
|
||||
static Point* recenterPoints(Point* points, int count, const Point& center = Point::ZERO);
|
||||
static void recenterPoints(Point* points, int count, const Point& center = Point::ZERO);
|
||||
/** get center of the polyon points */
|
||||
static Point getPolyonCenter(const Point* points, int count);
|
||||
|
||||
|
@ -282,8 +282,8 @@ class PhysicsShapeEdgeBox : public PhysicsShape
|
|||
public:
|
||||
static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Point& offset = Point::ZERO);
|
||||
virtual Point getOffset() override { return _offset; }
|
||||
void getPoints(const Point* outPoints) const;
|
||||
int getPointsCount() const;
|
||||
void getPoints(Point* outPoints) const;
|
||||
int getPointsCount() const { return 4; }
|
||||
|
||||
protected:
|
||||
bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Point& offset = Point::ZERO);
|
||||
|
|
|
@ -58,6 +58,8 @@ extern "C" {
|
|||
#include "lua_cocos2dx_coco_studio_manual.hpp"
|
||||
#include "lua_cocos2dx_spine_auto.hpp"
|
||||
#include "lua_cocos2dx_spine_manual.hpp"
|
||||
#include "lua_cocos2dx_physics_auto.hpp"
|
||||
#include "lua_cocos2dx_physics_manual.hpp"
|
||||
|
||||
namespace {
|
||||
int lua_print(lua_State * luastate)
|
||||
|
@ -156,6 +158,10 @@ bool LuaStack::init(void)
|
|||
register_all_cocos2dx_spine(_state);
|
||||
register_all_cocos2dx_spine_manual(_state);
|
||||
register_glnode_manual(_state);
|
||||
#if CC_USE_PHYSICS
|
||||
register_all_cocos2dx_physics(_state);
|
||||
register_all_cocos2dx_physics_manual(_state);
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
LuaObjcBridge::luaopen_luaoc(_state);
|
||||
#endif
|
||||
|
|
|
@ -307,6 +307,43 @@ bool luaval_to_point(lua_State* L,int lo,Point* outValue)
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool luaval_to_physics_material(lua_State* L,int lo,PhysicsMaterial* outValue)
|
||||
{
|
||||
if (NULL == L || NULL == outValue)
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err) )
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
|
||||
if (ok)
|
||||
{
|
||||
lua_pushstring(L, "density");
|
||||
lua_gettable(L, lo);
|
||||
outValue->density = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "restitution");
|
||||
lua_gettable(L, lo);
|
||||
outValue->restitution = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "friction");
|
||||
lua_gettable(L, lo);
|
||||
outValue->friction = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool luaval_to_ssize(lua_State* L,int lo, ssize_t* outValue)
|
||||
{
|
||||
return luaval_to_long(L, lo, reinterpret_cast<long*>(outValue));
|
||||
|
@ -1515,6 +1552,22 @@ void point_to_luaval(lua_State* L,const Point& pt)
|
|||
lua_rawset(L, -3); /* table[key] = value, L: table */
|
||||
}
|
||||
|
||||
void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm)
|
||||
{
|
||||
if (NULL == L)
|
||||
return;
|
||||
lua_newtable(L); /* L: table */
|
||||
lua_pushstring(L, "density"); /* L: table key */
|
||||
lua_pushnumber(L, (lua_Number) pm.density); /* L: table key value*/
|
||||
lua_rawset(L, -3); /* table[key] = value, L: table */
|
||||
lua_pushstring(L, "restitution"); /* L: table key */
|
||||
lua_pushnumber(L, (lua_Number) pm.restitution); /* L: table key value*/
|
||||
lua_rawset(L, -3); /* table[key] = value, L: table */
|
||||
lua_pushstring(L, "friction"); /* L: table key */
|
||||
lua_pushnumber(L, (lua_Number) pm.friction); /* L: table key value*/
|
||||
lua_rawset(L, -3); /* table[key] = value, L: table */
|
||||
}
|
||||
|
||||
void size_to_luaval(lua_State* L,const Size& sz)
|
||||
{
|
||||
if (NULL == L)
|
||||
|
|
|
@ -41,6 +41,7 @@ extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue);
|
|||
extern bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue);
|
||||
extern bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue);
|
||||
extern bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue);
|
||||
extern bool luaval_to_physics_material(lua_State* L,int lo, cocos2d::PhysicsMaterial* outValue);
|
||||
extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue);
|
||||
extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue );
|
||||
extern bool luaval_to_array(lua_State* L,int lo, Array** outValue);
|
||||
|
@ -177,6 +178,7 @@ extern void rect_to_luaval(lua_State* L,const Rect& rt);
|
|||
extern void color3b_to_luaval(lua_State* L,const Color3B& cc);
|
||||
extern void color4b_to_luaval(lua_State* L,const Color4B& cc);
|
||||
extern void color4f_to_luaval(lua_State* L,const Color4F& cc);
|
||||
extern void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm);
|
||||
extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue);
|
||||
extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue);
|
||||
extern void array_to_luaval(lua_State* L,Array* inValue);
|
||||
|
|
|
@ -0,0 +1,390 @@
|
|||
#include "lua_cocos2dx_manual.hpp"
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tolua_fix.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "LuaBasicConversions.h"
|
||||
#include "CCLuaValue.h"
|
||||
#include "CCLuaEngine.h"
|
||||
|
||||
int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsBody* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getJoints'", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
do {
|
||||
|
||||
if(!ok)
|
||||
return 0;
|
||||
auto& ret = cobj->getJoints();
|
||||
|
||||
lua_newtable(tolua_S);
|
||||
|
||||
if (ret.empty())
|
||||
return 1;
|
||||
|
||||
auto iter = ret.begin();
|
||||
int indexTable = 1;
|
||||
for (; iter != ret.end(); ++iter)
|
||||
{
|
||||
if (nullptr == *iter)
|
||||
continue;
|
||||
|
||||
std::string hashName = typeid(*iter).name();
|
||||
auto name = g_luaType.find(hashName);
|
||||
std::string className = "";
|
||||
if(name != g_luaType.end()){
|
||||
className = name->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsJoint";
|
||||
}
|
||||
|
||||
lua_pushnumber(tolua_S, (lua_Number)indexTable);
|
||||
tolua_pushusertype(tolua_S,(void*)(*iter), className.c_str());
|
||||
lua_rawset(tolua_S, -3);
|
||||
++indexTable;
|
||||
}
|
||||
} while (0);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getJoints",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getJoints'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsWorld* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
cocos2d::Scene& ret = cobj->getScene();
|
||||
do {
|
||||
|
||||
std::string hashName = typeid(ret).name();
|
||||
auto iter = g_luaType.find(hashName);
|
||||
std::string className = "";
|
||||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "Scene";
|
||||
}
|
||||
|
||||
int ID = (int)(ret._ID);
|
||||
int* luaID = &(ret._luaID);
|
||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)(&ret),className.c_str());
|
||||
|
||||
}while (0);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScene",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsWorld* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 4)
|
||||
{
|
||||
std::function<bool (cocos2d::PhysicsWorld &, const cocos2d::PhysicsRayCastInfo &, void *)> arg0;
|
||||
cocos2d::Point arg1;
|
||||
cocos2d::Point arg2;
|
||||
do {
|
||||
arg0 = [tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool
|
||||
{
|
||||
LuaStack* stack = LuaStack::create();
|
||||
std::string hashName = typeid(&world).name();
|
||||
auto iter = g_luaType.find(hashName);
|
||||
std::string className = "";
|
||||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsWorld";
|
||||
}
|
||||
|
||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
||||
tolua_pushusertype(tolua_S, (void*)(&info), "PhysicsRayCastInfo");
|
||||
bool ret = stack->executeFunction(2);
|
||||
stack->clean();
|
||||
return ret;
|
||||
};
|
||||
} while(0)
|
||||
;
|
||||
ok &= luaval_to_point(tolua_S, 3, &arg1);
|
||||
ok &= luaval_to_point(tolua_S, 4, &arg2);
|
||||
#pragma warning NO CONVERSION TO NATIVE FOR void*;
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->rayCast(arg0, arg1, arg2, nullptr);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rayCast",argc, 4);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsWorld* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_queryRect'", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 3)
|
||||
{
|
||||
std::function<bool (cocos2d::PhysicsWorld &, cocos2d::PhysicsShape &, void *)> arg0;
|
||||
cocos2d::Rect arg1;
|
||||
do {
|
||||
arg0 = [tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool
|
||||
{
|
||||
LuaStack* stack = LuaStack::create();
|
||||
std::string hashName = typeid(&world).name();
|
||||
auto iter = g_luaType.find(hashName);
|
||||
std::string className = "";
|
||||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsWorld";
|
||||
}
|
||||
|
||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
||||
stack->pushObject(&shape, "PhysicsShape");
|
||||
bool ret = stack->executeFunction(2);
|
||||
stack->clean();
|
||||
return ret;
|
||||
};
|
||||
} while(0);
|
||||
|
||||
ok &= luaval_to_rect(tolua_S, 3, &arg1);
|
||||
#pragma warning NO CONVERSION TO NATIVE FOR void*;
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->queryRect(arg0, arg1, nullptr);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "queryRect",argc, 3);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_queryRect'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsWorld* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_queryPoint'", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 3)
|
||||
{
|
||||
std::function<bool (cocos2d::PhysicsWorld &, cocos2d::PhysicsShape &, void *)> arg0;
|
||||
cocos2d::Point arg1;
|
||||
do {
|
||||
arg0 = [tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool
|
||||
{
|
||||
LuaStack* stack = LuaStack::create();
|
||||
std::string hashName = typeid(&world).name();
|
||||
auto iter = g_luaType.find(hashName);
|
||||
std::string className = "";
|
||||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsWorld";
|
||||
}
|
||||
|
||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
||||
stack->pushObject(&shape, "PhysicsShape");
|
||||
bool ret = stack->executeFunction(2);
|
||||
stack->clean();
|
||||
return ret;
|
||||
};
|
||||
assert(false);
|
||||
} while(0)
|
||||
;
|
||||
ok &= luaval_to_point(tolua_S, 3, &arg1);
|
||||
#pragma warning NO CONVERSION TO NATIVE FOR void*;
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->queryPoint(arg0, arg1, nullptr);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "queryPoint",argc, 3);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_queryPoint'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "PhysicsBody");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"getJoints");
|
||||
lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_getJoints );
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsWorld");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"getScene");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_getScene );
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S,"queryPoint");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryPoint );
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S,"queryRect");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryRect );
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S,"rayCast");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_rayCast );
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H
|
||||
#define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tolua++.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "LuaScriptHandlerMgr.h"
|
||||
|
||||
int register_all_cocos2dx_physics_manual(lua_State* tolua_S);
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
|
||||
#endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl
|
|||
|
||||
# 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*$".
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event.*
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event(?!.*(Physics).*).*
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
|
|
@ -90,3 +90,6 @@ LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py
|
|||
|
||||
echo "Generating bindings for cocos2dx_spine..."
|
||||
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_spine.ini -s cocos2dx_spine -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_spine_auto
|
||||
|
||||
echo "Generating bindings for cocos2dx_physics..."
|
||||
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_physics.ini -s cocos2dx_physics -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_physics_auto
|
||||
|
|
Loading…
Reference in New Issue