2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp"
|
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaValue.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
#include "2d/CCFastTMXLayer.h"
|
2014-07-17 12:54:50 +08:00
|
|
|
|
2014-07-17 14:54:34 +08:00
|
|
|
static int lua_cocos2dx_experimental_TMXLayer_getTileGIDAt(lua_State* tolua_S)
|
2014-07-17 12:54:50 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
2014-07-17 14:54:34 +08:00
|
|
|
cocos2d::experimental::TMXLayer* cobj = nullptr;
|
2014-07-17 12:54:50 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2014-07-17 16:41:09 +08:00
|
|
|
if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror;
|
2014-07-17 12:54:50 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 14:54:34 +08:00
|
|
|
cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!cobj)
|
|
|
|
{
|
2014-07-17 14:54:34 +08:00
|
|
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getTileGIDAt'", nullptr);
|
2014-07-17 12:54:50 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
argc = lua_gettop(tolua_S)-1;
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
cocos2d::Vec2 arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-22 11:16:16 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:getTileGIDAt");
|
2014-07-17 12:54:50 +08:00
|
|
|
if(!ok)
|
|
|
|
return 0;
|
|
|
|
int ret = cobj->getTileGIDAt(arg0);
|
|
|
|
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
|
|
|
tolua_pushnumber(tolua_S,(lua_Number)0);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
cocos2d::Vec2 arg0;
|
|
|
|
int arg1 = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-22 11:16:16 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:getTileGIDAt");
|
|
|
|
ok &= luaval_to_int32(tolua_S, 3, &arg1, "ccexp.TMXLayer:getTileGIDAt");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
if(!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1);
|
|
|
|
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
|
|
|
tolua_pushnumber(tolua_S,(lua_Number)arg1);
|
|
|
|
return 2;
|
|
|
|
}
|
2014-12-01 15:53:41 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getTileGIDAt",argc, 1);
|
2014-07-17 12:54:50 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2014-07-17 14:54:34 +08:00
|
|
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getTileGIDAt'.",&tolua_err);
|
2014-07-17 12:54:50 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-17 14:54:34 +08:00
|
|
|
static void extendExperimentalTMXLayer(lua_State* tolua_S)
|
2014-07-17 12:54:50 +08:00
|
|
|
{
|
2014-07-17 14:54:34 +08:00
|
|
|
lua_pushstring(tolua_S, "ccexp.TMXLayer");
|
2014-07-17 12:54:50 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
2014-07-17 14:54:34 +08:00
|
|
|
tolua_function(tolua_S, "getTileGIDAt", lua_cocos2dx_experimental_TMXLayer_getTileGIDAt);
|
2014-07-17 12:54:50 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
bool isVectorV3FC4BT2F(lua_State* tolua_S, int lo)
|
|
|
|
{
|
|
|
|
if (!lua_istable(tolua_S, lo))
|
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
lua_pushnumber(tolua_S, 1);
|
|
|
|
lua_gettable(tolua_S,lo);
|
|
|
|
if (!lua_istable(tolua_S, -1))
|
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
lua_pushstring(tolua_S, "vertices");
|
|
|
|
lua_gettable(tolua_S, -2);
|
|
|
|
if (lua_isnil(tolua_S, -1))
|
|
|
|
return false;
|
|
|
|
lua_pop(tolua_S, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
lua_pushstring(tolua_S, "colors");
|
|
|
|
lua_gettable(tolua_S, -2);
|
|
|
|
if (lua_isnil(tolua_S, -1))
|
|
|
|
return false;
|
|
|
|
lua_pop(tolua_S, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
lua_pushstring(tolua_S, "texCoords");
|
|
|
|
lua_gettable(tolua_S, -2);
|
|
|
|
if (lua_isnil(tolua_S, -1))
|
|
|
|
return false;
|
|
|
|
lua_pop(tolua_S, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
int register_all_cocos2dx_experimental_manual(lua_State* L)
|
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 14:54:34 +08:00
|
|
|
extendExperimentalTMXLayer(L);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-17 12:54:50 +08:00
|
|
|
return 0;
|
|
|
|
}
|