Пример #1
0
void CWidgetWindow::executeTouchCancelledAfterLongClickHandler(Ref* pSender, Touch *pTouch, float fDuration)
{
    if( m_pTouchCancelledAfterLongClickListener && m_pTouchCancelledAfterLongClickHandler )
    {
		(m_pTouchCancelledAfterLongClickListener->*m_pTouchCancelledAfterLongClickHandler)(pSender, pTouch, fDuration);
    }
#if USING_LUA
	else if( m_pTouchCancelledAfterLongClickScriptHandler != 0 )
	{
		LuaEngine* pEngine = LuaEngine::getInstance();
		LuaStack* pStack = pEngine->getLuaStack();

		pStack->pushObject(pSender, "Ref");
		pStack->pushObject(pTouch, "Touch");
		pStack->pushFloat(fDuration);

		int nRet = pStack->executeFunctionByHandler(m_pTouchCancelledAfterLongClickScriptHandler, 3);
		pStack->clean();
	}
#endif
}
Пример #2
0
int lua_game_manager_Http_pushDownLoad(lua_State* tolua_S)
{
	int argc = 0;
	bool ok  = true;

#if COCOS2D_DEBUG >= 1
	tolua_Error tolua_err;
#endif

	game::manager::Http* cobj = (game::manager::Http*)tolua_tousertype(tolua_S,1,0);

#if COCOS2D_DEBUG >= 1
	//if (!tolua_isusertable(tolua_S,1,"game.manager.Http",0,&tolua_err)) goto tolua_lerror;
#endif

	argc = lua_gettop(tolua_S) - 1;

	if (argc >= 1)
	{
		if(!ok)
		{
			tolua_error(tolua_S,"invalid arguments in function 'lua_game_manager_Http_get'", nullptr);
			return 0;
		}
		std::string url;
		ok &= luaval_to_std_string(tolua_S, 2,&url, "game.manager.Http");

		RequestCompleteCallBack completeCallback = nullptr;
		if (argc >= 2)
		{
			LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,3,0));
			completeCallback = [=](const char* szBuffer){
				LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
				stack->pushString(szBuffer);
				stack->executeFunctionByHandler(handler, 1);
				stack->clean();
			};
		}

		DownLoadProgressCallBack progressCallBack = nullptr;
		if (argc >= 3)
		{
			LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,4,0));
			progressCallBack = [=](double total,double progress){
				LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
				stack->pushFloat(total);
				stack->pushFloat(progress);
				stack->executeFunctionByHandler(handler, 2);
				stack->clean();
			};
		}

		DownErrorCallBack errorCallBack = nullptr;
		if (argc >= 3)
		{
			LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,5,0));
			errorCallBack = [=](Downloader::Error error){
				LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
				stack->pushInt((int)error.code);
				stack->pushString(error.message.c_str(),error.message.size());
				stack->executeFunctionByHandler(handler, 2);
				stack->clean();
			};
		}
		cobj->pushDownLoad(url,completeCallback,progressCallBack,errorCallBack);
		lua_settop(tolua_S, 1);
		return 1;
	}
	luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Node:create",argc, 0);
	return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
	tolua_error(tolua_S,"#ferror in function 'lua_game_manager_Http_get'.",&tolua_err);
#endif
	return 0;
}