2013-08-09 10:07:10 +08:00
|
|
|
#include "lua_cocos2dx_auto.hpp"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#include "tolua_fix.h"
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "LuaBasicConversions.h"
|
|
|
|
#include "LuaScriptHandlerMgr.h"
|
|
|
|
#include "CCLuaValue.h"
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"MenuItemImage",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
do {
|
|
|
|
if (argc == 0)
|
|
|
|
{
|
|
|
|
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create();
|
|
|
|
//Uncheck
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemImage");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
do {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isstring(tolua_S,2,0,&tolua_err) ||
|
|
|
|
!tolua_isstring(tolua_S,3,0,&tolua_err))
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const char* normalImage = ((const char*) tolua_tostring(tolua_S,2,0));
|
|
|
|
const char* selectedImage = ((const char*) tolua_tostring(tolua_S,3,0));
|
|
|
|
MenuItemImage* tolua_ret = (MenuItemImage*) MenuItemImage::create(normalImage,selectedImage);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemImage");
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
do {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isstring(tolua_S,2,0,&tolua_err) ||
|
|
|
|
!tolua_isstring(tolua_S,3,0,&tolua_err) ||
|
|
|
|
!tolua_isstring(tolua_S,4,0,&tolua_err) )
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
const char* normalImage = ((const char*) tolua_tostring(tolua_S,2,0));
|
|
|
|
const char* selectedImage = ((const char*) tolua_tostring(tolua_S,3,0));
|
|
|
|
const char* disabledImage = ((const char*) tolua_tostring(tolua_S,4,0));
|
|
|
|
|
|
|
|
MenuItemImage* tolua_ret = (MenuItemImage*) MenuItemImage::create(normalImage,selectedImage,disabledImage);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemImage");
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2013-08-15 15:51:22 +08:00
|
|
|
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_MenuItemImage_create'.\n",&tolua_err);
|
2013-08-09 10:07:10 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"MenuItemLabel",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if(1 == argc)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) )
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
Node* label = ((Node*) tolua_tousertype(tolua_S,2,0));
|
|
|
|
MenuItemLabel* tolua_ret = (MenuItemLabel*) MenuItemLabel::create(label);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemLabel");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-08-15 15:51:22 +08:00
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemFont_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"MenuItemFont",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if(1 == argc)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
const char* value = ((const char*) tolua_tostring(tolua_S,2,0));
|
|
|
|
MenuItemFont* tolua_ret = (MenuItemFont*) MenuItemFont::create(value);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemFont");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemSprite_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"MenuItemSprite",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if(argc >= 2 && argc <= 3)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) ||
|
|
|
|
!tolua_isusertype(tolua_S,3,"Node",0,&tolua_err) )
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (3 == argc && !tolua_isusertype(tolua_S,4,"Node",0,&tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Node* normalSprite = ((Node*) tolua_tousertype(tolua_S,2,0));
|
|
|
|
Node* selectedSprite = ((Node*) tolua_tousertype(tolua_S,3,0));
|
|
|
|
Node* disabledSprite = NULL;
|
|
|
|
if (3 == argc)
|
|
|
|
{
|
|
|
|
disabledSprite = (Node*) tolua_tousertype(tolua_S,4,0);
|
|
|
|
}
|
|
|
|
MenuItemSprite* tolua_ret = (MenuItemSprite*) MenuItemSprite::create(normalSprite,selectedSprite,disabledSprite);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemSprite");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3);
|
|
|
|
return 0;
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
static int tolua_cocos2d_Menu_create(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (argc > 0 )
|
|
|
|
{
|
|
|
|
cocos2d::Array* array = cocos2d::Array::create();
|
|
|
|
if (NULL == array)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
CCLOG("Menu create method create array fail\n");
|
2013-08-09 10:07:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
uint32_t i = 1;
|
|
|
|
while (i <= argc)
|
|
|
|
{
|
2013-08-15 15:51:22 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1 + i, "MenuItem", 0, &tolua_err))
|
2013-08-09 10:07:10 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cocos2d::Object* item = static_cast<cocos2d::Object*>(tolua_tousertype(tolua_S, 1 + i, NULL));
|
|
|
|
if (NULL != item)
|
|
|
|
{
|
|
|
|
array->addObject(item);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
cocos2d::Menu* tolua_ret = cocos2d::Menu::createWithArray(array);
|
|
|
|
//UnCheck
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(argc == 0)
|
|
|
|
{
|
|
|
|
cocos2d::Menu* tolua_ret = cocos2d::Menu::create();
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2013-08-15 15:51:22 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu");
|
2013-08-09 10:07:10 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2013-08-15 15:51:22 +08:00
|
|
|
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Menu_create'.\n",&tolua_err);
|
2013-08-09 10:07:10 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2013-08-16 10:12:46 +08:00
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"MenuItemToggle",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if(1 == argc)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isusertype(tolua_S,2,"MenuItem",0,&tolua_err) )
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
MenuItem* item = (MenuItem*) tolua_tousertype(tolua_S,2,0);
|
|
|
|
MenuItemToggle* tolua_ret = (MenuItemToggle*) MenuItemToggle::create(item);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemToggle");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
MenuItem* cobj = nullptr;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"MenuItem",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
cobj = static_cast<cocos2d::MenuItemImage*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == cobj) {
|
2013-08-15 15:51:22 +08:00
|
|
|
tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler'\n", NULL);
|
2013-08-09 10:07:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)cobj, handler, ScriptHandlerMgr::kMenuClickHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2013-08-14 21:35:55 +08:00
|
|
|
tolua_error(tolua_S,"#ferror in function 'registerScriptTapHandler'.",&tolua_err);
|
2013-08-09 10:07:10 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
MenuItem* cobj = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"MenuItem",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cobj = static_cast<cocos2d::MenuItemImage*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == cobj) {
|
2013-08-15 15:51:22 +08:00
|
|
|
tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler'\n", NULL);
|
2013-08-09 10:07:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)cobj, ScriptHandlerMgr::kMenuClickHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptTapHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
Layer* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptTouchHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc >=1 && argc <= 4) {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
bool isMultiTouches = false;
|
|
|
|
int priority = 0;
|
|
|
|
bool swallowTouches = true;
|
|
|
|
|
|
|
|
if (argc >= 2) {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isboolean(tolua_S,3,0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
isMultiTouches = (bool)tolua_toboolean(tolua_S,3,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc >= 3) {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isnumber(tolua_S,4,0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
priority = (int)tolua_tonumber(tolua_S,4,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 4) {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isboolean(tolua_S,5,0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
swallowTouches = (bool)tolua_toboolean(tolua_S,5,true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Touch::DispatchMode touchesMode = Touch::DispatchMode::ALL_AT_ONCE;
|
|
|
|
if (!isMultiTouches)
|
|
|
|
touchesMode = Touch::DispatchMode::ONE_BY_ONE;
|
|
|
|
self->setTouchMode(touchesMode);
|
|
|
|
self->setTouchPriority(priority);
|
|
|
|
self->setSwallowsTouches(swallowTouches);
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kTouchesHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'registerScriptTouchHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
Layer* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptTouchHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kTouchesHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptTapHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-16 10:12:46 +08:00
|
|
|
int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
Layer* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptKeypadHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kKeypadHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'registerScriptKeypadHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
Layer* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptKeypadHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler(self, ScriptHandlerMgr::kKeypadHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptKeypadHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-15 15:51:22 +08:00
|
|
|
int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
Layer* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptAccelerateHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) {
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kAccelerometerHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'registerScriptAccelerateHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
Layer* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptAccelerateHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kAccelerometerHandler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptAccelerateHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S)
|
2013-08-09 10:07:10 +08:00
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
Scheduler* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Scheduler",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Scheduler*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
2013-08-14 21:35:55 +08:00
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc'\n", NULL);
|
2013-08-09 10:07:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (3 == argc) {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
|
|
|
|
!tolua_isboolean(tolua_S,4,0,&tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
float interval = (float) tolua_tonumber(tolua_S,3,0);
|
|
|
|
bool paused = (bool) tolua_toboolean(tolua_S,4,0);
|
|
|
|
unsigned int tolua_ret = (unsigned int) self->scheduleScriptFunc(handler,interval,paused);
|
|
|
|
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'scheduleScriptFunc'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-14 21:35:55 +08:00
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
int argc = 0;
|
|
|
|
Scheduler* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Scheduler",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Scheduler*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_unscheduleScriptEntry'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (1 == argc) {
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
unsigned int scheduleScriptEntryID = ((unsigned int) tolua_tonumber(tolua_S,2,0));
|
|
|
|
self->unscheduleScriptEntry(scheduleScriptEntryID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unscheduleScriptEntry'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
static int tolua_cocos2d_Sequence_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if(argc > 0)
|
|
|
|
{
|
|
|
|
cocos2d::Array* array = cocos2d::Array::create();
|
|
|
|
if (NULL == array)
|
|
|
|
{
|
|
|
|
CCLOG("Sequence create method create array fail\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
uint32_t i = 1;
|
|
|
|
while (i <= argc)
|
|
|
|
{
|
|
|
|
if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cocos2d::Object* item = static_cast<cocos2d::Object*>(tolua_tousertype(tolua_S, 1 + i, NULL));
|
|
|
|
if (NULL != item)
|
|
|
|
{
|
|
|
|
array->addObject(item);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
cocos2d::Sequence* tolua_ret = cocos2d::Sequence::create(array);
|
|
|
|
//issue 2433 uncheck
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_CallFunc_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"CallFunc",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
LUA_FUNCTION funcID = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
LuaCallFunc* tolua_ret = (LuaCallFunc*) LuaCallFunc::create(funcID);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CallFunc");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
2013-08-16 10:12:46 +08:00
|
|
|
Node* self = nullptr;
|
2013-08-14 21:35:55 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
2013-08-16 10:12:46 +08:00
|
|
|
self = static_cast<cocos2d::Node*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_registerScriptHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2013-08-14 21:35:55 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
2013-08-16 10:12:46 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kNodeHandler);
|
2013-08-14 21:35:55 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
2013-08-16 10:12:46 +08:00
|
|
|
Node* self = nullptr;
|
2013-08-14 21:35:55 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
2013-08-16 10:12:46 +08:00
|
|
|
self = static_cast<cocos2d::Node*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_unregisterScriptHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2013-08-14 21:35:55 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 0)
|
|
|
|
{
|
2013-08-16 10:12:46 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kNodeHandler);
|
2013-08-14 21:35:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-16 10:12:46 +08:00
|
|
|
|
|
|
|
static int tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
Node* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Node*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
|
|
|
int priority = 0;
|
|
|
|
if (luaval_to_int32(tolua_S, 3, &priority))
|
|
|
|
{
|
|
|
|
self->scheduleUpdateWithPriorityLua(handler,priority);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'scheduleUpdateWithPriorityLua'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_unscheduleUpdate(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
Node* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::Node*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_unscheduleUpdate'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
self->unscheduleUpdate();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'unscheduleUpdate'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
static int tolua_cocos2d_Spawn_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"Spawn",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc > 0)
|
|
|
|
{
|
|
|
|
cocos2d::Array* array = cocos2d::Array::create();
|
|
|
|
if (NULL == array)
|
|
|
|
{
|
|
|
|
CCLOG("Spawn create method create array fail\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t i = 1;
|
|
|
|
while (i <= argc)
|
|
|
|
{
|
|
|
|
if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cocos2d::Object* item = static_cast<cocos2d::Object*>(tolua_tousertype(tolua_S, 1 + i, NULL));
|
|
|
|
if (NULL != item)
|
|
|
|
{
|
|
|
|
array->addObject(item);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cocos2d::Spawn * tolua_ret = cocos2d::Spawn::create(array);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Spawn");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"CardinalSplineBy",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
double dur = 0.0;
|
|
|
|
ok &= luaval_to_number(tolua_S, 2, &dur);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
Point *arr = NULL;
|
|
|
|
ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
double ten = 0.0;
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &ten);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (num > 0)
|
|
|
|
{
|
|
|
|
PointArray* points = PointArray::create(num);
|
|
|
|
|
|
|
|
if (NULL == points)
|
|
|
|
{
|
|
|
|
free(arr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < num; i++) {
|
|
|
|
points->addControlPoint(arr[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(arr);
|
|
|
|
CardinalSplineBy* tolua_ret = CardinalSplineBy::create(dur, points, ten);
|
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CardinalSplineBy");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"CatmullRomBy",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double dur = 0.0;
|
|
|
|
ok &= luaval_to_number(tolua_S, 2, &dur);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
Point *arr = NULL;
|
|
|
|
ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (num > 0)
|
|
|
|
{
|
|
|
|
PointArray* points = PointArray::create(num);
|
|
|
|
|
|
|
|
if (NULL == points)
|
|
|
|
{
|
|
|
|
free(arr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < num; i++) {
|
|
|
|
points->addControlPoint(arr[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(arr);
|
|
|
|
CatmullRomBy* tolua_ret = CatmullRomBy::create(dur, points);
|
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CatmullRomBy");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"CatmullRomTo",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double dur = 0.0;
|
|
|
|
ok &= luaval_to_number(tolua_S, 2, &dur);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
Point *arr = NULL;
|
|
|
|
ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (num > 0)
|
|
|
|
{
|
|
|
|
PointArray* points = PointArray::create(num);
|
|
|
|
|
|
|
|
if (NULL == points)
|
|
|
|
{
|
|
|
|
free(arr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < num; i++) {
|
|
|
|
points->addControlPoint(arr[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(arr);
|
|
|
|
CatmullRomTo* tolua_ret = CatmullRomTo::create(dur, points);
|
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CatmullRomTo");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_BezierBy_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"BezierBy",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double t = 0.0;
|
|
|
|
ok &= luaval_to_number(tolua_S, 2, &t);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
Point *arr = NULL;
|
|
|
|
ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (num < 3)
|
|
|
|
{
|
|
|
|
free(arr);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccBezierConfig config;
|
|
|
|
config.controlPoint_1 = arr[0];
|
|
|
|
config.controlPoint_2 = arr[1];
|
|
|
|
config.endPosition = arr[2];
|
|
|
|
free(arr);
|
|
|
|
|
|
|
|
BezierBy* tolua_ret = BezierBy::create(t, config);
|
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"BezierBy");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_BezierTo_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertable(tolua_S,1,"BezierTo",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double t = 0.0;
|
|
|
|
ok &= luaval_to_number(tolua_S, 2, &t);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
Point *arr = NULL;
|
|
|
|
ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num);
|
|
|
|
if (!ok)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (num < 3)
|
|
|
|
{
|
|
|
|
free(arr);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccBezierConfig config;
|
|
|
|
config.controlPoint_1 = arr[0];
|
|
|
|
config.controlPoint_2 = arr[1];
|
|
|
|
config.endPosition = arr[2];
|
|
|
|
free(arr);
|
|
|
|
|
|
|
|
BezierTo* tolua_ret = BezierTo::create(t, config);
|
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"BezierTo");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2013-08-15 15:51:22 +08:00
|
|
|
|
|
|
|
static int tolua_cocos2d_DrawNode_drawPolygon(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
DrawNode* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_isusertype(tolua_S,1,"DrawNode",0,&tolua_err)) goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::DrawNode*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self) {
|
|
|
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_DrawNode_drawPolygon'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (5 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if(
|
|
|
|
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
|
|
|
!tolua_istable(tolua_S, 4, 0,&tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 5, 0, &tolua_err) ||
|
|
|
|
!tolua_istable(tolua_S,6, 0,&tolua_err) )
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
size_t size = lua_tonumber(tolua_S, 3);
|
|
|
|
if ( size > 0 )
|
|
|
|
{
|
|
|
|
Point* points = new Point[size];
|
|
|
|
if (NULL == points)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(tolua_S,i + 1);
|
|
|
|
lua_gettable(tolua_S,2);
|
|
|
|
if (!tolua_istable(tolua_S,-1, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE_ARRAY(points);
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i]))
|
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
CC_SAFE_DELETE_ARRAY(points);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
Color4F fillColor;
|
|
|
|
if (!luaval_to_color4f(tolua_S, 4, &fillColor))
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE_ARRAY(points);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float borderWidth = (float)tolua_tonumber(tolua_S, 5, 0);
|
|
|
|
|
|
|
|
Color4F borderColor;
|
|
|
|
if (!luaval_to_color4f(tolua_S, 6, &borderColor))
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE_ARRAY(points);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->drawPolygon(points, size, fillColor, borderWidth, borderColor);
|
|
|
|
CC_SAFE_DELETE_ARRAY(points);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 5);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'drawPolygon'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// setBlendFunc
|
|
|
|
template<class T>
|
2013-08-15 16:14:14 +08:00
|
|
|
static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className)
|
2013-08-15 15:51:22 +08:00
|
|
|
{
|
2013-08-15 16:14:14 +08:00
|
|
|
if (NULL == tolua_S || NULL == className || strlen(className) == 0)
|
2013-08-15 15:51:22 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
int argc = 0;
|
|
|
|
T* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2013-08-15 16:14:14 +08:00
|
|
|
if (!tolua_isusertype(tolua_S,1,className,0,&tolua_err)) goto tolua_lerror;
|
2013-08-15 15:51:22 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
self = static_cast<T*>(tolua_tousertype(tolua_S,1,0));
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (2 == argc)
|
|
|
|
{
|
|
|
|
GLenum src, dst;
|
|
|
|
if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
BlendFunc blendFunc = {src, dst};
|
|
|
|
self->setBlendFunc(blendFunc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S,"#ferror in function 'setBlendFunc'.",&tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S)
|
|
|
|
{
|
2013-08-15 16:14:14 +08:00
|
|
|
return tolua_cocos2dx_setBlendFunc<Sprite>(tolua_S,"Sprite");
|
2013-08-15 15:51:22 +08:00
|
|
|
}
|
|
|
|
|
2013-08-16 10:12:46 +08:00
|
|
|
static int tolua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
return tolua_cocos2dx_setBlendFunc<LayerColor>(tolua_S,"LayerColor");
|
|
|
|
}
|
2013-08-09 10:07:10 +08:00
|
|
|
|
|
|
|
int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"MenuItem");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"registerScriptTapHandler");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_registerScriptTapHandler);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptTapHandler");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_unregisterScriptTapHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"MenuItemImage");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemImage_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
lua_pushstring(tolua_S, "MenuItemLabel");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemLabel_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
2013-08-15 15:51:22 +08:00
|
|
|
lua_pushstring(tolua_S, "MenuItemFont");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemFont_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S, "MenuItemSprite");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemSprite_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
2013-08-16 10:12:46 +08:00
|
|
|
|
|
|
|
lua_pushstring(tolua_S, "MenuItemToggle");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemToggle_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
2013-08-15 15:51:22 +08:00
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
lua_pushstring(tolua_S, "Menu");
|
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Menu_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
lua_pushstring(tolua_S,"Node");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"registerScriptHandler");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_registerScriptHandler);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
lua_pushstring(tolua_S,"unregisterScriptHandler");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unregisterScriptHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2013-08-16 10:12:46 +08:00
|
|
|
lua_pushstring(tolua_S,"scheduleUpdateWithPriorityLua");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S,"unscheduleUpdate");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unscheduleUpdate);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2013-08-14 21:35:55 +08:00
|
|
|
}
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
lua_pushstring(tolua_S,"Layer");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"registerScriptTouchHandler");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_registerScriptTouchHandler);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptTouchHandler");
|
2013-08-15 15:51:22 +08:00
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_unregisterScriptTouchHandler);
|
2013-08-09 10:07:10 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2013-08-16 10:12:46 +08:00
|
|
|
lua_pushstring(tolua_S, "registerScriptKeypadHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptKeypadHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptKeypadHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptKeypadHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2013-08-15 15:51:22 +08:00
|
|
|
lua_pushstring(tolua_S, "registerScriptAccelerateHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptAccelerateHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptAccelerateHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptAccelerateHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2013-08-09 10:07:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"Scheduler");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"scheduleScriptFunc");
|
2013-08-14 21:35:55 +08:00
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc);
|
2013-08-09 10:07:10 +08:00
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
lua_pushstring(tolua_S, "unscheduleScriptEntry");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_unscheduleScriptEntry);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
}
|
2013-08-14 21:35:55 +08:00
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"Sequence");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Sequence_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"CallFunc");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_CallFunc_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"Spawn");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_Spawn_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"CardinalSplineBy");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_CardinalSplineBy_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"CatmullRomBy");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomBy_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"CatmullRomTo");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomTo_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"BezierBy");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_BezierBy_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"BezierTo");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"create");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_BezierTo_create);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
2013-08-15 15:51:22 +08:00
|
|
|
lua_pushstring(tolua_S,"DrawNode");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"drawPolygon");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2d_DrawNode_drawPolygon);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushstring(tolua_S,"Sprite");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"setBlendFunc");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2dx_Sprite_setBlendFunc);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
2013-08-14 21:35:55 +08:00
|
|
|
|
2013-08-16 10:12:46 +08:00
|
|
|
lua_pushstring(tolua_S,"LayerColor");
|
|
|
|
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S,-1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S,"setBlendFunc");
|
|
|
|
lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerColor_setBlendFunc);
|
|
|
|
lua_rawset(tolua_S,-3);
|
|
|
|
}
|
|
|
|
|
2013-08-09 10:07:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|