mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7287 from samuele3hu/v3_hot_fix
Add the Lua bindings for FastTMXTileMap and FastTMXLayer,then add related test cases
This commit is contained in:
commit
fd433898a6
|
@ -253,6 +253,8 @@ THE SOFTWARE.
|
|||
#include "2d/CCTMXTiledMap.h"
|
||||
#include "2d/CCTMXXMLParser.h"
|
||||
#include "2d/CCTileMapAtlas.h"
|
||||
#include "2d/CCFastTMXTiledMap.h"
|
||||
#include "2d/CCFastTMXLayer.h"
|
||||
|
||||
// component
|
||||
#include "2d/CCComponent.h"
|
||||
|
|
|
@ -6436,6 +6436,80 @@ static void extendApplication(lua_State* tolua_S)
|
|||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_FastTMXLayer_getTileGIDAt(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FastTMXLayer* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getTileGIDAt'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
cocos2d::Vec2 arg0;
|
||||
|
||||
ok &= luaval_to_vec2(tolua_S, 2, &arg0);
|
||||
if(!ok)
|
||||
return 0;
|
||||
int ret = cobj->getTileGIDAt(arg0);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||
return 1;
|
||||
}
|
||||
if (argc == 2)
|
||||
{
|
||||
cocos2d::Vec2 arg0;
|
||||
int arg1 = 0;
|
||||
|
||||
ok &= luaval_to_vec2(tolua_S, 2, &arg0);
|
||||
ok &= luaval_to_int32(tolua_S, 3, &arg1);
|
||||
|
||||
if(!ok)
|
||||
return 0;
|
||||
|
||||
unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileGIDAt",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getTileGIDAt'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void extendFastTMXLayer(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "cc.FastTMXLayer");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
tolua_function(tolua_S, "getTileGIDAt", lua_cocos2dx_FastTMXLayer_getTileGIDAt);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
int register_all_cocos2dx_manual(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
|
@ -6489,6 +6563,7 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|||
extendTMXLayer(tolua_S);
|
||||
extendEventListenerFocus(tolua_S);
|
||||
extendApplication(tolua_S);
|
||||
extendFastTMXLayer(tolua_S);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -55,6 +55,7 @@ require "src/XMLHttpRequestTest/XMLHttpRequestTest"
|
|||
require "src/PhysicsTest/PhysicsTest"
|
||||
require "src/CaptureScreenTest/CaptureScreenTest"
|
||||
require "src/VideoPlayerTest/VideoPlayerTest"
|
||||
require "src/FastTiledMapTest/FastTiledMapTest"
|
||||
|
||||
|
||||
local LINE_SPACE = 40
|
||||
|
@ -85,6 +86,7 @@ local _allTests = {
|
|||
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
|
||||
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
|
||||
{ isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
|
||||
{ isSupported = true, name = "FastTiledMapTest" , create_func = FastTiledMapTestMain},
|
||||
{ isSupported = true, name = "FontTest" , create_func = FontTestMain },
|
||||
{ isSupported = true, name = "IntervalTest" , create_func = IntervalTestMain },
|
||||
{ isSupported = true, name = "KeypadTest" , create_func= KeypadTestMain },
|
||||
|
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAu
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewProtocol GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console Mesh GLProgramCache GLProgramState
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewProtocol GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console Mesh GLProgramCache GLProgramState
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
@ -131,7 +131,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
Animation3D::[getBoneCurveByName],
|
||||
Animation3DCache::[*],
|
||||
Sprite3DMaterialCache::[*],
|
||||
Bone3D::[*]
|
||||
Bone3D::[*],
|
||||
FastTMXLayer::[(g|s)etTiles getTileGIDAt]
|
||||
|
||||
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
||||
ProgressTimer::[setReverseProgress=setReverseDirection],
|
||||
|
|
Loading…
Reference in New Issue