I wrote this in lua:
body1 = physics.newbody("dynamic", 500, 100, 0)
body1:applyforce(10000, 0)
node2 = graphics.new_physnode(node1, body1, "phys1")
body1:applyforce(10000, 0)
the first time I called applyforce, it worked well. But at the second time, it became a nil value. So maybe it's the new_physnode that mess things up?
this is new_physnode:
int l_new_physnode(lua_State* L) {
ShapeNode* shapenode = (ShapeNode*)lua_touserdata(L, 1);
Physics::hdbody body = (Physics::hdbody)lua_touserdata(L, 2);
string name = lua_tostring(L, 3);
PhysNode* physnode = graphics.new_physnode(shapenode, body, name);
lua_pushlightuserdata(L, physnode);
luaL_getmetatable(L, "Lua.Node");
lua_setmetatable(L, -2);
return 1;
}
it will just copy the pointer of body and shapenode then store them in physnode.
yet I cannot get it to work. Why this is happening?(body's metatable becomes null but node's metatable remain the same...)
thanks!