mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5444 from samuele3hu/developDynamic
issue #3956:Modifyt the mechanism of toluafix_pushusertype_ccobject to pass the real typename to lua
This commit is contained in:
commit
2898909130
|
@ -1 +1 @@
|
||||||
e3331b31586222de318fe42b3d7d9a22c23f2d1f
|
96ebe58c64783ed2e976ff504db835a397475f00
|
|
@ -5,7 +5,7 @@ set(LUABINDING_SRC
|
||||||
../auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp
|
../auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp
|
||||||
../auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp
|
../auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp
|
||||||
../auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp
|
../auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp
|
||||||
bindings/tolua_fix.c
|
bindings/tolua_fix.cpp
|
||||||
bindings/CCLuaBridge.cpp
|
bindings/CCLuaBridge.cpp
|
||||||
bindings/CCLuaEngine.cpp
|
bindings/CCLuaEngine.cpp
|
||||||
bindings/CCLuaStack.cpp
|
bindings/CCLuaStack.cpp
|
||||||
|
|
|
@ -37,7 +37,7 @@ LOCAL_SRC_FILES := CCLuaBridge.cpp \
|
||||||
../../../../external/lua/tolua/tolua_map.c \
|
../../../../external/lua/tolua/tolua_map.c \
|
||||||
../../../../external/lua/tolua/tolua_push.c \
|
../../../../external/lua/tolua/tolua_push.c \
|
||||||
../../../../external/lua/tolua/tolua_to.c \
|
../../../../external/lua/tolua/tolua_to.c \
|
||||||
tolua_fix.c \
|
tolua_fix.cpp \
|
||||||
socket/auxiliar.c \
|
socket/auxiliar.c \
|
||||||
socket/luasocket_buffer.c \
|
socket/luasocket_buffer.c \
|
||||||
socket/except.c \
|
socket/except.c \
|
||||||
|
|
|
@ -24,13 +24,12 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "CCLuaStack.h"
|
#include "CCLuaStack.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "tolua++.h"
|
#include "tolua++.h"
|
||||||
#include "lualib.h"
|
#include "lualib.h"
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "tolua_fix.h"
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
#include "lua_extensions.h"
|
#include "lua_extensions.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,14 +23,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::unordered_map<std::string, std::string> g_luaType;
|
std::unordered_map<std::string, std::string> g_luaType;
|
||||||
std::unordered_map<std::string, std::string> g_typeCast;
|
std::unordered_map<std::string, std::string> g_typeCast;
|
||||||
|
@ -1596,18 +1589,9 @@ void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info)
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
std::string hashName = typeid(*shape).name();
|
|
||||||
auto iter = g_luaType.find(hashName);
|
|
||||||
std::string className = "";
|
|
||||||
if(iter != g_luaType.end()){
|
|
||||||
className = iter->second.c_str();
|
|
||||||
} else {
|
|
||||||
className = "PhysicsShape";
|
|
||||||
}
|
|
||||||
|
|
||||||
int ID = (int)(shape->_ID);
|
int ID = (int)(shape->_ID);
|
||||||
int* luaID = &(shape->_luaID);
|
int* luaID = &(shape->_luaID);
|
||||||
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)shape,className.c_str());
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)shape,"cc.PhysicsShape");
|
||||||
}
|
}
|
||||||
lua_rawset(L, -3); /* table[key] = value, L: table */
|
lua_rawset(L, -3); /* table[key] = value, L: table */
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "tolua++.h"
|
#include "tolua++.h"
|
||||||
#include "tolua_fix.h"
|
|
||||||
}
|
}
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
@ -294,36 +293,46 @@ void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue);
|
||||||
void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inValue);
|
void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inValue);
|
||||||
void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue);
|
void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Because all override functions wouldn't be bound,so we must use `typeid` to get the real class name
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
const char* getLuaTypeName(T* ret,const char* type)
|
||||||
|
{
|
||||||
|
if (nullptr != ret)
|
||||||
|
{
|
||||||
|
std::string hashName = typeid(*ret).name();
|
||||||
|
auto iter = g_luaType.find(hashName);
|
||||||
|
if(g_luaType.end() != iter)
|
||||||
|
{
|
||||||
|
return iter->second.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void object_to_luaval(lua_State* L,const char* type, T* ret)
|
void object_to_luaval(lua_State* L,const char* type, T* ret)
|
||||||
{
|
{
|
||||||
if(nullptr != ret)
|
if(nullptr != ret)
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
Because all override functions wouldn't be bound,so we must use `typeid` to get the real class name
|
|
||||||
*/
|
|
||||||
std::string hashName = typeid(*ret).name();
|
|
||||||
auto iter = g_luaType.find(hashName);
|
|
||||||
std::string className = "";
|
|
||||||
if(g_luaType.end() != iter)
|
|
||||||
{
|
|
||||||
className = iter->second.c_str();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
cocos2d::Ref* dynObject = dynamic_cast<cocos2d::Ref *>(ret);
|
cocos2d::Ref* dynObject = dynamic_cast<cocos2d::Ref *>(ret);
|
||||||
|
|
||||||
if (nullptr != dynObject)
|
if (nullptr != dynObject)
|
||||||
{
|
{
|
||||||
int ID = (int)(dynObject->_ID) ;
|
int ID = (int)(dynObject->_ID) ;
|
||||||
int* luaID = &(dynObject->_luaID);
|
int* luaID = &(dynObject->_luaID);
|
||||||
toluafix_pushusertype_ccobject(L,ID, luaID, (void*)ret,className.c_str());
|
toluafix_pushusertype_ccobject(L,ID, luaID, (void*)ret,type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tolua_pushusertype(L,(void*)ret,className.c_str());
|
tolua_pushusertype(L,(void*)ret,getLuaTypeName(ret, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
79a0d9662a9a7c45ff5d17c60a855b7144b91d1f
|
ac3ec208ccad60f34c9f194d1815f0129fe711dc
|
|
@ -21,17 +21,10 @@
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifdef __cplusplus
|
#include "LuaScriptHandlerMgr.h"
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "LuaScriptHandlerMgr.h"
|
#include "tolua_fix.h"
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "extensions/cocos-ext.h"
|
#include "extensions/cocos-ext.h"
|
||||||
#include "CCLuaStack.h"
|
#include "CCLuaStack.h"
|
||||||
|
|
|
@ -23,18 +23,10 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
|
#include "Lua_web_socket.h"
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Lua_web_socket.h"
|
#include "tolua_fix.h"
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "CCLuaStack.h"
|
#include "CCLuaStack.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
|
|
|
@ -22,16 +22,8 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "lua_cocos2dx_coco_studio_manual.hpp"
|
#include "lua_cocos2dx_coco_studio_manual.hpp"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
#include "LuaScriptHandlerMgr.h"
|
#include "LuaScriptHandlerMgr.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
|
|
|
@ -22,16 +22,8 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "lua_cocos2dx_deprecated.h"
|
#include "lua_cocos2dx_deprecated.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
#include "LuaScriptHandlerMgr.h"
|
#include "LuaScriptHandlerMgr.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
|
@ -1968,7 +1960,7 @@ static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00(lua_State
|
||||||
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec,delay);
|
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec,delay);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Animation");
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1993,7 +1985,7 @@ static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated01(lua_State
|
||||||
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec);
|
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Animation");
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2037,7 +2029,7 @@ static int tolua_cocos2d_Sequence_createWithTwoActions(lua_State* tolua_S)
|
||||||
Sequence* tolua_ret = (Sequence*) Sequence::createWithTwoActions(pActionOne,pActionTwo);
|
Sequence* tolua_ret = (Sequence*) Sequence::createWithTwoActions(pActionOne,pActionTwo);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Sequence");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2066,7 +2058,7 @@ static int tolua_Cocos2d_Sequence_create_deprecated00(lua_State* tolua_S)
|
||||||
Sequence* tolua_ret = (Sequence*) Sequence::create(vec);
|
Sequence* tolua_ret = (Sequence*) Sequence::create(vec);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Sequence");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
|
@ -2174,7 +2166,7 @@ static int tolua_cocos2d_Spawn_createWithTwoActions_deprcated00(lua_State* tolua
|
||||||
Spawn* tolua_ret = (Spawn*) Spawn::createWithTwoActions(pAction1,pAction2);
|
Spawn* tolua_ret = (Spawn*) Spawn::createWithTwoActions(pAction1,pAction2);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Spawn");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Spawn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2217,7 +2209,7 @@ static int tolua_cocos2d_Menu_createWithArray00(lua_State* tolua_S)
|
||||||
Menu* tolua_ret = (Menu*) Menu::createWithArray(vec);
|
Menu* tolua_ret = (Menu*) Menu::createWithArray(vec);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Menu");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
|
@ -2321,7 +2313,7 @@ static int tolua_cocos2d_LayerMultiplex_createWithArray00(lua_State* tolua_S)
|
||||||
LayerMultiplex* tolua_ret = (LayerMultiplex*) LayerMultiplex::createWithArray(vec);
|
LayerMultiplex* tolua_ret = (LayerMultiplex*) LayerMultiplex::createWithArray(vec);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.LayerMultiplex");
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -22,16 +22,8 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "lua_cocos2dx_extension_manual.h"
|
#include "lua_cocos2dx_extension_manual.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
#include "cocos-ext.h"
|
#include "cocos-ext.h"
|
||||||
|
|
|
@ -22,16 +22,8 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "lua_cocos2dx_gui_manual.hpp"
|
#include "lua_cocos2dx_gui_manual.hpp"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
#include "LuaScriptHandlerMgr.h"
|
#include "LuaScriptHandlerMgr.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
29bde887dbd41a72f33704fb57cbab230d1a1688
|
6b4a49b88aacb735030875a6da6af87086f85628
|
|
@ -1,15 +1,7 @@
|
||||||
#include "lua_cocos2dx_manual.hpp"
|
#include "lua_cocos2dx_manual.hpp"
|
||||||
|
|
||||||
#if CC_USE_PHYSICS
|
#if CC_USE_PHYSICS
|
||||||
|
#include "tolua_fix.h"
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
#include "CCLuaEngine.h"
|
#include "CCLuaEngine.h"
|
||||||
|
@ -63,21 +55,12 @@ int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S)
|
||||||
if (nullptr == *iter)
|
if (nullptr == *iter)
|
||||||
continue;
|
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 = "cc.PhysicsJoint";
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_pushnumber(tolua_S, (lua_Number)indexTable);
|
lua_pushnumber(tolua_S, (lua_Number)indexTable);
|
||||||
tolua_pushusertype(tolua_S,(void*)(*iter), className.c_str());
|
tolua_pushusertype(tolua_S,(void*)(*iter), getLuaTypeName(*iter, "cc.PhysicsJoint"));
|
||||||
lua_rawset(tolua_S, -3);
|
lua_rawset(tolua_S, -3);
|
||||||
++indexTable;
|
++indexTable;
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getJoints",argc, 0);
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getJoints",argc, 0);
|
||||||
|
@ -185,20 +168,11 @@ int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S)
|
||||||
do {
|
do {
|
||||||
arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool
|
arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool
|
||||||
{
|
{
|
||||||
std::string hashName = typeid(&world).name();
|
tolua_pushusertype(tolua_S, (void*)(&world), getLuaTypeName(&world, "cc.PhysicsWorld"));
|
||||||
auto iter = g_luaType.find(hashName);
|
|
||||||
std::string className = "";
|
|
||||||
if(iter != g_luaType.end()){
|
|
||||||
className = iter->second.c_str();
|
|
||||||
} else {
|
|
||||||
className = "cc.PhysicsWorld";
|
|
||||||
}
|
|
||||||
|
|
||||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
|
||||||
physics_raycastinfo_to_luaval(tolua_S, info);
|
physics_raycastinfo_to_luaval(tolua_S, info);
|
||||||
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||||
};
|
};
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
ok &= luaval_to_point(tolua_S, 3, &arg1);
|
ok &= luaval_to_point(tolua_S, 3, &arg1);
|
||||||
ok &= luaval_to_point(tolua_S, 4, &arg2);
|
ok &= luaval_to_point(tolua_S, 4, &arg2);
|
||||||
|
@ -251,29 +225,11 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S)
|
||||||
do {
|
do {
|
||||||
arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool
|
arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool
|
||||||
{
|
{
|
||||||
std::string hashName = typeid(&world).name();
|
tolua_pushusertype(tolua_S, (void*)(&world), getLuaTypeName(&world, "cc.PhysicsWorld"));
|
||||||
auto iter = g_luaType.find(hashName);
|
toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), "cc.PhysicsShape");
|
||||||
std::string className = "";
|
|
||||||
if(iter != g_luaType.end()){
|
|
||||||
className = iter->second.c_str();
|
|
||||||
} else {
|
|
||||||
className = "cc.PhysicsWorld";
|
|
||||||
}
|
|
||||||
|
|
||||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
|
||||||
|
|
||||||
hashName = typeid(&shape).name();
|
|
||||||
iter = g_luaType.find(hashName);
|
|
||||||
className = "";
|
|
||||||
if(iter != g_luaType.end()){
|
|
||||||
className = iter->second.c_str();
|
|
||||||
} else {
|
|
||||||
className = "cc.PhysicsShape";
|
|
||||||
}
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str());
|
|
||||||
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||||
};
|
};
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
ok &= luaval_to_rect(tolua_S, 3, &arg1);
|
ok &= luaval_to_rect(tolua_S, 3, &arg1);
|
||||||
if(!ok)
|
if(!ok)
|
||||||
|
@ -327,30 +283,12 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S)
|
||||||
do {
|
do {
|
||||||
arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool
|
arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool
|
||||||
{
|
{
|
||||||
std::string hashName = typeid(&world).name();
|
tolua_pushusertype(tolua_S, (void*)(&world), getLuaTypeName(&world, "cc.PhysicsWorld"));
|
||||||
auto iter = g_luaType.find(hashName);
|
toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), "cc.PhysicsShape");
|
||||||
std::string className = "";
|
|
||||||
if(iter != g_luaType.end()){
|
|
||||||
className = iter->second.c_str();
|
|
||||||
} else {
|
|
||||||
className = "cc.PhysicsWorld";
|
|
||||||
}
|
|
||||||
|
|
||||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
|
||||||
|
|
||||||
hashName = typeid(&shape).name();
|
|
||||||
iter = g_luaType.find(hashName);
|
|
||||||
className = "";
|
|
||||||
if(iter != g_luaType.end()){
|
|
||||||
className = iter->second.c_str();
|
|
||||||
} else {
|
|
||||||
className = "cc.PhysicsShape";
|
|
||||||
}
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str());
|
|
||||||
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||||
};
|
};
|
||||||
assert(false);
|
assert(false);
|
||||||
} while(0)
|
} while(0)
|
||||||
;
|
;
|
||||||
ok &= luaval_to_point(tolua_S, 3, &arg1);
|
ok &= luaval_to_point(tolua_S, 3, &arg1);
|
||||||
if(!ok)
|
if(!ok)
|
||||||
|
@ -402,26 +340,17 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
lua_pushnil(tolua_S);
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
}
|
||||||
if (NULL != dynObject) {
|
} while (0);
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
|
@ -443,26 +372,18 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
|
||||||
std::string hashName = typeid(*ret).name();
|
if (nullptr != ret)
|
||||||
auto iter = g_luaType.find(hashName);
|
{
|
||||||
std::string className = "";
|
int ID = ret->_ID;
|
||||||
if(iter != g_luaType.end()){
|
int* luaID = &ret->_luaID;
|
||||||
className = iter->second.c_str();
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
} else {
|
}
|
||||||
className = "cc.PhysicsBody";
|
else
|
||||||
}
|
{
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
lua_pushnil(tolua_S);
|
||||||
if (NULL != dynObject) {
|
}
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
} while (0);
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
|
@ -486,26 +407,17 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2, arg3);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2, arg3);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
lua_pushnil(tolua_S);
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
}
|
||||||
if (NULL != dynObject) {
|
} while (0);
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createPolygon",argc, 2);
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createPolygon",argc, 2);
|
||||||
|
@ -549,26 +461,17 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
|
||||||
if (NULL != dynObject) {
|
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
lua_pushnil(tolua_S);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
|
@ -590,26 +493,17 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
|
||||||
if (NULL != dynObject) {
|
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
lua_pushnil(tolua_S);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
|
@ -633,26 +527,17 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2, arg3);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2, arg3);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
|
||||||
if (NULL != dynObject) {
|
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
lua_pushnil(tolua_S);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgePolygon",argc, 2);
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgePolygon",argc, 2);
|
||||||
|
@ -696,26 +581,17 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
lua_pushnil(tolua_S);
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
}
|
||||||
if (NULL != dynObject) {
|
} while (0);
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
|
@ -737,26 +613,17 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
lua_pushnil(tolua_S);
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
}
|
||||||
if (NULL != dynObject) {
|
} while (0);
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
|
@ -780,26 +647,17 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
||||||
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2, arg3);
|
cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2, arg3);
|
||||||
CC_SAFE_FREE(arg0);
|
CC_SAFE_FREE(arg0);
|
||||||
do {
|
do {
|
||||||
if (NULL != ret){
|
if (nullptr != ret)
|
||||||
std::string hashName = typeid(*ret).name();
|
{
|
||||||
auto iter = g_luaType.find(hashName);
|
int ID = ret->_ID;
|
||||||
std::string className = "";
|
int* luaID = &ret->_luaID;
|
||||||
if(iter != g_luaType.end()){
|
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret, "cc.PhysicsBody");
|
||||||
className = iter->second.c_str();
|
}
|
||||||
} else {
|
else
|
||||||
className = "cc.PhysicsBody";
|
{
|
||||||
}
|
lua_pushnil(tolua_S);
|
||||||
cocos2d::Ref *dynObject = dynamic_cast<cocos2d::Ref *>((cocos2d::PhysicsBody*)ret);
|
}
|
||||||
if (NULL != dynObject) {
|
} while (0);
|
||||||
int ID = ret ? (int)(dynObject->_ID) : -1;
|
|
||||||
int* luaID = ret ? &(dynObject->_luaID) : NULL;
|
|
||||||
toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str());
|
|
||||||
} else {
|
|
||||||
tolua_pushusertype(tolua_S,(void*)ret,className.c_str());
|
|
||||||
}} else {
|
|
||||||
lua_pushnil(tolua_S);
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeChain",argc, 2);
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeChain",argc, 2);
|
||||||
|
@ -1152,9 +1010,9 @@ static int tolua_cocos2dx_EventListenerPhysicsContact_registerScriptHandler(lua_
|
||||||
self = static_cast<EventListenerPhysicsContact*>(tolua_tousertype(tolua_S,1,0));
|
self = static_cast<EventListenerPhysicsContact*>(tolua_tousertype(tolua_S,1,0));
|
||||||
#if COCOS2D_DEBUG >= 1
|
#if COCOS2D_DEBUG >= 1
|
||||||
if (nullptr == self) {
|
if (nullptr == self) {
|
||||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerPhysicsContact_registerScriptHandler'\n", nullptr);
|
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerPhysicsContact_registerScriptHandler'\n", nullptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
argc = lua_gettop(tolua_S) - 1;
|
argc = lua_gettop(tolua_S) - 1;
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,8 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "lua_cocos2dx_spine_manual.hpp"
|
#include "lua_cocos2dx_spine_manual.hpp"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "LuaBasicConversions.h"
|
#include "LuaBasicConversions.h"
|
||||||
#include "LuaScriptHandlerMgr.h"
|
#include "LuaScriptHandlerMgr.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
|
|
|
@ -22,13 +22,8 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "lua_xml_http_request.h"
|
#include "lua_xml_http_request.h"
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "tolua_fix.h"
|
||||||
#include "CCLuaStack.h"
|
#include "CCLuaStack.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
#include "CCLuaEngine.h"
|
#include "CCLuaEngine.h"
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
|
||||||
#include "tolua_fix.h"
|
#include "tolua_fix.h"
|
||||||
|
#include "CCRef.h"
|
||||||
|
#include "LuaBasicConversions.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
using namespace cocos2d;
|
||||||
|
|
||||||
static int s_function_ref_id = 0;
|
static int s_function_ref_id = 0;
|
||||||
|
|
||||||
TOLUA_API void toluafix_open(lua_State* L)
|
TOLUA_API void toluafix_open(lua_State* L)
|
||||||
|
@ -31,6 +35,9 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref* vPtr = static_cast<Ref*>(ptr);
|
||||||
|
const char* vType = getLuaTypeName(vPtr, type);
|
||||||
|
|
||||||
if (*p_refid == 0)
|
if (*p_refid == 0)
|
||||||
{
|
{
|
||||||
*p_refid = refid;
|
*p_refid = refid;
|
||||||
|
@ -38,7 +45,7 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L,
|
||||||
lua_pushstring(L, TOLUA_REFID_PTR_MAPPING);
|
lua_pushstring(L, TOLUA_REFID_PTR_MAPPING);
|
||||||
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_ptr */
|
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_ptr */
|
||||||
lua_pushinteger(L, refid); /* stack: refid_ptr refid */
|
lua_pushinteger(L, refid); /* stack: refid_ptr refid */
|
||||||
lua_pushlightuserdata(L, ptr); /* stack: refid_ptr refid ptr */
|
lua_pushlightuserdata(L, vPtr); /* stack: refid_ptr refid ptr */
|
||||||
|
|
||||||
lua_rawset(L, -3); /* refid_ptr[refid] = ptr, stack: refid_ptr */
|
lua_rawset(L, -3); /* refid_ptr[refid] = ptr, stack: refid_ptr */
|
||||||
lua_pop(L, 1); /* stack: - */
|
lua_pop(L, 1); /* stack: - */
|
||||||
|
@ -46,14 +53,14 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L,
|
||||||
lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING);
|
lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING);
|
||||||
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_type */
|
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_type */
|
||||||
lua_pushinteger(L, refid); /* stack: refid_type refid */
|
lua_pushinteger(L, refid); /* stack: refid_type refid */
|
||||||
lua_pushstring(L, type); /* stack: refid_type refid type */
|
lua_pushstring(L, vType); /* stack: refid_type refid type */
|
||||||
lua_rawset(L, -3); /* refid_type[refid] = type, stack: refid_type */
|
lua_rawset(L, -3); /* refid_type[refid] = type, stack: refid_type */
|
||||||
lua_pop(L, 1); /* stack: - */
|
lua_pop(L, 1); /* stack: - */
|
||||||
|
|
||||||
//printf("[LUA] push CCObject OK - refid: %d, ptr: %x, type: %s\n", *p_refid, (int)ptr, type);
|
//printf("[LUA] push CCObject OK - refid: %d, ptr: %x, type: %s\n", *p_refid, (int)ptr, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
tolua_pushusertype_and_addtoroot(L, ptr, type);
|
tolua_pushusertype_and_addtoroot(L, vPtr, vType);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -4,11 +4,6 @@
|
||||||
|
|
||||||
#include "tolua++.h"
|
#include "tolua++.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TOLUA_REFID_PTR_MAPPING "toluafix_refid_ptr_mapping"
|
#define TOLUA_REFID_PTR_MAPPING "toluafix_refid_ptr_mapping"
|
||||||
#define TOLUA_REFID_TYPE_MAPPING "toluafix_refid_type_mapping"
|
#define TOLUA_REFID_TYPE_MAPPING "toluafix_refid_type_mapping"
|
||||||
#define TOLUA_REFID_FUNCTION_MAPPING "toluafix_refid_function_mapping"
|
#define TOLUA_REFID_FUNCTION_MAPPING "toluafix_refid_function_mapping"
|
||||||
|
@ -28,8 +23,4 @@ TOLUA_API int toluafix_totable(lua_State* L, int lo, int def);
|
||||||
TOLUA_API int toluafix_istable(lua_State* L, int lo, const char* type, int def, tolua_Error* err);
|
TOLUA_API int toluafix_istable(lua_State* L, int lo, const char* type, int def, tolua_Error* err);
|
||||||
TOLUA_API void toluafix_stack_dump(lua_State* L, const char* label);
|
TOLUA_API void toluafix_stack_dump(lua_State* L, const char* label);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern "C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __TOLUA_FIX_H_
|
#endif // __TOLUA_FIX_H_
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
#include "lua_assetsmanager_test_sample.h"
|
#include "lua_assetsmanager_test_sample.h"
|
||||||
|
#include "tolua_fix.h"
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "tolua_fix.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "cocos-ext.h"
|
#include "cocos-ext.h"
|
||||||
|
|
||||||
|
|
|
@ -425,10 +425,10 @@ local function SpeedTest()
|
||||||
local spawn = cc.Spawn:create(seq3_1, seq3_2)
|
local spawn = cc.Spawn:create(seq3_1, seq3_2)
|
||||||
SpeedTest_action1 = cc.Speed:create(cc.RepeatForever:create(spawn), 1.0)
|
SpeedTest_action1 = cc.Speed:create(cc.RepeatForever:create(spawn), 1.0)
|
||||||
|
|
||||||
local spawn2 = tolua.cast(spawn:clone(), "cc.Spawn")
|
local spawn2 = spawn:clone()
|
||||||
SpeedTest_action2 = cc.Speed:create(cc.RepeatForever:create(spawn2), 1.0)
|
SpeedTest_action2 = cc.Speed:create(cc.RepeatForever:create(spawn2), 1.0)
|
||||||
|
|
||||||
local spawn3 = tolua.cast(spawn:clone(), "cc.Spawn")
|
local spawn3 = spawn:clone()
|
||||||
SpeedTest_action3 = cc.Speed:create(cc.RepeatForever:create(spawn3), 1.0)
|
SpeedTest_action3 = cc.Speed:create(cc.RepeatForever:create(spawn3), 1.0)
|
||||||
|
|
||||||
grossini:runAction(SpeedTest_action2)
|
grossini:runAction(SpeedTest_action2)
|
||||||
|
|
|
@ -550,8 +550,8 @@ local function ActionAnimate()
|
||||||
tamara:runAction(cc.Sequence:create(action2, action2:reverse()))
|
tamara:runAction(cc.Sequence:create(action2, action2:reverse()))
|
||||||
|
|
||||||
local animation3 = animation2:clone()
|
local animation3 = animation2:clone()
|
||||||
-- problem
|
|
||||||
tolua.cast(animation3,"cc.Animation"):setLoops(4)
|
animation3:setLoops(4)
|
||||||
|
|
||||||
local action3 = cc.Animate:create(animation3)
|
local action3 = cc.Animate:create(animation3)
|
||||||
kathia:runAction(action3)
|
kathia:runAction(action3)
|
||||||
|
@ -740,7 +740,7 @@ local function ActionRotateToRepeat()
|
||||||
local act2 = cc.RotateTo:create(1, 0)
|
local act2 = cc.RotateTo:create(1, 0)
|
||||||
local seq = cc.Sequence:create(act1, act2)
|
local seq = cc.Sequence:create(act1, act2)
|
||||||
local rep1 = cc.RepeatForever:create(seq)
|
local rep1 = cc.RepeatForever:create(seq)
|
||||||
local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "cc.Sequence"), 10)
|
local rep2 = cc.Repeat:create(seq:clone(), 10)
|
||||||
|
|
||||||
tamara:runAction(rep1)
|
tamara:runAction(rep1)
|
||||||
kathia:runAction(rep2)
|
kathia:runAction(rep2)
|
||||||
|
@ -931,8 +931,8 @@ local function ActionOrbit()
|
||||||
local seq = cc.Sequence:create(move, move_back)
|
local seq = cc.Sequence:create(move, move_back)
|
||||||
local rfe = cc.RepeatForever:create(seq)
|
local rfe = cc.RepeatForever:create(seq)
|
||||||
kathia:runAction(rfe)
|
kathia:runAction(rfe)
|
||||||
tamara:runAction(tolua.cast(rfe:clone(), "cc.ActionInterval"))
|
tamara:runAction(rfe:clone())
|
||||||
grossini:runAction(tolua.cast(rfe:clone(), "cc.ActionInterval"))
|
grossini:runAction(rfe:clone())
|
||||||
|
|
||||||
|
|
||||||
Helper.subtitleLabel:setString("OrbitCamera action")
|
Helper.subtitleLabel:setString("OrbitCamera action")
|
||||||
|
|
|
@ -428,7 +428,7 @@ end
|
||||||
|
|
||||||
function TestPerformance:refreshTitle()
|
function TestPerformance:refreshTitle()
|
||||||
local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount
|
local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount
|
||||||
local label = tolua.cast(self:getChildByTag(10001),"cc.LabelTTF")
|
local label = self:getChildByTag(10001)
|
||||||
label:setString(subTitleInfo)
|
label:setString(subTitleInfo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
09ed3c488f6d182685c416c291f8f325fb5cc2d2
|
55c597addccd9586d927093004a96fc08902b860
|
|
@ -193,9 +193,9 @@ function SpriteComponentTest:createGameScene()
|
||||||
local action1 = cc.Blink:create(2, 10)
|
local action1 = cc.Blink:create(2, 10)
|
||||||
local action2 = cc.Blink:create(2, 5)
|
local action2 = cc.Blink:create(2, 5)
|
||||||
|
|
||||||
local sister1 = tolua.cast(node:getChildByTag(10003):getComponent("CCSprite"),"ccs.ComRender")
|
local sister1 = node:getChildByTag(10003):getComponent("CCSprite")
|
||||||
sister1:getNode():runAction(action1)
|
sister1:getNode():runAction(action1)
|
||||||
local sister2 = tolua.cast(node:getChildByTag(10004):getComponent("CCSprite"),"ccs.ComRender")
|
local sister2 = node:getChildByTag(10004):getComponent("CCSprite")
|
||||||
sister2:getNode():runAction(action2)
|
sister2:getNode():runAction(action2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -245,10 +245,10 @@ end
|
||||||
function ArmatureComponentTest:createGameScene()
|
function ArmatureComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.json")
|
||||||
if nil ~= node then
|
if nil ~= node then
|
||||||
local blowFish = tolua.cast(node:getChildByTag(10007):getComponent("CCArmature"),"ccs.ComRender")
|
local blowFish = node:getChildByTag(10007):getComponent("CCArmature")
|
||||||
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||||
|
|
||||||
local butterflyfish = tolua.cast(node:getChildByTag(10008):getComponent("CCArmature"),"ccs.ComRender")
|
local butterflyfish = node:getChildByTag(10008):getComponent("CCArmature")
|
||||||
butterflyfish:getNode():runAction(CCMoveBy:create(10.0, cc.p(-1000.0, 0)))
|
butterflyfish:getNode():runAction(CCMoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -298,15 +298,15 @@ end
|
||||||
function UIComponentTest:createGameScene()
|
function UIComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.json")
|
||||||
if nil ~= node then
|
if nil ~= node then
|
||||||
local render = tolua.cast(node:getChildByTag(10025):getComponent("GUIComponent"),"ccs.ComRender")
|
local render = node:getChildByTag(10025):getComponent("GUIComponent")
|
||||||
local widget = tolua.cast(render:getNode(), "ccui.Widget")
|
local widget = render:getNode()
|
||||||
local button = tolua.cast(widget:getChildByName("Button_156"),"ccui.Button")
|
local button = widget:getChildByName("Button_156")
|
||||||
local function onTouch(sender, eventType)
|
local function onTouch(sender, eventType)
|
||||||
if eventType == ccui.TouchEventType.began then
|
if eventType == ccui.TouchEventType.began then
|
||||||
local blowFish = tolua.cast(node:getChildByTag(10010):getComponent("CCArmature"), "ccs.ComRender")
|
local blowFish = node:getChildByTag(10010):getComponent("CCArmature")
|
||||||
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||||
|
|
||||||
local butterflyfish = tolua.cast(node:getChildByTag(10011):getComponent("CCArmature"), "ccs.ComRender")
|
local butterflyfish = node:getChildByTag(10011):getComponent("CCArmature")
|
||||||
butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -360,7 +360,7 @@ end
|
||||||
function TmxMapComponentTest:createGameScene()
|
function TmxMapComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.json")
|
||||||
if nil ~= node then
|
if nil ~= node then
|
||||||
local tmxMap = tolua.cast(node:getChildByTag(10015):getComponent("CCTMXTiledMap"),"ccs.ComRender")
|
local tmxMap = node:getChildByTag(10015):getComponent("CCTMXTiledMap")
|
||||||
local actionTo = cc.SkewTo:create(2, 0.0, 2.0)
|
local actionTo = cc.SkewTo:create(2, 0.0, 2.0)
|
||||||
local rotateTo = cc.RotateTo:create(2, 61.0)
|
local rotateTo = cc.RotateTo:create(2, 61.0)
|
||||||
local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47)
|
local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47)
|
||||||
|
@ -420,7 +420,7 @@ end
|
||||||
function ParticleComponentTest:createGameScene()
|
function ParticleComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json")
|
||||||
if nil ~= node then
|
if nil ~= node then
|
||||||
local particle = tolua.cast(node:getChildByTag(10020):getComponent("CCParticleSystemQuad"),"ccs.ComRender")
|
local particle = node:getChildByTag(10020):getComponent("CCParticleSystemQuad")
|
||||||
local jump = cc.JumpBy:create(5, cc.p(-500,0), 50, 4)
|
local jump = cc.JumpBy:create(5, cc.p(-500,0), 50, 4)
|
||||||
local action = cc.Sequence:create( jump, jump:reverse())
|
local action = cc.Sequence:create( jump, jump:reverse())
|
||||||
particle:getNode():runAction(action)
|
particle:getNode():runAction(action)
|
||||||
|
@ -472,13 +472,13 @@ end
|
||||||
function EffectComponentTest:createGameScene()
|
function EffectComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json")
|
||||||
if nil ~= node then
|
if nil ~= node then
|
||||||
local render = tolua.cast(node:getChildByTag(10015):getComponent("CCArmature"),"ccs.ComRender")
|
local render = node:getChildByTag(10015):getComponent("CCArmature")
|
||||||
local armature = tolua.cast(render:getNode(),"ccs.Armature")
|
local armature = render:getNode()
|
||||||
local function animationEvent(armatureBack,movementType,movementID)
|
local function animationEvent(armatureBack,movementType,movementID)
|
||||||
local id = movementID
|
local id = movementID
|
||||||
if movementType == ccs.MovementEventType.loopComplete then
|
if movementType == ccs.MovementEventType.loopComplete then
|
||||||
if id == "Fire" then
|
if id == "Fire" then
|
||||||
local audio = tolua.cast(node:getChildByTag(10015):getComponent("CCComAudio"), "ccs.ComAudio")
|
local audio = node:getChildByTag(10015):getComponent("CCComAudio")
|
||||||
audio:playEffect()
|
audio:playEffect()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -533,7 +533,7 @@ end
|
||||||
function BackgroundComponentTest:createGameScene()
|
function BackgroundComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json")
|
||||||
if nil ~= node then
|
if nil ~= node then
|
||||||
local audio = tolua.cast(node:getComponent("CCBackgroundAudio"),"ccs.ComAudio")
|
local audio = node:getComponent("CCBackgroundAudio")
|
||||||
audio:playBackgroundMusic()
|
audio:playBackgroundMusic()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ end
|
||||||
|
|
||||||
function AttributeComponentTest:createGameScene()
|
function AttributeComponentTest:createGameScene()
|
||||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.json")
|
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.json")
|
||||||
local attribute = tolua.cast(node:getChildByTag(10015):getComponent("CCComAttribute"), "ccs.ComAttribute")
|
local attribute = node:getChildByTag(10015):getComponent("CCComAttribute")
|
||||||
print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP")))
|
print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP")))
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
|
|
|
@ -95,7 +95,7 @@ local function Effect2()
|
||||||
|
|
||||||
local delay = cc.DelayTime:create(1)
|
local delay = cc.DelayTime:create(1)
|
||||||
|
|
||||||
target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "cc.Action"), turnoff, turnon))
|
target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, delay:clone(), turnoff, turnon))
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ ccb["TestScrollViewsLayer"] = TestScrollViewsLayer
|
||||||
|
|
||||||
local function onMenuItemAClicked()
|
local function onMenuItemAClicked()
|
||||||
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
||||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont")
|
local labelBmFt = TestMenusLayer["mMenuItemStatusLabelBMFont"]
|
||||||
if nil ~= labelBmFt then
|
if nil ~= labelBmFt then
|
||||||
labelBmFt:setString("Menu Item A clicked.");
|
labelBmFt:setString("Menu Item A clicked.");
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ end
|
||||||
|
|
||||||
local function onMenuItemBClicked()
|
local function onMenuItemBClicked()
|
||||||
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
||||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont")
|
local labelBmFt = TestMenusLayer["mMenuItemStatusLabelBMFont"]
|
||||||
if nil ~= labelBmFt then
|
if nil ~= labelBmFt then
|
||||||
labelBmFt:setString("Menu Item B clicked.");
|
labelBmFt:setString("Menu Item B clicked.");
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ end
|
||||||
|
|
||||||
local function pressedC( ... )
|
local function pressedC( ... )
|
||||||
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
||||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont")
|
local labelBmFt = TestMenusLayer["mMenuItemStatusLabelBMFont"]
|
||||||
if nil ~= labelBmFt then
|
if nil ~= labelBmFt then
|
||||||
labelBmFt:setString("Menu Item C clicked.");
|
labelBmFt:setString("Menu Item C clicked.");
|
||||||
end
|
end
|
||||||
|
@ -59,9 +59,9 @@ local function onMenuTestClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestMenus.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestMenus.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -88,9 +88,9 @@ local function onSpriteTestClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestSprites.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestSprites.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -107,9 +107,9 @@ local function onButtonTestClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestButtons.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestButtons.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -122,7 +122,7 @@ local function onButtonTestClicked()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onCCControlButtonClicked(sender,controlEvent)
|
local function onCCControlButtonClicked(sender,controlEvent)
|
||||||
local labelTTF = tolua.cast(TestButtonsLayer["mCCControlEventLabel"],"cc.LabelBMFont")
|
local labelTTF = TestButtonsLayer["mCCControlEventLabel"]
|
||||||
|
|
||||||
if nil == labelTTF then
|
if nil == labelTTF then
|
||||||
return
|
return
|
||||||
|
@ -158,9 +158,9 @@ local function onAnimationsTestClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestAnimations.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestAnimations.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -177,9 +177,9 @@ local function onParticleSystemTestClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestParticleSystems.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestParticleSystems.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -193,7 +193,7 @@ end
|
||||||
|
|
||||||
local function onCCControlButtonIdleClicked()
|
local function onCCControlButtonIdleClicked()
|
||||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
local animationMgr = TestAnimationsLayer["mAnimationManager"]
|
||||||
if nil ~= animationMgr then
|
if nil ~= animationMgr then
|
||||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Idle", 0.3)
|
animationMgr:runAnimationsForSequenceNamedTweenDuration("Idle", 0.3)
|
||||||
end
|
end
|
||||||
|
@ -202,7 +202,7 @@ end
|
||||||
|
|
||||||
local function onCCControlButtonWaveClicked()
|
local function onCCControlButtonWaveClicked()
|
||||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
local animationMgr = TestAnimationsLayer["mAnimationManager"]
|
||||||
if nil ~= animationMgr then
|
if nil ~= animationMgr then
|
||||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Wave", 0.3)
|
animationMgr:runAnimationsForSequenceNamedTweenDuration("Wave", 0.3)
|
||||||
end
|
end
|
||||||
|
@ -211,7 +211,7 @@ end
|
||||||
|
|
||||||
local function onCCControlButtonJumpClicked()
|
local function onCCControlButtonJumpClicked()
|
||||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
local animationMgr = TestAnimationsLayer["mAnimationManager"]
|
||||||
if nil ~= animationMgr then
|
if nil ~= animationMgr then
|
||||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Jump", 0.3)
|
animationMgr:runAnimationsForSequenceNamedTweenDuration("Jump", 0.3)
|
||||||
end
|
end
|
||||||
|
@ -220,7 +220,7 @@ end
|
||||||
|
|
||||||
local function onCCControlButtonFunkyClicked()
|
local function onCCControlButtonFunkyClicked()
|
||||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
local animationMgr = TestAnimationsLayer["mAnimationManager"]
|
||||||
if nil ~= animationMgr then
|
if nil ~= animationMgr then
|
||||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Funky", 0.3)
|
animationMgr:runAnimationsForSequenceNamedTweenDuration("Funky", 0.3)
|
||||||
end
|
end
|
||||||
|
@ -237,9 +237,9 @@ local function onScrollViewTestClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestScrollViews.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestScrollViews.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestScrollViews.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestScrollViews.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -256,9 +256,9 @@ local function onTimelineCallbackSoundClicked()
|
||||||
local scene = cc.Scene:create()
|
local scene = cc.Scene:create()
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
local ccLabelTTF = HelloCocosBuilderLayer["mTestTitleLabelTTF"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:setString("ccb/ccb/TestTimelineCallback.ccbi")
|
ccLabelTTF:setString("ccb/ccb/TestTimelineCallback.ccbi")
|
||||||
end
|
end
|
||||||
|
@ -272,7 +272,7 @@ end
|
||||||
|
|
||||||
function onCallback1()
|
function onCallback1()
|
||||||
if nil ~= TestTimelineLayer["helloLabel"] then
|
if nil ~= TestTimelineLayer["helloLabel"] then
|
||||||
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"cc.LabelTTF")
|
local ccLabelTTF = TestTimelineLayer["helloLabel"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:runAction(cc.RotateBy:create(1, 360))
|
ccLabelTTF:runAction(cc.RotateBy:create(1, 360))
|
||||||
ccLabelTTF:setString("Callback 1");
|
ccLabelTTF:setString("Callback 1");
|
||||||
|
@ -282,7 +282,7 @@ end
|
||||||
|
|
||||||
function onCallback2()
|
function onCallback2()
|
||||||
if nil ~= TestTimelineLayer["helloLabel"] then
|
if nil ~= TestTimelineLayer["helloLabel"] then
|
||||||
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"cc.LabelTTF")
|
local ccLabelTTF = TestTimelineLayer["helloLabel"]
|
||||||
if nil ~= ccLabelTTF then
|
if nil ~= ccLabelTTF then
|
||||||
ccLabelTTF:runAction(cc.RotateBy:create(2, 360))
|
ccLabelTTF:runAction(cc.RotateBy:create(2, 360))
|
||||||
ccLabelTTF:setString("Callback 2");
|
ccLabelTTF:setString("Callback 2");
|
||||||
|
@ -306,7 +306,7 @@ local function HelloCCBTestMainLayer()
|
||||||
print(type(cc.Scene))
|
print(type(cc.Scene))
|
||||||
local proxy = cc.CCBProxy:create()
|
local proxy = cc.CCBProxy:create()
|
||||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,HelloCocosBuilderLayer)
|
local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,HelloCocosBuilderLayer)
|
||||||
local layer = tolua.cast(node,"cc.Layer")
|
local layer = node
|
||||||
return layer
|
return layer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ local function runNotificationCenterTest()
|
||||||
local s = cc.Director:getInstance():getWinSize()
|
local s = cc.Director:getInstance():getWinSize()
|
||||||
|
|
||||||
local function toggleSwitch(tag,menuItem)
|
local function toggleSwitch(tag,menuItem)
|
||||||
local toggleItem = tolua.cast(menuItem,"cc.MenuItemToggle")
|
local toggleItem = menuItem
|
||||||
local nIndex = toggleItem:getSelectedIndex()
|
local nIndex = toggleItem:getSelectedIndex()
|
||||||
local selectedItem = toggleItem:getSelectedItem()
|
local selectedItem = toggleItem:getSelectedItem()
|
||||||
if 0 == nIndex then
|
if 0 == nIndex then
|
||||||
|
@ -155,7 +155,7 @@ local function runNotificationCenterTest()
|
||||||
connectitem:setTag(NotificationCenterParam.kTagConnect+i)
|
connectitem:setTag(NotificationCenterParam.kTagConnect+i)
|
||||||
|
|
||||||
local function connectToSwitch(tag,menuItem)
|
local function connectToSwitch(tag,menuItem)
|
||||||
local connectMenuitem = tolua.cast(menuItem,"cc.MenuItemToggle")
|
local connectMenuitem = menuItem
|
||||||
local bConnected = true
|
local bConnected = true
|
||||||
if connectMenuitem:getSelectedIndex() == 0 then
|
if connectMenuitem:getSelectedIndex() == 0 then
|
||||||
bConnected = false
|
bConnected = false
|
||||||
|
@ -376,7 +376,7 @@ local function runCCControlTest()
|
||||||
if nil == pSender or nil == pDisplayValueLabel then
|
if nil == pSender or nil == pDisplayValueLabel then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pControl = tolua.cast(pSender,"cc.ControlSlider")
|
local pControl = pSender
|
||||||
local strFmt = nil
|
local strFmt = nil
|
||||||
if pControl:getTag() == 1 then
|
if pControl:getTag() == 1 then
|
||||||
strFmt = string.format("Upper slider value = %.02f",pControl:getValue())
|
strFmt = string.format("Upper slider value = %.02f",pControl:getValue())
|
||||||
|
@ -434,7 +434,7 @@ local function runCCControlTest()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pPicker = tolua.cast(pSender,"cc.ControlColourPicker")
|
local pPicker = pSender
|
||||||
local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b)
|
local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b)
|
||||||
pColorLabel:setString(strFmt)
|
pColorLabel:setString(strFmt)
|
||||||
end
|
end
|
||||||
|
@ -499,7 +499,7 @@ local function runCCControlTest()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pControl = tolua.cast(pSender,"cc.ControlSwitch")
|
local pControl = pSender
|
||||||
if pControl:isOn() then
|
if pControl:isOn() then
|
||||||
pDisplayValueLabel:setString("On")
|
pDisplayValueLabel:setString("On")
|
||||||
else
|
else
|
||||||
|
@ -774,7 +774,7 @@ local function runCCControlTest()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pControl = tolua.cast(pSender,"cc.ControlPotentiometer")
|
local pControl = pSender
|
||||||
local strFmt = string.format("%0.2f",pControl:getValue())
|
local strFmt = string.format("%0.2f",pControl:getValue())
|
||||||
pDisplayValueLabel:setString(strFmt )
|
pDisplayValueLabel:setString(strFmt )
|
||||||
end
|
end
|
||||||
|
@ -831,7 +831,7 @@ local function runCCControlTest()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pControl = tolua.cast(pSender,"cc.ControlStepper")
|
local pControl = pSender
|
||||||
local strFmt = string.format("%0.02f",pControl:getValue() )
|
local strFmt = string.format("%0.02f",pControl:getValue() )
|
||||||
pDisplayValueLabel:setString(strFmt )
|
pDisplayValueLabel:setString(strFmt )
|
||||||
end
|
end
|
||||||
|
@ -917,7 +917,7 @@ local function runEditBoxTest()
|
||||||
local EditEmail = nil
|
local EditEmail = nil
|
||||||
|
|
||||||
local function editBoxTextEventHandle(strEventName,pSender)
|
local function editBoxTextEventHandle(strEventName,pSender)
|
||||||
local edit = tolua.cast(pSender,"cc.EditBox")
|
local edit = pSender
|
||||||
local strFmt
|
local strFmt
|
||||||
if strEventName == "began" then
|
if strEventName == "began" then
|
||||||
strFmt = string.format("editBox %p DidBegin !", edit)
|
strFmt = string.format("editBox %p DidBegin !", edit)
|
||||||
|
@ -1038,7 +1038,7 @@ function TableViewTestLayer.tableCellAtIndex(table, idx)
|
||||||
label:setTag(123)
|
label:setTag(123)
|
||||||
cell:addChild(label)
|
cell:addChild(label)
|
||||||
else
|
else
|
||||||
label = tolua.cast(cell:getChildByTag(123),"cc.LabelTTF")
|
label = cell:getChildByTag(123)
|
||||||
if nil ~= label then
|
if nil ~= label then
|
||||||
label:setString(strValue)
|
label:setString(strValue)
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,11 +32,11 @@ function LabelAtlasTest.step(dt)
|
||||||
local string = string.format("%2.2f Test", m_time)
|
local string = string.format("%2.2f Test", m_time)
|
||||||
|
|
||||||
local label1_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite1)
|
local label1_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite1)
|
||||||
local label1 = tolua.cast(label1_origin, "cc.LabelAtlas")
|
local label1 = label1_origin
|
||||||
label1:setString(string) --
|
label1:setString(string) --
|
||||||
|
|
||||||
local label2_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite2)
|
local label2_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite2)
|
||||||
local label2 = tolua.cast(label2_origin, "cc.LabelAtlas")
|
local label2 = label2_origin
|
||||||
string = string.format("%d", m_time)
|
string = string.format("%d", m_time)
|
||||||
|
|
||||||
label2:setString(string)
|
label2:setString(string)
|
||||||
|
@ -88,11 +88,11 @@ function LabelAtlasColorTest.step(dt)
|
||||||
m_time = m_time + dt
|
m_time = m_time + dt
|
||||||
local string = string.format("%2.2f Test", m_time)
|
local string = string.format("%2.2f Test", m_time)
|
||||||
local label1_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite1)
|
local label1_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite1)
|
||||||
local label1 = tolua.cast(label1_origin, "cc.LabelAtlas")
|
local label1 = label1_origin
|
||||||
label1:setString(string)
|
label1:setString(string)
|
||||||
|
|
||||||
local label2_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite2)
|
local label2_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite2)
|
||||||
local label2 = tolua.cast(label2_origin, "cc.LabelAtlas")
|
local label2 = label2_origin
|
||||||
string = string.format("%d", m_time)
|
string = string.format("%d", m_time)
|
||||||
|
|
||||||
label2:setString(string)
|
label2:setString(string)
|
||||||
|
@ -199,7 +199,7 @@ function Atlas3.create()
|
||||||
label2:setColor(cc.c3b(255, 0, 0 ))
|
label2:setColor(cc.c3b(255, 0, 0 ))
|
||||||
layer:addChild(label2, 0, kTagBitmapAtlas2)
|
layer:addChild(label2, 0, kTagBitmapAtlas2)
|
||||||
|
|
||||||
label2:runAction( tolua.cast(repeatAction:clone(), "cc.Action") )
|
label2:runAction( repeatAction:clone())
|
||||||
|
|
||||||
local label3 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt")
|
local label3 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt")
|
||||||
-- testing anchors
|
-- testing anchors
|
||||||
|
@ -223,13 +223,13 @@ function Atlas3.step(dt)
|
||||||
m_time = m_time + dt
|
m_time = m_time + dt
|
||||||
local string = string.format("%2.2f Test j", m_time)
|
local string = string.format("%2.2f Test j", m_time)
|
||||||
|
|
||||||
local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "cc.LabelBMFont")
|
local label1 = Atlas3.layer:getChildByTag(kTagBitmapAtlas1)
|
||||||
label1:setString(string)
|
label1:setString(string)
|
||||||
|
|
||||||
local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelBMFont")
|
local label2 = Atlas3.layer:getChildByTag(kTagBitmapAtlas2)
|
||||||
label2:setString(string)
|
label2:setString(string)
|
||||||
|
|
||||||
local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "cc.LabelBMFont")
|
local label3 = Atlas3.layer:getChildByTag(kTagBitmapAtlas3)
|
||||||
label3:setString(string)
|
label3:setString(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ function Atlas4.create()
|
||||||
label2:setPosition( cc.p(s.width/2.0, 80) )
|
label2:setPosition( cc.p(s.width/2.0, 80) )
|
||||||
|
|
||||||
local lastChar = label2:getChildByTag(3)
|
local lastChar = label2:getChildByTag(3)
|
||||||
lastChar:runAction(tolua.cast( rot_4ever:clone(), "cc.Action" ))
|
lastChar:runAction(rot_4ever:clone())
|
||||||
|
|
||||||
layer:registerScriptHandler(Atlas4.onNodeEvent)
|
layer:registerScriptHandler(Atlas4.onNodeEvent)
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ function Atlas4.step(dt)
|
||||||
|
|
||||||
local string = string.format("%04.1f", m_time)
|
local string = string.format("%04.1f", m_time)
|
||||||
|
|
||||||
local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelBMFont")
|
local label1 = Atlas4.layer:getChildByTag(kTagBitmapAtlas2)
|
||||||
label1:setString(string)
|
label1:setString(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -592,9 +592,9 @@ function LabelsEmpty.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
function LabelsEmpty.updateStrings(dt)
|
function LabelsEmpty.updateStrings(dt)
|
||||||
local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "cc.LabelBMFont")
|
local label1 = LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1)
|
||||||
local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelTTF")
|
local label2 = LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2)
|
||||||
local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "cc.LabelAtlas")
|
local label3 = LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3)
|
||||||
|
|
||||||
if( LabelsEmpty.setEmpty == false) then
|
if( LabelsEmpty.setEmpty == false) then
|
||||||
label1:setString("not empty")
|
label1:setString("not empty")
|
||||||
|
@ -1118,7 +1118,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
function BitmapFontMultiLineAlignment.stringChanged(tag, sender)
|
function BitmapFontMultiLineAlignment.stringChanged(tag, sender)
|
||||||
local item = tolua.cast(sender, "cc.MenuItemFont")
|
local item = sender
|
||||||
item:setColor(cc.c3b(255, 0, 0))
|
item:setColor(cc.c3b(255, 0, 0))
|
||||||
BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
||||||
BitmapFontMultiLineAlignment._pLastAlignmentItem = item
|
BitmapFontMultiLineAlignment._pLastAlignmentItem = item
|
||||||
|
@ -1136,7 +1136,7 @@ end
|
||||||
|
|
||||||
function BitmapFontMultiLineAlignment.alignmentChanged(tag, sender)
|
function BitmapFontMultiLineAlignment.alignmentChanged(tag, sender)
|
||||||
-- cclog("BitmapFontMultiLineAlignment.alignmentChanged, tag:"..tag)
|
-- cclog("BitmapFontMultiLineAlignment.alignmentChanged, tag:"..tag)
|
||||||
local item = tolua.cast(sender, "cc.MenuItemFont")
|
local item = sender
|
||||||
item:setColor(cc.c3b(255, 0, 0))
|
item:setColor(cc.c3b(255, 0, 0))
|
||||||
BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
||||||
BitmapFontMultiLineAlignment._pLastAlignmentItem = item
|
BitmapFontMultiLineAlignment._pLastAlignmentItem = item
|
||||||
|
|
|
@ -61,7 +61,7 @@ function LabelFNTColorAndOpacity.create()
|
||||||
label2:setColor(cc.c3b(255, 0, 0 ))
|
label2:setColor(cc.c3b(255, 0, 0 ))
|
||||||
layer:addChild(label2, 0, kTagBitmapAtlas2)
|
layer:addChild(label2, 0, kTagBitmapAtlas2)
|
||||||
|
|
||||||
label2:runAction( tolua.cast(repeatAction:clone(), "cc.Action") )
|
label2:runAction(repeatAction:clone())
|
||||||
|
|
||||||
local label3 = cc.Label:createWithBMFont("fonts/bitmapFontTest2.fnt", "Test")
|
local label3 = cc.Label:createWithBMFont("fonts/bitmapFontTest2.fnt", "Test")
|
||||||
-- testing anchors
|
-- testing anchors
|
||||||
|
@ -85,13 +85,13 @@ function LabelFNTColorAndOpacity.step(dt)
|
||||||
m_time = m_time + dt
|
m_time = m_time + dt
|
||||||
local string = string.format("%2.2f Test j", m_time)
|
local string = string.format("%2.2f Test j", m_time)
|
||||||
|
|
||||||
local label1 = tolua.cast(LabelFNTColorAndOpacity.layer:getChildByTag(kTagBitmapAtlas1), "cc.Label")
|
local label1 = LabelFNTColorAndOpacity.layer:getChildByTag(kTagBitmapAtlas1)
|
||||||
label1:setString(string)
|
label1:setString(string)
|
||||||
|
|
||||||
local label2 = tolua.cast(LabelFNTColorAndOpacity.layer:getChildByTag(kTagBitmapAtlas2), "cc.Label")
|
local label2 = LabelFNTColorAndOpacity.layer:getChildByTag(kTagBitmapAtlas2)
|
||||||
label2:setString(string)
|
label2:setString(string)
|
||||||
|
|
||||||
local label3 = tolua.cast(LabelFNTColorAndOpacity.layer:getChildByTag(kTagBitmapAtlas3), "cc.Label")
|
local label3 = LabelFNTColorAndOpacity.layer:getChildByTag(kTagBitmapAtlas3)
|
||||||
label3:setString(string)
|
label3:setString(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ function LabelFNTSpriteActions.create()
|
||||||
label2:setPosition( cc.p(s.width/2.0, 80) )
|
label2:setPosition( cc.p(s.width/2.0, 80) )
|
||||||
|
|
||||||
local lastChar = label2:getLetter(3)
|
local lastChar = label2:getLetter(3)
|
||||||
lastChar:runAction(tolua.cast( rot_4ever:clone(), "cc.Action" ))
|
lastChar:runAction(rot_4ever:clone())
|
||||||
|
|
||||||
layer:registerScriptHandler(LabelFNTSpriteActions.onNodeEvent)
|
layer:registerScriptHandler(LabelFNTSpriteActions.onNodeEvent)
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ function LabelFNTMultiLineAlignment.create()
|
||||||
|
|
||||||
local labelWidth = math.abs(LabelFNTMultiLineAlignment._pArrowsShouldRetain:getPositionX() - LabelFNTMultiLineAlignment._pLabelShouldRetain:getPositionX()) * 2
|
local labelWidth = math.abs(LabelFNTMultiLineAlignment._pArrowsShouldRetain:getPositionX() - LabelFNTMultiLineAlignment._pLabelShouldRetain:getPositionX()) * 2
|
||||||
|
|
||||||
LabelFNTMultiLineAlignment._pLabelShouldRetain:setWidth(labelWidth)
|
LabelFNTMultiLineAlignment._pLabelShouldRetain:setMaxLineWidth(labelWidth)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onTouchesEnded(touch, event)
|
local function onTouchesEnded(touch, event)
|
||||||
|
@ -725,7 +725,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
function LabelFNTMultiLineAlignment.stringChanged(tag, sender)
|
function LabelFNTMultiLineAlignment.stringChanged(tag, sender)
|
||||||
local item = tolua.cast(sender, "cc.MenuItemFont")
|
local item = sender
|
||||||
item:setColor(cc.c3b(255, 0, 0))
|
item:setColor(cc.c3b(255, 0, 0))
|
||||||
LabelFNTMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
LabelFNTMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
||||||
LabelFNTMultiLineAlignment._pLastAlignmentItem = item
|
LabelFNTMultiLineAlignment._pLastAlignmentItem = item
|
||||||
|
@ -743,7 +743,7 @@ end
|
||||||
|
|
||||||
function LabelFNTMultiLineAlignment.alignmentChanged(tag, sender)
|
function LabelFNTMultiLineAlignment.alignmentChanged(tag, sender)
|
||||||
-- cclog("LabelFNTMultiLineAlignment.alignmentChanged, tag:"..tag)
|
-- cclog("LabelFNTMultiLineAlignment.alignmentChanged, tag:"..tag)
|
||||||
local item = tolua.cast(sender, "cc.MenuItemFont")
|
local item = sender
|
||||||
item:setColor(cc.c3b(255, 0, 0))
|
item:setColor(cc.c3b(255, 0, 0))
|
||||||
LabelFNTMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
LabelFNTMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
||||||
LabelFNTMultiLineAlignment._pLastAlignmentItem = item
|
LabelFNTMultiLineAlignment._pLastAlignmentItem = item
|
||||||
|
|
|
@ -314,7 +314,7 @@ local function LayerTest1()
|
||||||
|
|
||||||
local newSize = cc.size( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2)
|
local newSize = cc.size( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2)
|
||||||
|
|
||||||
local l = tolua.cast(ret:getChildByTag(kTagLayer), "cc.LayerColor")
|
local l = ret:getChildByTag(kTagLayer)
|
||||||
|
|
||||||
l:setContentSize( newSize )
|
l:setContentSize( newSize )
|
||||||
end
|
end
|
||||||
|
@ -395,7 +395,7 @@ local function LayerTestBlend()
|
||||||
local blend = true
|
local blend = true
|
||||||
|
|
||||||
local function newBlend(dt)
|
local function newBlend(dt)
|
||||||
local layer = tolua.cast(ret:getChildByTag(kTagLayer), "cc.LayerColor")
|
local layer = ret:getChildByTag(kTagLayer)
|
||||||
|
|
||||||
local src = 0
|
local src = 0
|
||||||
local dst = 0
|
local dst = 0
|
||||||
|
@ -445,7 +445,7 @@ local function LayerGradient()
|
||||||
|
|
||||||
local function toggleItem(sender)
|
local function toggleItem(sender)
|
||||||
-- cclog("toggleItem")
|
-- cclog("toggleItem")
|
||||||
local gradient = tolua.cast(ret:getChildByTag(kTagLayer), "cc.LayerGradient")
|
local gradient = ret:getChildByTag(kTagLayer)
|
||||||
gradient:setCompressedInterpolation(not gradient:isCompressedInterpolation())
|
gradient:setCompressedInterpolation(not gradient:isCompressedInterpolation())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ local function LayerGradient()
|
||||||
local diff = cc.p(movingPos.x - start.x, movingPos.y - start.y)
|
local diff = cc.p(movingPos.x - start.x, movingPos.y - start.y)
|
||||||
diff = cc.pNormalize(diff)
|
diff = cc.pNormalize(diff)
|
||||||
|
|
||||||
local gradient = tolua.cast(ret:getChildByTag(1), "cc.LayerGradient")
|
local gradient = ret:getChildByTag(1)
|
||||||
gradient:setVector(diff)
|
gradient:setVector(diff)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ local function LayerIgnoreAnchorPointPos()
|
||||||
l:setPosition(cc.p( s.width/2, s.height/2))
|
l:setPosition(cc.p( s.width/2, s.height/2))
|
||||||
|
|
||||||
local move = cc.MoveBy:create(2, cc.p(100,2))
|
local move = cc.MoveBy:create(2, cc.p(100,2))
|
||||||
local back = tolua.cast(move:reverse(), "cc.MoveBy")
|
local back = move:reverse()
|
||||||
local seq = cc.Sequence:create(move, back)
|
local seq = cc.Sequence:create(move, back)
|
||||||
l:runAction(cc.RepeatForever:create(seq))
|
l:runAction(cc.RepeatForever:create(seq))
|
||||||
ret:addChild(l, 0, kLayerIgnoreAnchorPoint)
|
ret:addChild(l, 0, kLayerIgnoreAnchorPoint)
|
||||||
|
@ -569,7 +569,7 @@ local function LayerIgnoreAnchorPointScale()
|
||||||
|
|
||||||
|
|
||||||
local scale = cc.ScaleBy:create(2, 2)
|
local scale = cc.ScaleBy:create(2, 2)
|
||||||
local back = tolua.cast(scale:reverse(), "cc.ScaleBy")
|
local back = scale:reverse()
|
||||||
local seq = cc.Sequence:create(scale, back)
|
local seq = cc.Sequence:create(scale, back)
|
||||||
|
|
||||||
l:runAction(cc.RepeatForever:create(seq))
|
l:runAction(cc.RepeatForever:create(seq))
|
||||||
|
|
|
@ -32,13 +32,13 @@ local function MenuLayerMainMenu()
|
||||||
|
|
||||||
local function menuCallback(sender)
|
local function menuCallback(sender)
|
||||||
cclog("menuCallback...")
|
cclog("menuCallback...")
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(1)
|
ret:getParent():switchTo(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
item1:registerScriptTapHandler(menuCallback)
|
item1:registerScriptTapHandler(menuCallback)
|
||||||
-- Image Item
|
-- Image Item
|
||||||
local function menuCallback2(sender)
|
local function menuCallback2(sender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(2)
|
ret:getParent():switchTo(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local item2 = cc.MenuItemImage:create(s_SendScore, s_PressSendScore)
|
local item2 = cc.MenuItemImage:create(s_SendScore, s_PressSendScore)
|
||||||
|
@ -46,7 +46,7 @@ local function MenuLayerMainMenu()
|
||||||
|
|
||||||
|
|
||||||
local schedulerEntry = nil
|
local schedulerEntry = nil
|
||||||
local scheduler = cc.Director:getInstance():getScheduler()
|
local scheduler = cc.Director:getInstance():getScheduler()
|
||||||
local function allowTouches(dt)
|
local function allowTouches(dt)
|
||||||
local pDirector = cc.Director:getInstance()
|
local pDirector = cc.Director:getInstance()
|
||||||
--pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY +1, ret)
|
--pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY +1, ret)
|
||||||
|
@ -85,7 +85,7 @@ local function MenuLayerMainMenu()
|
||||||
cc.MenuItemFont:setFontName("Marker Felt")
|
cc.MenuItemFont:setFontName("Marker Felt")
|
||||||
|
|
||||||
local function menuCallbackConfig(sender)
|
local function menuCallbackConfig(sender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(3)
|
ret:getParent():switchTo(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Label Item (cc.LabelBMFont)
|
-- Label Item (cc.LabelBMFont)
|
||||||
|
@ -99,7 +99,7 @@ local function MenuLayerMainMenu()
|
||||||
-- Events
|
-- Events
|
||||||
cc.MenuItemFont:setFontName("Marker Felt")
|
cc.MenuItemFont:setFontName("Marker Felt")
|
||||||
local function menuCallbackBugsTest(pSender)
|
local function menuCallbackBugsTest(pSender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(4)
|
ret:getParent():switchTo(4)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Bugs Item
|
-- Bugs Item
|
||||||
|
@ -115,7 +115,7 @@ local function MenuLayerMainMenu()
|
||||||
item7:registerScriptTapHandler(onQuit)
|
item7:registerScriptTapHandler(onQuit)
|
||||||
|
|
||||||
local function menuMovingCallback(pSender)
|
local function menuMovingCallback(pSender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(5)
|
ret:getParent():switchTo(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
local item8 = cc.MenuItemFont:create("Remove menu item when moving")
|
local item8 = cc.MenuItemFont:create("Remove menu item when moving")
|
||||||
|
@ -152,7 +152,7 @@ local function MenuLayerMainMenu()
|
||||||
if pObject == nil then
|
if pObject == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
child = tolua.cast(pObject, "cc.Node")
|
child = pObject
|
||||||
local dstPointX, dstPointY = child:getPosition()
|
local dstPointX, dstPointY = child:getPosition()
|
||||||
local offset = s.width/2 + 50
|
local offset = s.width/2 + 50
|
||||||
if i % 2 == 0 then
|
if i % 2 == 0 then
|
||||||
|
@ -200,7 +200,7 @@ local function MenuLayer2()
|
||||||
local function alignMenusH()
|
local function alignMenusH()
|
||||||
local i = 0
|
local i = 0
|
||||||
for i=0, 1 do
|
for i=0, 1 do
|
||||||
local menu = tolua.cast(ret:getChildByTag(100+i), "cc.Menu")
|
local menu = ret:getChildByTag(100+i)
|
||||||
menu:setPosition( m_centeredMenu )
|
menu:setPosition( m_centeredMenu )
|
||||||
if i==0 then
|
if i==0 then
|
||||||
-- TIP: if no padding, padding = 5
|
-- TIP: if no padding, padding = 5
|
||||||
|
@ -219,7 +219,7 @@ local function MenuLayer2()
|
||||||
local function alignMenusV()
|
local function alignMenusV()
|
||||||
local i = 0
|
local i = 0
|
||||||
for i=0, 1 do
|
for i=0, 1 do
|
||||||
local menu = tolua.cast(ret:getChildByTag(100+i), "cc.Menu")
|
local menu = ret:getChildByTag(100+i)
|
||||||
menu:setPosition( m_centeredMenu )
|
menu:setPosition( m_centeredMenu )
|
||||||
if i==0 then
|
if i==0 then
|
||||||
-- TIP: if no padding, padding = 5
|
-- TIP: if no padding, padding = 5
|
||||||
|
@ -236,11 +236,11 @@ local function MenuLayer2()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function menuCallback(sender)
|
local function menuCallback(sender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0)
|
ret:getParent():switchTo(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function menuCallbackOpacity(tag, sender)
|
local function menuCallbackOpacity(tag, sender)
|
||||||
local menu = tolua.cast(sender:getParent(), "cc.Menu")
|
local menu = sender:getParent()
|
||||||
local opacity = menu:getOpacity()
|
local opacity = menu:getOpacity()
|
||||||
if opacity == 128 then
|
if opacity == 128 then
|
||||||
menu:setOpacity(255)
|
menu:setOpacity(255)
|
||||||
|
@ -305,7 +305,7 @@ local function MenuLayer3()
|
||||||
local m_disabledItem = nil
|
local m_disabledItem = nil
|
||||||
local ret = cc.Layer:create()
|
local ret = cc.Layer:create()
|
||||||
local function menuCallback(sender)
|
local function menuCallback(sender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0)
|
ret:getParent():switchTo(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function menuCallback2(sender)
|
local function menuCallback2(sender)
|
||||||
|
@ -357,8 +357,8 @@ local function MenuLayer3()
|
||||||
item2:runAction( cc.RepeatForever:create(cc.Sequence:create( jump, jump:reverse())))
|
item2:runAction( cc.RepeatForever:create(cc.Sequence:create( jump, jump:reverse())))
|
||||||
|
|
||||||
local spin1 = cc.RotateBy:create(3, 360)
|
local spin1 = cc.RotateBy:create(3, 360)
|
||||||
local spin2 = tolua.cast(spin1:clone(), "cc.ActionInterval")
|
local spin2 = spin1:clone()
|
||||||
local spin3 = tolua.cast(spin1:clone(), "cc.ActionInterval")
|
local spin3 = spin1:clone()
|
||||||
|
|
||||||
item1:runAction( cc.RepeatForever:create(spin1) )
|
item1:runAction( cc.RepeatForever:create(spin1) )
|
||||||
item2:runAction( cc.RepeatForever:create(spin2) )
|
item2:runAction( cc.RepeatForever:create(spin2) )
|
||||||
|
@ -398,11 +398,11 @@ local function MenuLayer4()
|
||||||
local item1 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" ))
|
local item1 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" ))
|
||||||
|
|
||||||
local function menuCallback(tag, sender)
|
local function menuCallback(tag, sender)
|
||||||
cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "cc.MenuItemToggle"):getSelectedIndex() )
|
cclog("selected item: tag: %d, index:%d", tag, sender:getSelectedIndex() )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function backCallback(tag, sender)
|
local function backCallback(tag, sender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0)
|
ret:getParent():switchTo(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
item1:registerScriptTapHandler(menuCallback)
|
item1:registerScriptTapHandler(menuCallback)
|
||||||
|
@ -475,21 +475,21 @@ end
|
||||||
local function BugsTest()
|
local function BugsTest()
|
||||||
local ret = cc.Layer:create()
|
local ret = cc.Layer:create()
|
||||||
local function issue1410MenuCallback(tag, pSender)
|
local function issue1410MenuCallback(tag, pSender)
|
||||||
local menu = tolua.cast(pSender:getParent(), "cc.Menu")
|
local menu = pSender:getParent()
|
||||||
menu:setEnabled(false)
|
menu:setEnabled(false)
|
||||||
menu:setEnabled(true)
|
menu:setEnabled(true)
|
||||||
cclog("NO CRASHES")
|
cclog("NO CRASHES")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function issue1410v2MenuCallback(tag, pSender)
|
local function issue1410v2MenuCallback(tag, pSender)
|
||||||
local menu = tolua.cast(pSender:getParent(), "cc.Menu")
|
local menu = pSender:getParent()
|
||||||
menu:setEnabled(true)
|
menu:setEnabled(true)
|
||||||
menu:setEnabled(false)
|
menu:setEnabled(false)
|
||||||
cclog("NO CRASHES. AND MENU SHOULD STOP WORKING")
|
cclog("NO CRASHES. AND MENU SHOULD STOP WORKING")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function backMenuCallback(tag, pSender)
|
local function backMenuCallback(tag, pSender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0)
|
ret:getParent():switchTo(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ local function RemoveMenuItemWhenMove()
|
||||||
|
|
||||||
local back = cc.MenuItemFont:create("go back")
|
local back = cc.MenuItemFont:create("go back")
|
||||||
local function goBack(tag, pSender)
|
local function goBack(tag, pSender)
|
||||||
tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0)
|
ret:getParent():switchTo(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
back:registerScriptTapHandler(goBack)
|
back:registerScriptTapHandler(goBack)
|
||||||
|
|
|
@ -184,7 +184,7 @@ function TouchableSpriteTest:onEnter()
|
||||||
sprite2:addChild(sprite3, 1)
|
sprite2:addChild(sprite3, 1)
|
||||||
|
|
||||||
local function onTouchBegan(touch, event)
|
local function onTouchBegan(touch, event)
|
||||||
local target = tolua.cast(event:getCurrentTarget(),"cc.Sprite")
|
local target = event:getCurrentTarget()
|
||||||
|
|
||||||
local locationInNode = target:convertToNodeSpace(touch:getLocation())
|
local locationInNode = target:convertToNodeSpace(touch:getLocation())
|
||||||
local s = target:getContentSize()
|
local s = target:getContentSize()
|
||||||
|
@ -199,14 +199,14 @@ function TouchableSpriteTest:onEnter()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onTouchMoved(touch, event)
|
local function onTouchMoved(touch, event)
|
||||||
local target = tolua.cast(event:getCurrentTarget(), "cc.Sprite")
|
local target = event:getCurrentTarget()
|
||||||
local posX,posY = target:getPosition()
|
local posX,posY = target:getPosition()
|
||||||
local delta = touch:getDelta()
|
local delta = touch:getDelta()
|
||||||
target:setPosition(cc.p(posX + delta.x, posY + delta.y))
|
target:setPosition(cc.p(posX + delta.x, posY + delta.y))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onTouchEnded(touch, event)
|
local function onTouchEnded(touch, event)
|
||||||
local target = tolua.cast(event:getCurrentTarget(), "cc.Sprite")
|
local target = event:getCurrentTarget()
|
||||||
print("sprite onTouchesEnded..")
|
print("sprite onTouchesEnded..")
|
||||||
target:setOpacity(255)
|
target:setOpacity(255)
|
||||||
if target == sprite2 then
|
if target == sprite2 then
|
||||||
|
|
|
@ -261,10 +261,10 @@ local function Test6()
|
||||||
local rot = cc.RotateBy:create(2, 360)
|
local rot = cc.RotateBy:create(2, 360)
|
||||||
local rot_back = rot:reverse()
|
local rot_back = rot:reverse()
|
||||||
local forever1 = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back))
|
local forever1 = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back))
|
||||||
local forever11 = tolua.cast(forever1:clone(), "cc.RepeatForever")
|
local forever11 = forever1:clone()
|
||||||
|
|
||||||
local forever2 = tolua.cast(forever1:clone(), "cc.RepeatForever")
|
local forever2 = forever1:clone()
|
||||||
local forever21 = tolua.cast(forever1:clone(), "cc.RepeatForever")
|
local forever21 = forever1:clone()
|
||||||
|
|
||||||
Test6_layer:addChild(sp1, 0, kTagSprite1)
|
Test6_layer:addChild(sp1, 0, kTagSprite1)
|
||||||
sp1:addChild(sp11)
|
sp1:addChild(sp11)
|
||||||
|
@ -342,7 +342,7 @@ local function shouldNotLeak(dt)
|
||||||
scheduler:unscheduleScriptEntry(StressTest2_entry)
|
scheduler:unscheduleScriptEntry(StressTest2_entry)
|
||||||
|
|
||||||
local sublayer = StressTest2_layer:getChildByTag(kTagSprite1)
|
local sublayer = StressTest2_layer:getChildByTag(kTagSprite1)
|
||||||
sublayer:removeAllChildrenWithCleanup(true)
|
sublayer:removeAllChildren(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function StressTest2_onEnterOrExit(tag)
|
local function StressTest2_onEnterOrExit(tag)
|
||||||
|
@ -370,10 +370,9 @@ local function StressTest2()
|
||||||
|
|
||||||
local fire = cc.ParticleFire:create()
|
local fire = cc.ParticleFire:create()
|
||||||
fire:setTexture(cc.Director:getInstance():getTextureCache():addImage("Images/fire.png"))
|
fire:setTexture(cc.Director:getInstance():getTextureCache():addImage("Images/fire.png"))
|
||||||
fire = tolua.cast(fire, "cc.Node")
|
|
||||||
fire:setPosition(80, s.height / 2 - 50)
|
fire:setPosition(80, s.height / 2 - 50)
|
||||||
|
|
||||||
local copy_seq3 = tolua.cast(seq3:clone(), "cc.Sequence")
|
local copy_seq3 = seq3:clone()
|
||||||
fire:runAction(cc.RepeatForever:create(copy_seq3))
|
fire:runAction(cc.RepeatForever:create(copy_seq3))
|
||||||
sublayer:addChild(fire, 2)
|
sublayer:addChild(fire, 2)
|
||||||
|
|
||||||
|
@ -564,7 +563,7 @@ local function ConvertToNode()
|
||||||
|
|
||||||
point:setPosition(sprite:getPosition())
|
point:setPosition(sprite:getPosition())
|
||||||
|
|
||||||
local copy = tolua.cast(action:clone(), "cc.RepeatForever")
|
local copy = action:clone()
|
||||||
sprite:runAction(copy)
|
sprite:runAction(copy)
|
||||||
ConvertToNode_layer:addChild(sprite, i)
|
ConvertToNode_layer:addChild(sprite, i)
|
||||||
end
|
end
|
||||||
|
|
|
@ -147,7 +147,7 @@ local function OpenGLTestMainLayer()
|
||||||
local i = 0
|
local i = 0
|
||||||
local len = table.getn(children)
|
local len = table.getn(children)
|
||||||
for i= 0 ,len - 1 do
|
for i= 0 ,len - 1 do
|
||||||
local child = tolua.cast(children[i + 1], "cc.Sprite")
|
local child = children[i + 1]
|
||||||
local oldPosX,oldPosY = child:getPosition()
|
local oldPosX,oldPosY = child:getPosition()
|
||||||
child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20)
|
child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20)
|
||||||
local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707)
|
local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707)
|
||||||
|
@ -558,7 +558,7 @@ local function OpenGLTestMainLayer()
|
||||||
|
|
||||||
local function getCurrentResult()
|
local function getCurrentResult()
|
||||||
local var = {}
|
local var = {}
|
||||||
local glProgam = tolua.cast(sprite:getShaderProgram(),"cc.GLProgram")
|
local glProgam = sprite:getShaderProgram()
|
||||||
if nil ~= glProgam then
|
if nil ~= glProgam then
|
||||||
local p = glProgam:getProgram()
|
local p = glProgam:getProgram()
|
||||||
local aaSize,aaType,aaName = gl.getActiveAttrib(p,0)
|
local aaSize,aaType,aaName = gl.getActiveAttrib(p,0)
|
||||||
|
|
|
@ -148,7 +148,7 @@ local function runNodeChildrenTest()
|
||||||
local function updateQuantityLabel()
|
local function updateQuantityLabel()
|
||||||
if nQuantityOfNodes ~= nLastRenderedCount then
|
if nQuantityOfNodes ~= nLastRenderedCount then
|
||||||
-- local pInfoLabel = pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer)
|
-- local pInfoLabel = pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer)
|
||||||
local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "cc.LabelTTF")
|
local pInfoLabel = pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer)
|
||||||
local strNode = nQuantityOfNodes.." nodes"
|
local strNode = nQuantityOfNodes.." nodes"
|
||||||
pInfoLabel:setString(strNode)
|
pInfoLabel:setString(strNode)
|
||||||
nLastRenderedCount = nQuantityOfNodes
|
nLastRenderedCount = nQuantityOfNodes
|
||||||
|
@ -167,7 +167,7 @@ local function runNodeChildrenTest()
|
||||||
local i = 0
|
local i = 0
|
||||||
local len = table.getn(pChildren)
|
local len = table.getn(pChildren)
|
||||||
for i = 0, len - 1, 1 do
|
for i = 0, len - 1, 1 do
|
||||||
local child = tolua.cast(pChildren[i + 1], "cc.Sprite")
|
local child = pChildren[i + 1]
|
||||||
child:setVisible(false)
|
child:setVisible(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -190,7 +190,7 @@ local function runNodeChildrenTest()
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 0 , nTotalToAdd - 1 do
|
for i = 0 , nTotalToAdd - 1 do
|
||||||
local pChild = tolua.cast(pSprites[i + 1],"cc.Node")
|
local pChild = pSprites[i + 1]
|
||||||
pBatchNode:addChild(pChild, zs[i], NodeChildrenTestParam.kTagBase + i)
|
pBatchNode:addChild(pChild, zs[i], NodeChildrenTestParam.kTagBase + i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ local function runNodeChildrenTest()
|
||||||
end
|
end
|
||||||
-- add them with random Z (very important!)
|
-- add them with random Z (very important!)
|
||||||
for i=0, nTotalToAdd - 1 do
|
for i=0, nTotalToAdd - 1 do
|
||||||
local pChild = tolua.cast(pSprites[i + 1],"cc.Node")
|
local pChild = pSprites[i + 1]
|
||||||
pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i)
|
pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ local function runNodeChildrenTest()
|
||||||
|
|
||||||
--dd them with random Z (very important!)
|
--dd them with random Z (very important!)
|
||||||
for i = 0, nTotalToAdd - 1 do
|
for i = 0, nTotalToAdd - 1 do
|
||||||
local pChild = tolua.cast(pSprites[i + 1] ,"cc.Node")
|
local pChild = pSprites[i + 1]
|
||||||
pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i)
|
pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ local function runNodeChildrenTest()
|
||||||
|
|
||||||
-- reorder them
|
-- reorder them
|
||||||
for i = 0, nTotalToAdd - 1 do
|
for i = 0, nTotalToAdd - 1 do
|
||||||
local pNode = tolua.cast(pSprites[i + 1],"cc.Node")
|
local pNode = pSprites[i + 1]
|
||||||
pBatchNode:reorderChild(pNode, math.random(-1,1) * 50)
|
pBatchNode:reorderChild(pNode, math.random(-1,1) * 50)
|
||||||
end
|
end
|
||||||
pBatchNode:sortAllChildren()
|
pBatchNode:sortAllChildren()
|
||||||
|
@ -509,7 +509,7 @@ local function runParticleTest()
|
||||||
|
|
||||||
local function UpdateQuantityLabel()
|
local function UpdateQuantityLabel()
|
||||||
if nQuantityParticles ~= nLastRenderedCount then
|
if nQuantityParticles ~= nLastRenderedCount then
|
||||||
local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "cc.LabelTTF")
|
local pInfoLabel = pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer)
|
||||||
local strInfo = string.format("%u particles", nQuantityParticles)
|
local strInfo = string.format("%u particles", nQuantityParticles)
|
||||||
pInfoLabel:setString(strInfo)
|
pInfoLabel:setString(strInfo)
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ local function runParticleTest()
|
||||||
|
|
||||||
local function doTest()
|
local function doTest()
|
||||||
local s = cc.Director:getInstance():getWinSize()
|
local s = cc.Director:getInstance():getWinSize()
|
||||||
local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"cc.ParticleSystem")
|
local pParticleSystem = pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem)
|
||||||
if nil == pParticleSystem then
|
if nil == pParticleSystem then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -764,8 +764,8 @@ local function runParticleTest()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function step(t)
|
local function step(t)
|
||||||
local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"cc.LabelAtlas")
|
local pAtlas = pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas)
|
||||||
local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"cc.ParticleSystem")
|
local pEmitter = pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem)
|
||||||
local strInfo = string.format("%4d",pEmitter:getParticleCount())
|
local strInfo = string.format("%4d",pEmitter:getParticleCount())
|
||||||
pAtlas:setString(strInfo)
|
pAtlas:setString(strInfo)
|
||||||
end
|
end
|
||||||
|
@ -990,7 +990,7 @@ local function runSpriteTest()
|
||||||
|
|
||||||
local function UpdateNodes()
|
local function UpdateNodes()
|
||||||
if nQuantityNodes ~= nLastRenderedCount then
|
if nQuantityNodes ~= nLastRenderedCount then
|
||||||
local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "cc.LabelTTF")
|
local pInfoLabel = pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer)
|
||||||
local strInfo = string.format("%u nodes", nQuantityNodes)
|
local strInfo = string.format("%u nodes", nQuantityNodes)
|
||||||
pInfoLabel:setString(strInfo)
|
pInfoLabel:setString(strInfo)
|
||||||
nLastRenderedCount = nQuantityNodes
|
nLastRenderedCount = nQuantityNodes
|
||||||
|
@ -1701,14 +1701,14 @@ local function runFuncRelateWithTable()
|
||||||
if quantityOfNodes == 0 then
|
if quantityOfNodes == 0 then
|
||||||
quantityOfNodes = 100
|
quantityOfNodes = 100
|
||||||
end
|
end
|
||||||
local numLabel = tolua.cast(layer:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "cc.LabelTTF")
|
local numLabel = layer:getChildByTag(NodeChildrenTestParam.kTagInfoLayer)
|
||||||
local strNum = string.format("%d", quantityOfNodes)
|
local strNum = string.format("%d", quantityOfNodes)
|
||||||
numLabel:setString(strNum)
|
numLabel:setString(strNum)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onIncrease()
|
local function onIncrease()
|
||||||
quantityOfNodes = quantityOfNodes + 100
|
quantityOfNodes = quantityOfNodes + 100
|
||||||
local numLabel = tolua.cast(layer:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "cc.LabelTTF")
|
local numLabel = layer:getChildByTag(NodeChildrenTestParam.kTagInfoLayer)
|
||||||
local strNum = string.format("%d", quantityOfNodes)
|
local strNum = string.format("%d", quantityOfNodes)
|
||||||
numLabel:setString(strNum)
|
numLabel:setString(strNum)
|
||||||
end
|
end
|
||||||
|
|
|
@ -446,7 +446,7 @@ function SpriteAnchorPoint.initLayer(layer)
|
||||||
end
|
end
|
||||||
point:setPosition( sprite:getPosition() )
|
point:setPosition( sprite:getPosition() )
|
||||||
|
|
||||||
local copy = tolua.cast(action:clone(), "cc.Action")
|
local copy = action:clone()
|
||||||
sprite:runAction(copy)
|
sprite:runAction(copy)
|
||||||
layer:addChild(sprite, i)
|
layer:addChild(sprite, i)
|
||||||
end
|
end
|
||||||
|
@ -499,7 +499,7 @@ function SpriteBatchNodeAnchorPoint.initLayer(layer)
|
||||||
|
|
||||||
point:setPosition( cc.p(sprite:getPosition()) )
|
point:setPosition( cc.p(sprite:getPosition()) )
|
||||||
|
|
||||||
local copy = tolua.cast(action:clone(), "cc.Action")
|
local copy = action:clone()
|
||||||
sprite:runAction(copy)
|
sprite:runAction(copy)
|
||||||
batch:addChild(sprite, i)
|
batch:addChild(sprite, i)
|
||||||
end
|
end
|
||||||
|
|
|
@ -110,7 +110,7 @@ local function TextureMipMap()
|
||||||
local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3)
|
local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3)
|
||||||
local sc_back = scale1:reverse()
|
local sc_back = scale1:reverse()
|
||||||
|
|
||||||
local scale2 = tolua.cast(scale1:clone(), "cc.EaseOut")
|
local scale2 = scale1:clone()
|
||||||
local sc_back2 = scale2:reverse()
|
local sc_back2 = scale2:reverse()
|
||||||
|
|
||||||
img0:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back)))
|
img0:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back)))
|
||||||
|
@ -148,7 +148,7 @@ local function TexturePVRMipMap()
|
||||||
local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3)
|
local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3)
|
||||||
local sc_back = scale1:reverse()
|
local sc_back = scale1:reverse()
|
||||||
|
|
||||||
local scale2 = tolua.cast(scale1:clone(), "cc.EaseOut")
|
local scale2 = scale1:clone()
|
||||||
local sc_back2 = scale2:reverse()
|
local sc_back2 = scale2:reverse()
|
||||||
|
|
||||||
imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back)))
|
imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back)))
|
||||||
|
@ -182,7 +182,7 @@ local function TexturePVRMipMap2()
|
||||||
local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3)
|
local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3)
|
||||||
local sc_back = scale1:reverse()
|
local sc_back = scale1:reverse()
|
||||||
|
|
||||||
local scale2 = tolua.cast(scale1:clone(), "cc.EaseOut")
|
local scale2 = scale1:clone()
|
||||||
local sc_back2 = scale2:reverse()
|
local sc_back2 = scale2:reverse()
|
||||||
|
|
||||||
imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back)))
|
imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back)))
|
||||||
|
@ -803,9 +803,9 @@ local function TextureAlias()
|
||||||
|
|
||||||
-- scale them to show
|
-- scale them to show
|
||||||
local sc = cc.ScaleBy:create(3, 8.0)
|
local sc = cc.ScaleBy:create(3, 8.0)
|
||||||
local sc_back = tolua.cast(sc:reverse(), "cc.ScaleBy")
|
local sc_back = sc:reverse()
|
||||||
local scaleforever = cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))
|
local scaleforever = cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))
|
||||||
local scaleToo = tolua.cast(scaleforever:clone(), "cc.RepeatForever")
|
local scaleToo = scaleforever:clone()
|
||||||
|
|
||||||
sprite2:runAction(scaleforever)
|
sprite2:runAction(scaleforever)
|
||||||
sprite:runAction(scaleToo)
|
sprite:runAction(scaleToo)
|
||||||
|
@ -829,7 +829,7 @@ local function TexturePixelFormat()
|
||||||
-- 3- 16-bit RGB5A1
|
-- 3- 16-bit RGB5A1
|
||||||
-- 4- 16-bit RGB565
|
-- 4- 16-bit RGB565
|
||||||
|
|
||||||
local label = tolua.cast(ret:getChildByTag(kTagLabel), "cc.LabelTTF")
|
local label = ret:getChildByTag(kTagLabel)
|
||||||
label:setColor(cc.c3b(16,16,255))
|
label:setColor(cc.c3b(16,16,255))
|
||||||
|
|
||||||
local s = cc.Director:getInstance():getWinSize()
|
local s = cc.Director:getInstance():getWinSize()
|
||||||
|
@ -895,10 +895,10 @@ local function TexturePixelFormat()
|
||||||
local fadein = cc.FadeIn:create(2)
|
local fadein = cc.FadeIn:create(2)
|
||||||
local seq = cc.Sequence:create(cc.DelayTime:create(2), fadeout, fadein)
|
local seq = cc.Sequence:create(cc.DelayTime:create(2), fadeout, fadein)
|
||||||
local seq_4ever = cc.RepeatForever:create(seq)
|
local seq_4ever = cc.RepeatForever:create(seq)
|
||||||
local seq_4ever2 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever")
|
local seq_4ever2 = seq_4ever:clone()
|
||||||
local seq_4ever3 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever")
|
local seq_4ever3 = seq_4ever:clone()
|
||||||
local seq_4ever4 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever")
|
local seq_4ever4 = seq_4ever:clone()
|
||||||
local seq_4ever5 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever")
|
local seq_4ever5 = seq_4ever:clone()
|
||||||
|
|
||||||
sprite1:runAction(seq_4ever)
|
sprite1:runAction(seq_4ever)
|
||||||
sprite2:runAction(seq_4ever2)
|
sprite2:runAction(seq_4ever2)
|
||||||
|
@ -964,12 +964,12 @@ local function TextureAsync()
|
||||||
ret:addChild(label, 10)
|
ret:addChild(label, 10)
|
||||||
|
|
||||||
local scale = cc.ScaleBy:create(0.3, 2)
|
local scale = cc.ScaleBy:create(0.3, 2)
|
||||||
local scale_back = tolua.cast(scale:reverse(), "cc.ScaleBy")
|
local scale_back = scale:reverse()
|
||||||
local seq = cc.Sequence:create(scale, scale_back)
|
local seq = cc.Sequence:create(scale, scale_back)
|
||||||
label:runAction(cc.RepeatForever:create(seq))
|
label:runAction(cc.RepeatForever:create(seq))
|
||||||
|
|
||||||
local function imageLoaded(pObj)
|
local function imageLoaded(pObj)
|
||||||
local tex = tolua.cast(pObj, "cc.Texture2D")
|
local tex = pObj
|
||||||
local director = cc.Director:getInstance()
|
local director = cc.Director:getInstance()
|
||||||
|
|
||||||
--cc.ASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread")
|
--cc.ASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread")
|
||||||
|
@ -1043,7 +1043,7 @@ local function TextureGlClamp()
|
||||||
local rotate = cc.RotateBy:create(4, 360)
|
local rotate = cc.RotateBy:create(4, 360)
|
||||||
sprite:runAction(rotate)
|
sprite:runAction(rotate)
|
||||||
local scale = cc.ScaleBy:create(2, 0.04)
|
local scale = cc.ScaleBy:create(2, 0.04)
|
||||||
local scaleBack = tolua.cast(scale:reverse(), "cc.ScaleBy")
|
local scaleBack = scale:reverse()
|
||||||
local seq = cc.Sequence:create(scale, scaleBack)
|
local seq = cc.Sequence:create(scale, scaleBack)
|
||||||
sprite:runAction(seq)
|
sprite:runAction(seq)
|
||||||
local function onNodeEvent(event)
|
local function onNodeEvent(event)
|
||||||
|
@ -1077,7 +1077,7 @@ local function TextureGlRepeat()
|
||||||
local rotate = cc.RotateBy:create(4, 360)
|
local rotate = cc.RotateBy:create(4, 360)
|
||||||
sprite:runAction(rotate)
|
sprite:runAction(rotate)
|
||||||
local scale = cc.ScaleBy:create(2, 0.04)
|
local scale = cc.ScaleBy:create(2, 0.04)
|
||||||
local scaleBack = tolua.cast(scale:reverse(), "cc.ScaleBy")
|
local scaleBack = scale:reverse()
|
||||||
local seq = cc.Sequence:create(scale, scaleBack)
|
local seq = cc.Sequence:create(scale, scaleBack)
|
||||||
sprite:runAction(seq)
|
sprite:runAction(seq)
|
||||||
local function onNodeEvent(event)
|
local function onNodeEvent(event)
|
||||||
|
@ -1338,7 +1338,7 @@ local function TexturePVRv3Premult()
|
||||||
local function transformSprite(sprite)
|
local function transformSprite(sprite)
|
||||||
local fade = cc.FadeOut:create(2)
|
local fade = cc.FadeOut:create(2)
|
||||||
local dl = cc.DelayTime:create(2)
|
local dl = cc.DelayTime:create(2)
|
||||||
local fadein = tolua.cast(fade:reverse(), "cc.FadeOut")
|
local fadein = fade:reverse()
|
||||||
local seq = cc.Sequence:create(fade, fadein, dl)
|
local seq = cc.Sequence:create(fade, fadein, dl)
|
||||||
local repeatAction = cc.RepeatForever:create(seq)
|
local repeatAction = cc.RepeatForever:create(seq)
|
||||||
sprite:runAction(repeatAction)
|
sprite:runAction(repeatAction)
|
||||||
|
|
|
@ -82,7 +82,7 @@ local function TileMapEditTest()
|
||||||
-- The only limitation is that you cannot change an empty, or assign an empty tile to a tile
|
-- The only limitation is that you cannot change an empty, or assign an empty tile to a tile
|
||||||
-- The value 0 not rendered so don't assign or change a tile with value 0
|
-- The value 0 not rendered so don't assign or change a tile with value 0
|
||||||
|
|
||||||
local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "cc.TileMapAtlas")
|
local tilemap = layer:getChildByTag(kTagTileMap)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- For example you can iterate over all the tiles
|
-- For example you can iterate over all the tiles
|
||||||
|
@ -157,7 +157,7 @@ local function TMXOrthoTest()
|
||||||
local len = table.getn(pChildrenArray)
|
local len = table.getn(pChildrenArray)
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
pObject = pChildrenArray[i + 1]
|
pObject = pChildrenArray[i + 1]
|
||||||
child = tolua.cast(pObject, "cc.SpriteBatchNode")
|
child = pObject
|
||||||
|
|
||||||
if child == nil then
|
if child == nil then
|
||||||
break
|
break
|
||||||
|
@ -211,7 +211,7 @@ local function TMXOrthoTest2()
|
||||||
local len = table.getn(pChildrenArray)
|
local len = table.getn(pChildrenArray)
|
||||||
|
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
child = tolua.cast(pChildrenArray[i + 1], "cc.SpriteBatchNode")
|
child = pChildrenArray[i + 1]
|
||||||
|
|
||||||
if child == nil then
|
if child == nil then
|
||||||
break
|
break
|
||||||
|
@ -243,7 +243,7 @@ local function TMXOrthoTest3()
|
||||||
local len = table.getn(pChildrenArray)
|
local len = table.getn(pChildrenArray)
|
||||||
|
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
child = tolua.cast(pChildrenArray[i + 1], "cc.SpriteBatchNode")
|
child = pChildrenArray[i + 1]
|
||||||
|
|
||||||
if child == nil then
|
if child == nil then
|
||||||
break
|
break
|
||||||
|
@ -277,7 +277,7 @@ local function TMXOrthoTest4()
|
||||||
local len = table.getn(pChildrenArray)
|
local len = table.getn(pChildrenArray)
|
||||||
|
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
child = tolua.cast(pChildrenArray[i + 1], "cc.SpriteBatchNode")
|
child = pChildrenArray[i + 1]
|
||||||
|
|
||||||
if child == nil then
|
if child == nil then
|
||||||
break
|
break
|
||||||
|
@ -304,7 +304,7 @@ local function TMXOrthoTest4()
|
||||||
local function removeSprite(dt)
|
local function removeSprite(dt)
|
||||||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||||
schedulerEntry = nil
|
schedulerEntry = nil
|
||||||
local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap")
|
local map = ret:getChildByTag(kTagTileMap)
|
||||||
local layer0 = map:getLayer("Layer 0")
|
local layer0 = map:getLayer("Layer 0")
|
||||||
local s = layer0:getLayerSize()
|
local s = layer0:getLayerSize()
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ local function TMXReadWriteTest()
|
||||||
|
|
||||||
local function removeSprite(sender)
|
local function removeSprite(sender)
|
||||||
--------cclog("removing tile: %x", sender)
|
--------cclog("removing tile: %x", sender)
|
||||||
local node = tolua.cast(sender, "cc.Node")
|
local node = sender
|
||||||
if nil == node then
|
if nil == node then
|
||||||
print("Errro node is nil")
|
print("Errro node is nil")
|
||||||
end
|
end
|
||||||
|
@ -382,9 +382,9 @@ local function TMXReadWriteTest()
|
||||||
|
|
||||||
local finish = cc.CallFunc:create(removeSprite)
|
local finish = cc.CallFunc:create(removeSprite)
|
||||||
local seq0 = cc.Sequence:create(move, rotate, scale, opacity, fadein, scaleback, finish)
|
local seq0 = cc.Sequence:create(move, rotate, scale, opacity, fadein, scaleback, finish)
|
||||||
local seq1 = tolua.cast(seq0:clone(), "cc.Action")
|
local seq1 = seq0:clone()
|
||||||
local seq2 = tolua.cast(seq0:clone(), "cc.Action")
|
local seq2 = seq0:clone()
|
||||||
local seq3 = tolua.cast(seq0:clone(), "cc.Action")
|
local seq3 = seq0:clone()
|
||||||
|
|
||||||
tile0:runAction(seq0)
|
tile0:runAction(seq0)
|
||||||
tile1:runAction(seq1)
|
tile1:runAction(seq1)
|
||||||
|
@ -400,8 +400,8 @@ local function TMXReadWriteTest()
|
||||||
|
|
||||||
local function updateCol(dt)
|
local function updateCol(dt)
|
||||||
|
|
||||||
local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap")
|
local map = ret:getChildByTag(kTagTileMap)
|
||||||
local layer = tolua.cast(map:getChildByTag(0), "cc.TMXLayer")
|
local layer = map:getChildByTag(0)
|
||||||
|
|
||||||
--------cclog("++++atlas quantity: %d", layer:textureAtlas():getTotalQuads())
|
--------cclog("++++atlas quantity: %d", layer:textureAtlas():getTotalQuads())
|
||||||
--------cclog("++++children: %d", layer:getChildren():count() )
|
--------cclog("++++children: %d", layer:getChildren():count() )
|
||||||
|
@ -418,8 +418,8 @@ local function TMXReadWriteTest()
|
||||||
|
|
||||||
local function repaintWithGID(dt)
|
local function repaintWithGID(dt)
|
||||||
-- unschedule:_cmd)
|
-- unschedule:_cmd)
|
||||||
local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap")
|
local map = ret:getChildByTag(kTagTileMap)
|
||||||
local layer = tolua.cast(map:getChildByTag(0), "cc.TMXLayer")
|
local layer = map:getChildByTag(0)
|
||||||
|
|
||||||
local s = layer:getLayerSize()
|
local s = layer:getLayerSize()
|
||||||
local x = 0
|
local x = 0
|
||||||
|
@ -433,8 +433,8 @@ local function TMXReadWriteTest()
|
||||||
local function removeTiles(dt)
|
local function removeTiles(dt)
|
||||||
scheduler:unscheduleScriptEntry(removeTilesScheduler)
|
scheduler:unscheduleScriptEntry(removeTilesScheduler)
|
||||||
removeTilesScheduler = nil
|
removeTilesScheduler = nil
|
||||||
local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap")
|
local map = ret:getChildByTag(kTagTileMap)
|
||||||
local layer = tolua.cast(map:getChildByTag(0), "cc.TMXLayer")
|
local layer = map:getChildByTag(0)
|
||||||
local s = layer:getLayerSize()
|
local s = layer:getLayerSize()
|
||||||
local y = 0
|
local y = 0
|
||||||
for y=0, s.height-1, 1 do
|
for y=0, s.height-1, 1 do
|
||||||
|
@ -580,7 +580,7 @@ local function TMXUncompressedTest()
|
||||||
local i = 0
|
local i = 0
|
||||||
local len = table.getn(pChildrenArray)
|
local len = table.getn(pChildrenArray)
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
layer = tolua.cast(pChildrenArray[i + 1], "cc.TMXLayer")
|
layer = pChildrenArray[i + 1]
|
||||||
if layer == nil then
|
if layer == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -648,43 +648,6 @@ local function TMXOrthoObjectsTest()
|
||||||
--------cclog("platform: %x", platform)
|
--------cclog("platform: %x", platform)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw()
|
|
||||||
|
|
||||||
local map = tolua.cast(getChildByTag(kTagTileMap), "cc.TMXTiledMap")
|
|
||||||
local group = map:getObjectGroup("Object Group 1")
|
|
||||||
|
|
||||||
local objects = group:getObjects()
|
|
||||||
local dict = nil
|
|
||||||
local i = 0
|
|
||||||
local len = table.getn(objects)
|
|
||||||
for i = 0, len-1, 1 do
|
|
||||||
dict = objects[i + 1]
|
|
||||||
|
|
||||||
if dict == nil then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local key = "x"
|
|
||||||
local x = dict["x"]
|
|
||||||
key = "y"
|
|
||||||
local y = dict["y"]--dynamic_cast<NSNumber*>(dict:objectForKey("y")):getNumber()
|
|
||||||
key = "width"
|
|
||||||
local width = dict["width"]--dynamic_cast<NSNumber*>(dict:objectForKey("width")):getNumber()
|
|
||||||
key = "height"
|
|
||||||
local height = dict["height"]--dynamic_cast<NSNumber*>(dict:objectForKey("height")):getNumber()
|
|
||||||
|
|
||||||
glLineWidth(3)
|
|
||||||
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p(x, y), cc.p((x+width), y) )
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p((x+width), y), cc.p((x+width), (y+height)) )
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p((x+width), (y+height)), cc.p(x, (y+height)) )
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p(x, (y+height)), cc.p(x, y) )
|
|
||||||
|
|
||||||
glLineWidth(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
--
|
--
|
||||||
-- TMXIsoObjectsTest
|
-- TMXIsoObjectsTest
|
||||||
|
@ -704,56 +667,9 @@ local function TMXIsoObjectsTest()
|
||||||
--UxMutableArray* objects = group:objects()
|
--UxMutableArray* objects = group:objects()
|
||||||
local objects = group:getObjects()
|
local objects = group:getObjects()
|
||||||
--UxMutableDictionary<std:string>* dict
|
--UxMutableDictionary<std:string>* dict
|
||||||
local dict = nil
|
|
||||||
local i = 0
|
|
||||||
local len = table.getn(objects)
|
|
||||||
for i = 0, len-1, 1 do
|
|
||||||
dict = tolua.cast(objects[i + 1], "cc.Dictionary")
|
|
||||||
|
|
||||||
if dict == nil then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
--------cclog("object: %x", dict)
|
|
||||||
end
|
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw()
|
|
||||||
|
|
||||||
local map = tolua.cast(getChildByTag(kTagTileMap), "cc.TMXTiledMap")
|
|
||||||
local group = map:getObjectGroup("Object Group 1")
|
|
||||||
|
|
||||||
local objects = group:getObjects()
|
|
||||||
local dict = nil
|
|
||||||
local i = 0
|
|
||||||
local len = table.getn(objects)
|
|
||||||
for i = 0, len-1, 1 do
|
|
||||||
dict = tolua.cast(objects[i + 1], "cc.Dictionary")
|
|
||||||
|
|
||||||
if dict == nil then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local key = "x"
|
|
||||||
local x = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("x")):getNumber()
|
|
||||||
key = "y"
|
|
||||||
local y = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("y")):getNumber()
|
|
||||||
key = "width"
|
|
||||||
local width = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("width")):getNumber()
|
|
||||||
key = "height"
|
|
||||||
local height = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("height")):getNumber()
|
|
||||||
|
|
||||||
glLineWidth(3)
|
|
||||||
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p(x,y), cc.p(x+width,y) )
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p(x+width,y), cc.p(x+width,y+height) )
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p(x+width,y+height), cc.p(x,y+height) )
|
|
||||||
cc.DrawPrimitives.drawLine( cc.p(x,y+height), cc.p(x,y) )
|
|
||||||
|
|
||||||
glLineWidth(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
--
|
--
|
||||||
-- TMXResizeTest
|
-- TMXResizeTest
|
||||||
|
@ -1073,7 +989,7 @@ local function TMXOrthoFlipTest()
|
||||||
|
|
||||||
local i = 0
|
local i = 0
|
||||||
for i = 0, table.getn(map:getChildren())-1, 1 do
|
for i = 0, table.getn(map:getChildren())-1, 1 do
|
||||||
local child = tolua.cast(map:getChildren()[i + 1], "cc.SpriteBatchNode")
|
local child = map:getChildren()[i + 1]
|
||||||
child:getTexture():setAntiAliasTexParameters()
|
child:getTexture():setAntiAliasTexParameters()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1098,7 +1014,7 @@ local function TMXOrthoFlipRunTimeTest()
|
||||||
|
|
||||||
local i = 0
|
local i = 0
|
||||||
for i = 0, table.getn(map:getChildren())-1, 1 do
|
for i = 0, table.getn(map:getChildren())-1, 1 do
|
||||||
local child = tolua.cast(map:getChildren()[i + 1], "cc.SpriteBatchNode")
|
local child = map:getChildren()[i + 1]
|
||||||
child:getTexture():setAntiAliasTexParameters()
|
child:getTexture():setAntiAliasTexParameters()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1178,7 +1094,7 @@ local function TMXOrthoFromXMLTest()
|
||||||
local i = 0
|
local i = 0
|
||||||
local len = table.getn(map:getChildren())
|
local len = table.getn(map:getChildren())
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
local child = tolua.cast(map:getChildren()[i + 1], "cc.SpriteBatchNode")
|
local child = map:getChildren()[i + 1]
|
||||||
child:getTexture():setAntiAliasTexParameters()
|
child:getTexture():setAntiAliasTexParameters()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1206,7 +1122,7 @@ local function TMXBug987()
|
||||||
local len = table.getn(childs)
|
local len = table.getn(childs)
|
||||||
local pNode = nil
|
local pNode = nil
|
||||||
for i = 0, len-1, 1 do
|
for i = 0, len-1, 1 do
|
||||||
pNode = tolua.cast(childs[i + 1], "cc.TMXLayer")
|
pNode = childs[i + 1]
|
||||||
if pNode == nil then
|
if pNode == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue