diff --git a/AUTHORS b/AUTHORS index d30a8d123c..76014afe46 100644 --- a/AUTHORS +++ b/AUTHORS @@ -812,6 +812,7 @@ Developers: Added getAllTouches() in GLViewProtocol Precompiled headers improvements Added Application::openUrl for all supported platforms ecept WP8 and WinRT + Scale9Sprite capInsets set fix youknowone Adds iOS-like elastic bounceback support for cocos2d::extension::ScrollView diff --git a/CHANGELOG b/CHANGELOG index 6e41066be9..18dd133349 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,9 +16,12 @@ cocos2d-x-3.3-beta1 [FIX] Cocos Studio reader: UI animation playing crash if GUI JSON file is loaded again [FIX] Cocos Studio reader: improvement ImageViewReader don't necessary loadTexture when imageFilePath is empty [FIX] EditBox: view rendereed in wrong position if click EditBox on iOS 8 + [FIX] FileUtils: can not remove files/directory on iOS devices + [FIX] GLProgram: crashed on some Android devices that do not support more than 8 attributes [FIX] Label: getStringNumLines() may returns wrong result if label is dirty [FIX] Label: can not change opacity if using FNT font [FIX] Label: endless loop if not using system font, and constrained length is less than one character width + [FIX] LabelAtlas: opacity do not change when setting parent's opacity [FIX] Lua-bindings: may crash if passing two-dimensional table from lua to c++ [FIX] New audio: can not play audio after playing some times on Android [FIX] Node: macro scheduler_selector() superseded by CC_SCHEDULER_SELECTOR(). The same is true for the other schedule_ macros @@ -26,6 +29,8 @@ cocos2d-x-3.3-beta1 [FIX] Node: crashed if remove/add child too quickly when using integrated physics [FIX] TextFieldTTF: will get wrong characters if using Chinese input method on WP8 [FIX] UI: Button: button remains gray when releasing it, this issue only happened if enable scale9 and only has one texture + [FIX] UI: Button: when creating a button with a title only, button content size is not immediately updated + [FIX] UI: EditBox: setMaxLength is invalid on mac cocos2d-x-3.3-beta0 Sep.20 2014 [NEW] 3d: added `BillBoard` diff --git a/build/android-build.py b/build/android-build.py index cb1405b38e..967228bf7f 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -162,7 +162,7 @@ def copy_resources(target, app_android_root): copy_files(os.path.join(common_script_dir, "cocos2d"), assets_dir) copy_files(os.path.join(common_script_dir, "cocosbuilder"), assets_dir) copy_files(os.path.join(common_script_dir, "cocosdenshion"), assets_dir) - copy_files(os.path.join(common_script_dir, "cocostudio"), assets_dir) + copy_files(os.path.join(common_script_dir, "cocosstudio"), assets_dir) copy_files(os.path.join(common_script_dir, "extension"), assets_dir) copy_files(os.path.join(common_script_dir, "network"), assets_dir) copy_files(os.path.join(common_script_dir, "ui"), assets_dir) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 4164e3cd82..6939e46b9f 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1813,6 +1813,10 @@ B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; + DA8C62A219E52C6400000516 /* ioapi_mem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA8C62A019E52C6400000516 /* ioapi_mem.cpp */; }; + DA8C62A319E52C6400000516 /* ioapi_mem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA8C62A019E52C6400000516 /* ioapi_mem.cpp */; }; + DA8C62A419E52C6400000516 /* ioapi_mem.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8C62A119E52C6400000516 /* ioapi_mem.h */; }; + DA8C62A519E52C6400000516 /* ioapi_mem.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8C62A119E52C6400000516 /* ioapi_mem.h */; }; ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; @@ -2802,6 +2806,8 @@ B67C624319D4186F00F11FC6 /* ccShader_3D_ColorNormal.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_ColorNormal.frag; sourceTree = ""; }; B67C624419D4186F00F11FC6 /* ccShader_3D_ColorNormalTex.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_ColorNormalTex.frag; sourceTree = ""; }; B67C624519D4186F00F11FC6 /* ccShader_3D_PositionNormalTex.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_PositionNormalTex.vert; sourceTree = ""; }; + DA8C62A019E52C6400000516 /* ioapi_mem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ioapi_mem.cpp; sourceTree = ""; }; + DA8C62A119E52C6400000516 /* ioapi_mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi_mem.h; sourceTree = ""; }; ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -3350,6 +3356,8 @@ isa = PBXGroup; children = ( 1A570350180BD0B00088DEC7 /* ioapi.cpp */, + DA8C62A019E52C6400000516 /* ioapi_mem.cpp */, + DA8C62A119E52C6400000516 /* ioapi_mem.h */, 1A570351180BD0B00088DEC7 /* ioapi.h */, 1A570352180BD0B00088DEC7 /* unzip.cpp */, 1A570353180BD0B00088DEC7 /* unzip.h */, @@ -4936,6 +4944,7 @@ 50ABBED11925AB6F00A911A9 /* TGAlib.h in Headers */, 15AE19D319AAD3A700C27E9E /* Bone.h in Headers */, 1A57019F180BCB590088DEC7 /* CCFont.h in Headers */, + DA8C62A419E52C6400000516 /* ioapi_mem.h in Headers */, 1A5701A3180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 15AE18E919AAD35000C27E9E /* CCActionManagerEx.h in Headers */, 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */, @@ -5395,6 +5404,7 @@ 15AE1B9619AADA9A00C27E9E /* CocosGUI.h in Headers */, 1A57008C180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */, 1A570090180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */, + DA8C62A519E52C6400000516 /* ioapi_mem.h in Headers */, 1A570094180BC5A10088DEC7 /* CCActionTween.h in Headers */, 1A57009B180BC5C10088DEC7 /* CCAtlasNode.h in Headers */, 15AE184919AAD2F700C27E9E /* cocos3d.h in Headers */, @@ -5907,6 +5917,7 @@ 15AE18A219AAD33D00C27E9E /* CCParticleSystemQuadLoader.cpp in Sources */, 15AE188C19AAD33D00C27E9E /* CCLabelBMFontLoader.cpp in Sources */, 15AE19E619AAD3A700C27E9E /* Skin.cpp in Sources */, + DA8C62A219E52C6400000516 /* ioapi_mem.cpp in Sources */, 1A570069180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */, B257B44E1989D5E800D9A687 /* CCPrimitive.cpp in Sources */, 299CF1FB19A434BC00C378C1 /* ccRandom.cpp in Sources */, @@ -6426,6 +6437,7 @@ 3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */, 50ABC00E1926664800A911A9 /* CCFileUtils.cpp in Sources */, 299CF1FC19A434BC00C378C1 /* ccRandom.cpp in Sources */, + DA8C62A319E52C6400000516 /* ioapi_mem.cpp in Sources */, 15AE18C919AAD33D00C27E9E /* CCMenuItemLoader.cpp in Sources */, 50ABBE241925AB6F00A911A9 /* base64.cpp in Sources */, 1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 9c7f793e97..9d22a9f9ac 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -58,6 +58,8 @@ 1503FAC418DA8B6C00F6518C /* tp.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB118DA8B6C00F6518C /* tp.lua */; }; 1503FAC518DA8B6C00F6518C /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; }; 1503FAC618DA8B6C00F6518C /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; }; + 150F918819DA409E00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; }; + 150F918919DA409F00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; }; 15427B79198B879900DC375D /* libluacocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15EFA665198B33EE000C57D3 /* libluacocos2d iOS.a */; }; 15427B7A198B87AA00DC375D /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2d iOS.a */; }; 15427B7D198B880100DC375D /* lua_cocos2dx_controller_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15427B7B198B880100DC375D /* lua_cocos2dx_controller_manual.cpp */; }; @@ -197,14 +199,6 @@ 15D1FD3E199863CA00302043 /* DeprecatedCocosDenshionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD39199863CA00302043 /* DeprecatedCocosDenshionClass.lua */; }; 15D1FD3F199863CA00302043 /* DeprecatedCocosDenshionFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD3A199863CA00302043 /* DeprecatedCocosDenshionFunc.lua */; }; 15D1FD40199863CA00302043 /* DeprecatedCocosDenshionFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD3A199863CA00302043 /* DeprecatedCocosDenshionFunc.lua */; }; - 15D1FD45199863E800302043 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD41199863E800302043 /* CocoStudio.lua */; }; - 15D1FD46199863E800302043 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD41199863E800302043 /* CocoStudio.lua */; }; - 15D1FD47199863E800302043 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD42199863E800302043 /* DeprecatedCocoStudioClass.lua */; }; - 15D1FD48199863E800302043 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD42199863E800302043 /* DeprecatedCocoStudioClass.lua */; }; - 15D1FD49199863E800302043 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD43199863E800302043 /* DeprecatedCocoStudioFunc.lua */; }; - 15D1FD4A199863E800302043 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD43199863E800302043 /* DeprecatedCocoStudioFunc.lua */; }; - 15D1FD4B199863E800302043 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD44199863E800302043 /* StudioConstants.lua */; }; - 15D1FD4C199863E800302043 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD44199863E800302043 /* StudioConstants.lua */; }; 15D1FD51199863F900302043 /* DeprecatedExtensionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD4D199863F900302043 /* DeprecatedExtensionClass.lua */; }; 15D1FD52199863F900302043 /* DeprecatedExtensionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD4D199863F900302043 /* DeprecatedExtensionClass.lua */; }; 15D1FD53199863F900302043 /* DeprecatedExtensionEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD4E199863F900302043 /* DeprecatedExtensionEnum.lua */; }; @@ -237,6 +231,22 @@ 15D1FD761998642800302043 /* experimentalUIConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD6F1998642800302043 /* experimentalUIConstants.lua */; }; 15D1FD771998642800302043 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD701998642800302043 /* GuiConstants.lua */; }; 15D1FD781998642800302043 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FD701998642800302043 /* GuiConstants.lua */; }; + 15D7638219E8FC980069EAE8 /* CocosStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637E19E8FC980069EAE8 /* CocosStudio.lua */; }; + 15D7638319E8FC980069EAE8 /* CocosStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637E19E8FC980069EAE8 /* CocosStudio.lua */; }; + 15D7638419E8FC980069EAE8 /* CocosStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637E19E8FC980069EAE8 /* CocosStudio.lua */; }; + 15D7638519E8FC980069EAE8 /* CocosStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637E19E8FC980069EAE8 /* CocosStudio.lua */; }; + 15D7638619E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637F19E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua */; }; + 15D7638719E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637F19E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua */; }; + 15D7638819E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637F19E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua */; }; + 15D7638919E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7637F19E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua */; }; + 15D7638A19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638019E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua */; }; + 15D7638B19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638019E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua */; }; + 15D7638C19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638019E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua */; }; + 15D7638D19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638019E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua */; }; + 15D7638E19E8FC980069EAE8 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638119E8FC980069EAE8 /* StudioConstants.lua */; }; + 15D7638F19E8FC980069EAE8 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638119E8FC980069EAE8 /* StudioConstants.lua */; }; + 15D7639019E8FC980069EAE8 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638119E8FC980069EAE8 /* StudioConstants.lua */; }; + 15D7639119E8FC980069EAE8 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D7638119E8FC980069EAE8 /* StudioConstants.lua */; }; 15E66FC8192D957100C20A52 /* Sprite3DTest in Resources */ = {isa = PBXBuildFile; fileRef = 3E92EA841921A7720094CD21 /* Sprite3DTest */; }; 15E66FD6192DC8C700C20A52 /* Sprite3DTest in Resources */ = {isa = PBXBuildFile; fileRef = 3E92EA841921A7720094CD21 /* Sprite3DTest */; }; 15EE465B19A7200300AF29F1 /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15EE465A19A7200300AF29F1 /* libcurl.a */; }; @@ -1160,6 +1170,8 @@ 1503FAB018DA8B6C00F6518C /* socket.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = socket.lua; path = ../external/lua/luasocket/socket.lua; sourceTree = ""; }; 1503FAB118DA8B6C00F6518C /* tp.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tp.lua; path = ../external/lua/luasocket/tp.lua; sourceTree = ""; }; 1503FAB218DA8B6C00F6518C /* url.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = url.lua; path = ../external/lua/luasocket/url.lua; sourceTree = ""; }; + 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_test_bindings.cpp; sourceTree = ""; }; + 150F918719DA409E00B89F57 /* lua_test_bindings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_test_bindings.h; sourceTree = ""; }; 15427B76198B750300DC375D /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_module_register.h; sourceTree = ""; }; 15427B77198B843300DC375D /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_module_register.h; sourceTree = ""; }; 15427B7B198B880100DC375D /* lua_cocos2dx_controller_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lua_cocos2dx_controller_manual.cpp; path = "../../../../cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.cpp"; sourceTree = ""; }; @@ -2306,10 +2318,6 @@ 15D1FD38199863CA00302043 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = "../cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua"; sourceTree = ""; }; 15D1FD39199863CA00302043 /* DeprecatedCocosDenshionClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocosDenshionClass.lua; path = "../cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua"; sourceTree = ""; }; 15D1FD3A199863CA00302043 /* DeprecatedCocosDenshionFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocosDenshionFunc.lua; path = "../cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua"; sourceTree = ""; }; - 15D1FD41199863E800302043 /* CocoStudio.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocoStudio.lua; path = "../cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua"; sourceTree = ""; }; - 15D1FD42199863E800302043 /* DeprecatedCocoStudioClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocoStudioClass.lua; path = "../cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua"; sourceTree = ""; }; - 15D1FD43199863E800302043 /* DeprecatedCocoStudioFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocoStudioFunc.lua; path = "../cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua"; sourceTree = ""; }; - 15D1FD44199863E800302043 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = "../cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua"; sourceTree = ""; }; 15D1FD4D199863F900302043 /* DeprecatedExtensionClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedExtensionClass.lua; path = "../cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua"; sourceTree = ""; }; 15D1FD4E199863F900302043 /* DeprecatedExtensionEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedExtensionEnum.lua; path = "../cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua"; sourceTree = ""; }; 15D1FD4F199863F900302043 /* DeprecatedExtensionFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedExtensionFunc.lua; path = "../cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua"; sourceTree = ""; }; @@ -2322,6 +2330,10 @@ 15D1FD6E1998642800302043 /* DeprecatedUIFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedUIFunc.lua; path = "../cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua"; sourceTree = ""; }; 15D1FD6F1998642800302043 /* experimentalUIConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = experimentalUIConstants.lua; path = "../cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua"; sourceTree = ""; }; 15D1FD701998642800302043 /* GuiConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = GuiConstants.lua; path = "../cocos/scripting/lua-bindings/script/ui/GuiConstants.lua"; sourceTree = ""; }; + 15D7637E19E8FC980069EAE8 /* CocosStudio.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocosStudio.lua; path = "../cocos/scripting/lua-bindings/script/cocosstudio/CocosStudio.lua"; sourceTree = ""; }; + 15D7637F19E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocoStudioClass.lua; path = "../cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioClass.lua"; sourceTree = ""; }; + 15D7638019E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocoStudioFunc.lua; path = "../cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioFunc.lua"; sourceTree = ""; }; + 15D7638119E8FC980069EAE8 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = "../cocos/scripting/lua-bindings/script/cocosstudio/StudioConstants.lua"; sourceTree = ""; }; 15EE465A19A7200300AF29F1 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../external/curl/prebuilt/ios/libcurl.a; sourceTree = ""; }; 1A0EE2B218CDF6DA004CD58F /* cpp-empty-test Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cpp-empty-test Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A0EE31418CDF733004CD58F /* lua-empty-test Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "lua-empty-test Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -5308,6 +5320,10 @@ 1ABCA36418CD9E060087CE3A /* Lua Common */ = { isa = PBXGroup; children = ( + 15D7637E19E8FC980069EAE8 /* CocosStudio.lua */, + 15D7637F19E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua */, + 15D7638019E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua */, + 15D7638119E8FC980069EAE8 /* StudioConstants.lua */, 15D1FD6D1998642800302043 /* DeprecatedUIEnum.lua */, 15D1FD6E1998642800302043 /* DeprecatedUIFunc.lua */, 15D1FD6F1998642800302043 /* experimentalUIConstants.lua */, @@ -5320,10 +5336,6 @@ 15D1FD4E199863F900302043 /* DeprecatedExtensionEnum.lua */, 15D1FD4F199863F900302043 /* DeprecatedExtensionFunc.lua */, 15D1FD50199863F900302043 /* ExtensionConstants.lua */, - 15D1FD41199863E800302043 /* CocoStudio.lua */, - 15D1FD42199863E800302043 /* DeprecatedCocoStudioClass.lua */, - 15D1FD43199863E800302043 /* DeprecatedCocoStudioFunc.lua */, - 15D1FD44199863E800302043 /* StudioConstants.lua */, 15D1FD38199863CA00302043 /* AudioEngine.lua */, 15D1FD39199863CA00302043 /* DeprecatedCocosDenshionClass.lua */, 15D1FD3A199863CA00302043 /* DeprecatedCocosDenshionFunc.lua */, @@ -6614,6 +6626,8 @@ 1AC35D7C18CEE5B100F37B72 /* Classes */ = { isa = PBXGroup; children = ( + 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */, + 150F918719DA409E00B89F57 /* lua_test_bindings.h */, 15427B76198B750300DC375D /* lua_module_register.h */, 1AC35D7D18CEE5B100F37B72 /* AppDelegate.cpp */, 1AC35D7E18CEE5B100F37B72 /* AppDelegate.h */, @@ -7509,6 +7523,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15D7638719E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */, 1AC35D5C18CEDE9E00F37B72 /* InfoPlist.strings in Resources */, 1AC35D5D18CEDE9E00F37B72 /* MainMenu.xib in Resources */, 15D1FD621998641200302043 /* DeprecatedNetworkEnum.lua in Resources */, @@ -7519,12 +7534,15 @@ 15D1FCED1998637C00302043 /* bitExtend.lua in Resources */, 1503FABF18DA8B6C00F6518C /* smtp.lua in Resources */, 15D1FD291998637C00302043 /* Opengl.lua in Resources */, + 15D7638F19E8FC980069EAE8 /* StudioConstants.lua in Resources */, 1503FAB318DA8B6C00F6518C /* ftp.lua in Resources */, 1503FAB718DA8B6C00F6518C /* http.lua in Resources */, 15D1FCF71998637C00302043 /* Cocos2dConstants.lua in Resources */, 1503FAC118DA8B6C00F6518C /* socket.lua in Resources */, 1503FAB918DA8B6C00F6518C /* ltn12.lua in Resources */, 15D1FD0B1998637C00302043 /* DeprecatedOpenglEnum.lua in Resources */, + 15D7638B19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */, + 15D7638319E8FC980069EAE8 /* CocosStudio.lua in Resources */, 15D1FD661998641200302043 /* DeprecatedNetworkFunc.lua in Resources */, 15D1FD241998637C00302043 /* luaoc.lua in Resources */, 1AC35D5E18CEDE9E00F37B72 /* Icon.icns in Resources */, @@ -7577,7 +7595,9 @@ files = ( 15D1FD171998637C00302043 /* extern.lua in Resources */, 15D1FD641998641200302043 /* DeprecatedNetworkEnum.lua in Resources */, + 15D7638D19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */, 15D1FCF41998637C00302043 /* Cocos2d.lua in Resources */, + 15D7638519E8FC980069EAE8 /* CocosStudio.lua in Resources */, 1AC35D4A18CEDE9400F37B72 /* Icon-120.png in Resources */, 1503FAC018DA8B6C00F6518C /* smtp.lua in Resources */, 15D1FD681998641200302043 /* DeprecatedNetworkFunc.lua in Resources */, @@ -7593,6 +7613,7 @@ 1503FABE18DA8B6C00F6518C /* mime.lua in Resources */, 15D1FD601998641200302043 /* DeprecatedNetworkClass.lua in Resources */, 15D1FD2B1998637C00302043 /* Opengl.lua in Resources */, + 15D7639119E8FC980069EAE8 /* StudioConstants.lua in Resources */, 1AC35D4E18CEDE9400F37B72 /* Icon-72.png in Resources */, 1AC35D4F18CEDE9400F37B72 /* Icon-76.png in Resources */, 1503FAC218DA8B6C00F6518C /* socket.lua in Resources */, @@ -7602,6 +7623,7 @@ 15D1FD301998637C00302043 /* OpenglConstants.lua in Resources */, 1503FAB618DA8B6C00F6518C /* headers.lua in Resources */, 1AC35D4918CEDE9400F37B72 /* Icon-114.png in Resources */, + 15D7638919E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */, 1503FAB418DA8B6C00F6518C /* ftp.lua in Resources */, 15D1FCEF1998637C00302043 /* bitExtend.lua in Resources */, 1AC35D2A18CEDE7200F37B72 /* res in Resources */, @@ -7624,16 +7646,17 @@ files = ( 15D1FD751998642800302043 /* experimentalUIConstants.lua in Resources */, 156EAE071977D0BD00F53709 /* ActionTimeline in Resources */, + 15D7638219E8FC980069EAE8 /* CocosStudio.lua in Resources */, 15E66FD6192DC8C700C20A52 /* Sprite3DTest in Resources */, 15D1FD001998637C00302043 /* DeprecatedCocos2dEnum.lua in Resources */, 15D1FD2D1998637C00302043 /* OpenglConstants.lua in Resources */, 15D1FCF11998637C00302043 /* Cocos2d.lua in Resources */, - 15D1FD47199863E800302043 /* DeprecatedCocoStudioClass.lua in Resources */, 3E2F27BC19D00D7200E7C490 /* audio in Resources */, 1AC35DC318CEE65100F37B72 /* Misc in Resources */, 1AC35DC618CEE65100F37B72 /* Shaders in Resources */, 15D1FD141998637C00302043 /* extern.lua in Resources */, 1AC35DBB18CEE65100F37B72 /* components in Resources */, + 15D7638E19E8FC980069EAE8 /* StudioConstants.lua in Resources */, 1AC35DE218CEE65900F37B72 /* effect2.ogg in Resources */, 15C90B4318E66C1700D69802 /* mime.lua in Resources */, 15D1FD651998641200302043 /* DeprecatedNetworkFunc.lua in Resources */, @@ -7644,6 +7667,7 @@ 1AC35DBF18CEE65100F37B72 /* hd in Resources */, 1AC35DC818CEE65100F37B72 /* TileMaps in Resources */, 1AC35DBE18CEE65100F37B72 /* fonts in Resources */, + 15D7638619E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */, 15D1FD691998641200302043 /* NetworkConstants.lua in Resources */, 1AC35DDE18CEE65900F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */, 15D1FD34199863BA00302043 /* CCBReaderLoad.lua in Resources */, @@ -7658,6 +7682,7 @@ C08689C218D370C90093E810 /* background.caf in Resources */, 15D1FD0A1998637C00302043 /* DeprecatedOpenglEnum.lua in Resources */, 15C90B4918E66C2A00D69802 /* tp.lua in Resources */, + 15D7638A19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */, 15D1FD281998637C00302043 /* Opengl.lua in Resources */, 1AC35DE918CEE65900F37B72 /* effect1.wav in Resources */, 3E2F27BD19D00D7D00E7C490 /* background.wav in Resources */, @@ -7670,9 +7695,7 @@ 1AC35DC418CEE65100F37B72 /* Particles in Resources */, 15D1FD3F199863CA00302043 /* DeprecatedCocosDenshionFunc.lua in Resources */, 15D1FD191998637C00302043 /* json.lua in Resources */, - 15D1FD4B199863E800302043 /* StudioConstants.lua in Resources */, 1AC35DB918CEE65100F37B72 /* ccb in Resources */, - 15D1FD49199863E800302043 /* DeprecatedCocoStudioFunc.lua in Resources */, 15C90B4118E66C1100D69802 /* mbox.lua in Resources */, 15D1FD55199863F900302043 /* DeprecatedExtensionFunc.lua in Resources */, 15D1FD3B199863CA00302043 /* AudioEngine.lua in Resources */, @@ -7697,7 +7720,6 @@ 15D1FD51199863F900302043 /* DeprecatedExtensionClass.lua in Resources */, 1AC35DBD18CEE65100F37B72 /* extensions in Resources */, 15D1FD771998642800302043 /* GuiConstants.lua in Resources */, - 15D1FD45199863E800302043 /* CocoStudio.lua in Resources */, 15D1FD1E1998637C00302043 /* luaj.lua in Resources */, 1AC35DC718CEE65100F37B72 /* spine in Resources */, 15C90B4518E66C1E00D69802 /* smtp.lua in Resources */, @@ -7723,7 +7745,6 @@ 1AC35DF718CEE65B00F37B72 /* effect1.wav in Resources */, C08689C418D370C90093E810 /* background.caf in Resources */, 1AC35DD118CEE65200F37B72 /* fonts in Resources */, - 15D1FD4C199863E800302043 /* StudioConstants.lua in Resources */, 1AC35DCC18CEE65200F37B72 /* ccb in Resources */, 1AC35DD218CEE65200F37B72 /* hd in Resources */, 15D1FD251998637C00302043 /* luaoc.lua in Resources */, @@ -7740,7 +7761,6 @@ 15D1FD021998637C00302043 /* DeprecatedCocos2dEnum.lua in Resources */, 1AC35DF818CEE65B00F37B72 /* pew-pew-lei.wav in Resources */, 1AC35D9918CEE5D100F37B72 /* Default-568h@2x.png in Resources */, - 15D1FD4A199863E800302043 /* DeprecatedCocoStudioFunc.lua in Resources */, 15D1FD071998637C00302043 /* DeprecatedCocos2dFunc.lua in Resources */, 15C90B4218E66C1200D69802 /* mbox.lua in Resources */, 15D1FD201998637C00302043 /* luaj.lua in Resources */, @@ -7774,16 +7794,16 @@ 15D1FD2F1998637C00302043 /* OpenglConstants.lua in Resources */, 15D1FD671998641200302043 /* DeprecatedNetworkFunc.lua in Resources */, 1A1645A9191B6283008C7C7F /* ccs-res in Resources */, - 15D1FD46199863E800302043 /* CocoStudio.lua in Resources */, 15D1FD37199863BA00302043 /* DeprecatedCocosBuilderClass.lua in Resources */, 1AC35DA118CEE5D100F37B72 /* Icon-72.png in Resources */, + 15D7638819E8FC980069EAE8 /* DeprecatedCocoStudioClass.lua in Resources */, 15C90B4018E66C0D00D69802 /* ltn12.lua in Resources */, - 15D1FD48199863E800302043 /* DeprecatedCocoStudioClass.lua in Resources */, 15D1FD161998637C00302043 /* extern.lua in Resources */, 1AC35DA218CEE5D100F37B72 /* Icon-76.png in Resources */, 15C90B4818E66C2500D69802 /* socket.lua in Resources */, 15D1FD40199863CA00302043 /* DeprecatedCocosDenshionFunc.lua in Resources */, 15C90B3C18E66BEC00D69802 /* headers.lua in Resources */, + 15D7638419E8FC980069EAE8 /* CocosStudio.lua in Resources */, 1AC35DF418CEE65B00F37B72 /* effect1.raw in Resources */, 1AC35DD918CEE65200F37B72 /* Shaders in Resources */, 1AC35DCF18CEE65200F37B72 /* configs in Resources */, @@ -7797,7 +7817,9 @@ 1AC35D9C18CEE5D100F37B72 /* Icon-114.png in Resources */, 15D1FD52199863F900302043 /* DeprecatedExtensionClass.lua in Resources */, 1AC35D9F18CEE5D100F37B72 /* Icon-152.png in Resources */, + 15D7638C19E8FC980069EAE8 /* DeprecatedCocoStudioFunc.lua in Resources */, 1AC35DEE18CEE65B00F37B72 /* background.mp3 in Resources */, + 15D7639019E8FC980069EAE8 /* StudioConstants.lua in Resources */, 1AC35D9A18CEE5D100F37B72 /* Default.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -8006,6 +8028,7 @@ files = ( 1AC35D8118CEE5B100F37B72 /* AppDelegate.cpp in Sources */, 1AC35DB518CEE5DA00F37B72 /* LuaObjectCBridgeTest.mm in Sources */, + 150F918819DA409E00B89F57 /* lua_test_bindings.cpp in Sources */, 1AC35DB618CEE5DA00F37B72 /* main.cpp in Sources */, 1AC35D8318CEE5B100F37B72 /* lua_assetsmanager_test_sample.cpp in Sources */, ); @@ -8015,6 +8038,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 150F918919DA409F00B89F57 /* lua_test_bindings.cpp in Sources */, 1AC35DA518CEE5D100F37B72 /* main.m in Sources */, 1AC35DA418CEE5D100F37B72 /* LuaObjectCBridgeTest.mm in Sources */, 1AC35D9818CEE5D100F37B72 /* AppController.mm in Sources */, diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index e885655384..77d2aadb8a 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -216,7 +216,15 @@ void AtlasNode::setBlendFunc(const BlendFunc &blendFunc) void AtlasNode::updateBlendFunc() { if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() ) + { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; + setOpacityModifyRGB(false); + } + else + { + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; + setOpacityModifyRGB(true); + } } void AtlasNode::setTexture(Texture2D *texture) diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index aa0750e906..2134af1925 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -233,6 +233,12 @@ void LabelAtlas::updateColor() if (_textureAtlas) { Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); + if (_isOpacityModifyRGB) + { + color4.r *= _displayedOpacity/255.0f; + color4.g *= _displayedOpacity/255.0f; + color4.b *= _displayedOpacity/255.0f; + } auto quads = _textureAtlas->getQuads(); ssize_t length = _string.length(); for (int index = 0; index < length; index++) diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props index 06da521592..a6d48bbaa3 100644 --- a/cocos/2d/cocos2d_headers.props +++ b/cocos/2d/cocos2d_headers.props @@ -7,7 +7,7 @@ - $(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES + $(EngineRoot)cocos\editor-support;$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES _VARIADIC_MAX=10;%(PreprocessorDefinitions) diff --git a/cocos/2d/cocos2d_winrt.vcxproj b/cocos/2d/cocos2d_winrt.vcxproj index e8cc8dfe68..00d7f67216 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj +++ b/cocos/2d/cocos2d_winrt.vcxproj @@ -288,6 +288,7 @@ + @@ -506,6 +507,7 @@ + diff --git a/cocos/2d/cocos2d_winrt.vcxproj.filters b/cocos/2d/cocos2d_winrt.vcxproj.filters index a395535147..f486f2c14a 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj.filters +++ b/cocos/2d/cocos2d_winrt.vcxproj.filters @@ -455,6 +455,9 @@ external\tinyxml2 + + external\unzip + external\unzip @@ -1071,6 +1074,9 @@ external\tinyxml2 + + external\unzip + external\unzip diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index 1c4f3b5efb..9b3fa119eb 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -203,6 +203,7 @@ + @@ -444,6 +445,7 @@ + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 5ea9ffcabc..485ead9924 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -382,6 +382,9 @@ external\tinyxml2 + + external\unzip + external\unzip @@ -1012,6 +1015,9 @@ external\tinyxml2 + + external\unzip + external\unzip diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index d0453f314c..99d08acf4b 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -204,6 +204,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -544,6 +545,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 1e55d334ca..be5cfafea6 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -679,6 +679,9 @@ external\tinyxml2 + + external\unzip + external\unzip @@ -1729,6 +1732,9 @@ external\unzip + + external\unzip + external\edtaa diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index 70246384a9..427802b40d 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -2084,22 +2084,23 @@ unsigned int Bundle3D::parseGLProgramAttribute(const std::string& str) { return GLProgram::VERTEX_ATTRIB_TEX_COORD3; } - else if (str == "VERTEX_ATTRIB_TEX_COORD4") - { - return GLProgram::VERTEX_ATTRIB_TEX_COORD4; - } - else if (str == "VERTEX_ATTRIB_TEX_COORD5") - { - return GLProgram::VERTEX_ATTRIB_TEX_COORD5; - } - else if (str == "VERTEX_ATTRIB_TEX_COORD6") - { - return GLProgram::VERTEX_ATTRIB_TEX_COORD6; - } - else if (str == "VERTEX_ATTRIB_TEX_COORD7") - { - return GLProgram::VERTEX_ATTRIB_TEX_COORD7; - } + //comment out them +// else if (str == "VERTEX_ATTRIB_TEX_COORD4") +// { +// return GLProgram::VERTEX_ATTRIB_TEX_COORD4; +// } +// else if (str == "VERTEX_ATTRIB_TEX_COORD5") +// { +// return GLProgram::VERTEX_ATTRIB_TEX_COORD5; +// } +// else if (str == "VERTEX_ATTRIB_TEX_COORD6") +// { +// return GLProgram::VERTEX_ATTRIB_TEX_COORD6; +// } +// else if (str == "VERTEX_ATTRIB_TEX_COORD7") +// { +// return GLProgram::VERTEX_ATTRIB_TEX_COORD7; +// } else if (str == "VERTEX_ATTRIB_NORMAL") { return GLProgram::VERTEX_ATTRIB_NORMAL; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 562f37ea4b..8e750ddeeb 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -44,7 +44,7 @@ NS_CC_BEGIN -std::string s_attributeNames[] = {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::ATTRIBUTE_NAME_TEX_COORD2,GLProgram::ATTRIBUTE_NAME_TEX_COORD3,GLProgram::ATTRIBUTE_NAME_TEX_COORD4,GLProgram::ATTRIBUTE_NAME_TEX_COORD5,GLProgram::ATTRIBUTE_NAME_TEX_COORD6,GLProgram::ATTRIBUTE_NAME_TEX_COORD7,GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT, GLProgram::ATTRIBUTE_NAME_BLEND_INDEX}; +std::string s_attributeNames[] = {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::ATTRIBUTE_NAME_TEX_COORD2,GLProgram::ATTRIBUTE_NAME_TEX_COORD3,GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT, GLProgram::ATTRIBUTE_NAME_BLEND_INDEX}; Sprite3D* Sprite3D::create(const std::string &modelPath) { diff --git a/cocos/Android.mk b/cocos/Android.mk index ac8b308458..41351efb63 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -180,6 +180,7 @@ physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \ ../external/ConvertUTF/ConvertUTFWrapper.cpp \ ../external/ConvertUTF/ConvertUTF.c \ ../external/tinyxml2/tinyxml2.cpp \ +../external/unzip/ioapi_mem.cpp \ ../external/unzip/ioapi.cpp \ ../external/unzip/unzip.cpp \ ../external/edtaa3func/edtaa3func.cpp \ diff --git a/cocos/base/ZipUtils.cpp b/cocos/base/ZipUtils.cpp index c5f7e26011..eb2938dc22 100644 --- a/cocos/base/ZipUtils.cpp +++ b/cocos/base/ZipUtils.cpp @@ -22,17 +22,26 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ + +// FIXME: hack, must be included before ziputils +#include "unzip.h" +#include "base/ZipUtils.h" + #include #include #include -#include "base/ZipUtils.h" #include "base/CCData.h" #include "base/ccMacros.h" #include "platform/CCFileUtils.h" -#include "unzip.h" #include +// FIXME: Other platforms should use upstream minizip like mingw-w64 +#ifdef __MINGW32__ +#define unzGoToFirstFile64(A,B,C,D) unzGoToFirstFile2(A,B,C,D, NULL, 0, NULL, 0) +#define unzGoToNextFile64(A,B,C,D) unzGoToNextFile2(A,B,C,D, NULL, 0, NULL, 0) +#endif + NS_CC_BEGIN unsigned int ZipUtils::s_uEncryptedPvrKeyParts[4] = {0,0,0,0}; @@ -484,6 +493,8 @@ void ZipUtils::setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, // from unzip.cpp #define UNZ_MAXFILENAMEINZIP 256 +static const std::string emptyFilename(""); + struct ZipEntryInfo { unz_file_pos pos; @@ -500,6 +511,23 @@ public: FileListContainer fileList; }; +ZipFile *ZipFile::createWithBuffer(const void* buffer, uLong size) +{ + ZipFile *zip = new ZipFile(); + if (zip && zip->initWithBuffer(buffer, size)) { + return zip; + } else { + if (zip) delete zip; + return nullptr; + } +} + +ZipFile::ZipFile() +: _data(new ZipFilePrivate) +{ + _data->zipFile = nullptr; +} + ZipFile::ZipFile(const std::string &zipFile, const std::string &filter) : _data(new ZipFilePrivate) { @@ -612,4 +640,45 @@ unsigned char *ZipFile::getFileData(const std::string &fileName, ssize_t *size) return buffer; } +std::string ZipFile::getFirstFilename() +{ + if (unzGoToFirstFile(_data->zipFile) != UNZ_OK) return emptyFilename; + std::string path; + unz_file_info info; + getCurrentFileInfo(&path, &info); + return path; +} + +std::string ZipFile::getNextFilename() +{ + if (unzGoToNextFile(_data->zipFile) != UNZ_OK) return emptyFilename; + std::string path; + unz_file_info info; + getCurrentFileInfo(&path, &info); + return path; +} + +int ZipFile::getCurrentFileInfo(std::string *filename, unz_file_info *info) +{ + char path[FILENAME_MAX + 1]; + int ret = unzGetCurrentFileInfo(_data->zipFile, info, path, sizeof(path), nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + *filename = emptyFilename; + } else { + filename->assign(path); + } + return ret; +} + +bool ZipFile::initWithBuffer(const void *buffer, uLong size) +{ + if (!buffer || size == 0) return false; + + _data->zipFile = unzOpenBuffer(buffer, size); + if (!_data->zipFile) return false; + + setFilter(emptyFilename); + return true; +} + NS_CC_END diff --git a/cocos/base/ZipUtils.h b/cocos/base/ZipUtils.h index 0ab769383e..9b8a1f092e 100644 --- a/cocos/base/ZipUtils.h +++ b/cocos/base/ZipUtils.h @@ -37,6 +37,10 @@ THE SOFTWARE. #include "platform/CCStdC.h" #endif +#ifndef _unz64_H +typedef struct unz_file_info_s unz_file_info; +#endif + namespace cocos2d { /* XXX: pragma pack ??? */ @@ -214,6 +218,7 @@ namespace cocos2d // forward declaration class ZipFilePrivate; + struct unz_file_info_s; /** * Zip file - reader helper class. @@ -270,7 +275,18 @@ namespace cocos2d */ unsigned char *getFileData(const std::string &fileName, ssize_t *size); + std::string getFirstFilename(); + std::string getNextFilename(); + + static ZipFile *createWithBuffer(const void* buffer, unsigned long size); + private: + /* Only used internal for createWithBuffer() */ + ZipFile(); + + bool initWithBuffer(const void *buffer, unsigned long size); + int getCurrentFileInfo(std::string *filename, unz_file_info *info); + /** Internal data like zip file pointer / file list array and so on */ ZipFilePrivate *_data; }; diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index c61ba81f2a..c0de120d4f 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -341,6 +341,14 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par createObject(subDict, gb, attachComponent); } + const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize"); + if (DICTOOL->checkObjectExist_json(canvasSizeDict)) + { + int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width"); + int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height"); + gb->setContentSize(Size(width, height)); + } + return gb; } diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp index 450745f7d3..c1b8693259 100644 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp +++ b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp @@ -26,7 +26,6 @@ #if CC_USE_PHYSICS #include #include -#include "chipmunk.h" NS_CC_BEGIN diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h index 4167211051..ecde537a0a 100644 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h @@ -31,10 +31,7 @@ #include #include #include "platform/CCPlatformMacros.h" - -typedef uintptr_t cpGroup; -struct cpShape; -struct cpBody; +#include "chipmunk.h" NS_CC_BEGIN diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index ddc162c22c..49e0a9d9be 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -37,6 +37,10 @@ THE SOFTWARE. #include "unzip.h" #include +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) +#include +#endif + #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) #include #include @@ -644,7 +648,12 @@ unsigned char* FileUtils::getFileDataFromZip(const std::string& zipFilePath, con file = unzOpen(zipFilePath.c_str()); CC_BREAK_IF(!file); + // FIXME: Other platforms should use upstream minizip like mingw-w64 + #ifdef __MINGW32__ + int ret = unzLocateFile(file, filename.c_str(), NULL); + #else int ret = unzLocateFile(file, filename.c_str(), 1); + #endif CC_BREAK_IF(UNZ_OK != ret); char filePathA[260]; @@ -1103,6 +1112,18 @@ bool FileUtils::createDirectory(const std::string& path) #endif } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) +static int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) +{ + auto ret = remove(fpath); + if (ret) { + log("Fail to remove:%s ",fpath); + } + + return ret; +} +#endif + bool FileUtils::removeDirectory(const std::string& path) { if (path.size() > 0 && path[path.size() - 1] != '/') @@ -1155,6 +1176,11 @@ bool FileUtils::removeDirectory(const std::string& path) return true; else return false; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + if (nftw(path.c_str(),unlink_cb, 64, FTW_DEPTH | FTW_PHYS)) + return false; + else + return true; #else std::string command = "rm -r "; // Path may include space. @@ -1195,13 +1221,11 @@ bool FileUtils::removeFile(const std::string &path) else return false; #else - std::string command = "rm -f "; - // Path may include space. - command += "\"" + path + "\""; - if (system(command.c_str()) >= 0) - return true; - else + if (remove(path.c_str())) { return false; + } else { + return true; + } #endif } diff --git a/cocos/platform/win32/CCApplication-win32.cpp b/cocos/platform/win32/CCApplication-win32.cpp index ab3fb7f150..f42301bfa1 100644 --- a/cocos/platform/win32/CCApplication-win32.cpp +++ b/cocos/platform/win32/CCApplication-win32.cpp @@ -213,7 +213,7 @@ bool Application::openURL(const std::string &url) int wchars_num = MultiByteToWideChar(CP_UTF8, 0, url.c_str(), url.size() + 1, temp, url.size() + 1); HINSTANCE r = ShellExecuteW(NULL, L"open", temp, NULL, NULL, SW_SHOWNORMAL); delete[] temp; - return (int)r>32; + return (size_t)r>32; } void Application::setResourceRootPath(const std::string& rootResDir) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index e6a94386ef..840982f7c8 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -100,10 +100,6 @@ const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1"; const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2"; const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD3 = "a_texCoord3"; -const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD4 = "a_texCoord4"; -const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD5 = "a_texCoord5"; -const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD6 = "a_texCoord6"; -const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD7 = "a_texCoord7"; const char* GLProgram::ATTRIBUTE_NAME_NORMAL = "a_normal"; const char* GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"; const char* GLProgram::ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"; @@ -294,10 +290,6 @@ void GLProgram::bindPredefinedVertexAttribs() {GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::VERTEX_ATTRIB_TEX_COORD1}, {GLProgram::ATTRIBUTE_NAME_TEX_COORD2, GLProgram::VERTEX_ATTRIB_TEX_COORD2}, {GLProgram::ATTRIBUTE_NAME_TEX_COORD3, GLProgram::VERTEX_ATTRIB_TEX_COORD3}, - {GLProgram::ATTRIBUTE_NAME_TEX_COORD4, GLProgram::VERTEX_ATTRIB_TEX_COORD4}, - {GLProgram::ATTRIBUTE_NAME_TEX_COORD5, GLProgram::VERTEX_ATTRIB_TEX_COORD5}, - {GLProgram::ATTRIBUTE_NAME_TEX_COORD6, GLProgram::VERTEX_ATTRIB_TEX_COORD6}, - {GLProgram::ATTRIBUTE_NAME_TEX_COORD7, GLProgram::VERTEX_ATTRIB_TEX_COORD7}, {GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::VERTEX_ATTRIB_NORMAL}, }; diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index 830ca8b487..fa02252b97 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -87,14 +87,9 @@ public: VERTEX_ATTRIB_TEX_COORD1, VERTEX_ATTRIB_TEX_COORD2, VERTEX_ATTRIB_TEX_COORD3, - VERTEX_ATTRIB_TEX_COORD4, - VERTEX_ATTRIB_TEX_COORD5, - VERTEX_ATTRIB_TEX_COORD6, - VERTEX_ATTRIB_TEX_COORD7, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_BLEND_INDEX, - VERTEX_ATTRIB_MAX, // backward compatibility @@ -169,10 +164,6 @@ public: static const char* ATTRIBUTE_NAME_TEX_COORD1; static const char* ATTRIBUTE_NAME_TEX_COORD2; static const char* ATTRIBUTE_NAME_TEX_COORD3; - static const char* ATTRIBUTE_NAME_TEX_COORD4; - static const char* ATTRIBUTE_NAME_TEX_COORD5; - static const char* ATTRIBUTE_NAME_TEX_COORD6; - static const char* ATTRIBUTE_NAME_TEX_COORD7; static const char* ATTRIBUTE_NAME_NORMAL; static const char* ATTRIBUTE_NAME_BLEND_WEIGHT; static const char* ATTRIBUTE_NAME_BLEND_INDEX; diff --git a/cocos/renderer/ccShader_3D_PositionNormalTex.vert b/cocos/renderer/ccShader_3D_PositionNormalTex.vert index 8a77ef42f9..3bc58b91a1 100644 --- a/cocos/renderer/ccShader_3D_PositionNormalTex.vert +++ b/cocos/renderer/ccShader_3D_PositionNormalTex.vert @@ -1,9 +1,5 @@ const char* cc3D_PositionNormalTex_vert = STRINGIFY( -\n#define MAX_DIRECTIONAL_LIGHT_NUM 1 \n -\n#define MAX_POINT_LIGHT_NUM 1 \n -\n#define MAX_SPOT_LIGHT_NUM 1 \n -\n#define MAX_AMBIENT_LIGHT_NUM 1 \n \n#if (MAX_POINT_LIGHT_NUM > 0)\n uniform vec3 u_PointLightSourcePosition[MAX_POINT_LIGHT_NUM]; @@ -55,10 +51,6 @@ void main(void) ); const char* cc3D_SkinPositionNormalTex_vert = STRINGIFY( -\n#define MAX_DIRECTIONAL_LIGHT_NUM 1 \n -\n#define MAX_POINT_LIGHT_NUM 1 \n -\n#define MAX_SPOT_LIGHT_NUM 1 \n -\n#define MAX_AMBIENT_LIGHT_NUM 1 \n \n#if (MAX_POINT_LIGHT_NUM > 0)\n uniform vec3 u_PointLightSourcePosition[MAX_POINT_LIGHT_NUM]; diff --git a/cocos/scripting/lua-bindings/auto/api/AABB.lua b/cocos/scripting/lua-bindings/auto/api/AABB.lua deleted file mode 100644 index 584e00f36c..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/AABB.lua +++ /dev/null @@ -1,64 +0,0 @@ - --------------------------------- --- @module AABB --- @parent_module cc - --------------------------------- --- reset min and max value. --- @function [parent=#AABB] reset --- @param self - --------------------------------- --- Sets this bounding box to the specified values. --- @function [parent=#AABB] set --- @param self --- @param #vec3_table min --- @param #vec3_table max - --------------------------------- --- Transforms the bounding box by the given transformation matrix. --- @function [parent=#AABB] transform --- @param self --- @param #mat4_table mat - --------------------------------- --- Gets the center point of the bounding box. --- @function [parent=#AABB] getCenter --- @param self --- @return vec3_table#vec3_table ret (return value: vec3_table) - --------------------------------- --- --- @function [parent=#AABB] isEmpty --- @param self --- @return bool#bool ret (return value: bool) - --------------------------------- --- --- @function [parent=#AABB] getCorners --- @param self --- @param #vec3_table dst - --------------------------------- --- update the _min and _max from the given point. --- @function [parent=#AABB] updateMinMax --- @param self --- @param #vec3_table point --- @param #long num - --------------------------------- --- check whether the point is in. --- @function [parent=#AABB] containPoint --- @param self --- @param #vec3_table point --- @return bool#bool ret (return value: bool) - --------------------------------- --- @overload self, vec3_table, vec3_table --- @overload self --- @function [parent=#AABB] AABB --- @param self --- @param #vec3_table min --- @param #vec3_table max - -return nil diff --git a/cocos/scripting/lua-bindings/auto/api/OBB.lua b/cocos/scripting/lua-bindings/auto/api/OBB.lua deleted file mode 100644 index 3346b9f5d9..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/OBB.lua +++ /dev/null @@ -1,40 +0,0 @@ - --------------------------------- --- @module OBB --- @parent_module cc - --------------------------------- --- --- @function [parent=#OBB] reset --- @param self - --------------------------------- --- --- @function [parent=#OBB] set --- @param self --- @param #vec3_table center --- @param #vec3_table _xAxis --- @param #vec3_table _yAxis --- @param #vec3_table _zAxis --- @param #vec3_table _extents - --------------------------------- --- Transforms the obb by the given transformation matrix. --- @function [parent=#OBB] transform --- @param self --- @param #mat4_table mat - --------------------------------- --- --- @function [parent=#OBB] getCorners --- @param self --- @param #vec3_table verts - --------------------------------- --- --- @function [parent=#OBB] containPoint --- @param self --- @param #vec3_table point --- @return bool#bool ret (return value: bool) - -return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua index f4c658eda1..df2829323b 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua @@ -1,16 +1,6 @@ -------------------------------- -- @module cc --------------------------------------------------------- --- the cc AABB --- @field [parent=#cc] AABB#AABB AABB preloaded module - - --------------------------------------------------------- --- the cc OBB --- @field [parent=#cc] OBB#OBB OBB preloaded module - - -------------------------------------------------------- -- the cc Skeleton3D -- @field [parent=#cc] Skeleton3D#Skeleton3D Skeleton3D preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index bc2519ac6b..43db45a304 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -5,712 +5,6 @@ -int lua_cocos2dx_3d_AABB_reset(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_reset'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->reset(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:reset",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_reset'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_set(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_set'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::Vec3 arg0; - cocos2d::Vec3 arg1; - - ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.AABB:set"); - - ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.AABB:set"); - if(!ok) - return 0; - cobj->set(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:set",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_set'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_transform(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_transform'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Mat4 arg0; - - ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.AABB:transform"); - if(!ok) - return 0; - cobj->transform(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:transform",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_transform'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_getCenter(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_getCenter'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::Vec3 ret = cobj->getCenter(); - vec3_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:getCenter",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_getCenter'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_isEmpty(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_isEmpty'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->isEmpty(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:isEmpty",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_isEmpty'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_getCorners(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_getCorners'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec3* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Vec3",&arg0); - if(!ok) - return 0; - cobj->getCorners(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:getCorners",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_getCorners'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_updateMinMax(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_updateMinMax'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - const cocos2d::Vec3* arg0; - ssize_t arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.Vec3",&arg0); - - ok &= luaval_to_ssize(tolua_S, 3, &arg1, "cc.AABB:updateMinMax"); - if(!ok) - return 0; - cobj->updateMinMax(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:updateMinMax",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_updateMinMax'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_containPoint(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* 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.AABB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_containPoint'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec3 arg0; - - ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.AABB:containPoint"); - if(!ok) - return 0; - bool ret = cobj->containPoint(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:containPoint",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_containPoint'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_AABB_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::AABB* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 2) { - cocos2d::Vec3 arg0; - ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.AABB:AABB"); - - if (!ok) { break; } - cocos2d::Vec3 arg1; - ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.AABB:AABB"); - - if (!ok) { break; } - cobj = new cocos2d::AABB(arg0, arg1); - tolua_pushusertype(tolua_S,(void*)cobj,"cc.AABB"); - tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 0) { - cobj = new cocos2d::AABB(); - tolua_pushusertype(tolua_S,(void*)cobj,"cc.AABB"); - tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:AABB",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_3d_AABB_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (AABB)"); - return 0; -} - -int lua_register_cocos2dx_3d_AABB(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.AABB"); - tolua_cclass(tolua_S,"AABB","cc.AABB","",nullptr); - - tolua_beginmodule(tolua_S,"AABB"); - tolua_function(tolua_S,"new",lua_cocos2dx_3d_AABB_constructor); - tolua_function(tolua_S,"reset",lua_cocos2dx_3d_AABB_reset); - tolua_function(tolua_S,"set",lua_cocos2dx_3d_AABB_set); - tolua_function(tolua_S,"transform",lua_cocos2dx_3d_AABB_transform); - tolua_function(tolua_S,"getCenter",lua_cocos2dx_3d_AABB_getCenter); - tolua_function(tolua_S,"isEmpty",lua_cocos2dx_3d_AABB_isEmpty); - tolua_function(tolua_S,"getCorners",lua_cocos2dx_3d_AABB_getCorners); - tolua_function(tolua_S,"updateMinMax",lua_cocos2dx_3d_AABB_updateMinMax); - tolua_function(tolua_S,"containPoint",lua_cocos2dx_3d_AABB_containPoint); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::AABB).name(); - g_luaType[typeName] = "cc.AABB"; - g_typeCast["AABB"] = "cc.AABB"; - return 1; -} - -int lua_cocos2dx_3d_OBB_reset(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::OBB* 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.OBB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_reset'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->reset(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:reset",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_reset'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_OBB_set(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::OBB* 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.OBB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_set'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 5) - { - cocos2d::Vec3 arg0; - cocos2d::Vec3 arg1; - cocos2d::Vec3 arg2; - cocos2d::Vec3 arg3; - cocos2d::Vec3 arg4; - - ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.OBB:set"); - - ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.OBB:set"); - - ok &= luaval_to_vec3(tolua_S, 4, &arg2, "cc.OBB:set"); - - ok &= luaval_to_vec3(tolua_S, 5, &arg3, "cc.OBB:set"); - - ok &= luaval_to_vec3(tolua_S, 6, &arg4, "cc.OBB:set"); - if(!ok) - return 0; - cobj->set(arg0, arg1, arg2, arg3, arg4); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:set",argc, 5); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_set'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_OBB_transform(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::OBB* 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.OBB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_transform'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Mat4 arg0; - - ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.OBB:transform"); - if(!ok) - return 0; - cobj->transform(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:transform",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_transform'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_OBB_getCorners(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::OBB* 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.OBB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_getCorners'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec3* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Vec3",&arg0); - if(!ok) - return 0; - cobj->getCorners(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:getCorners",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_getCorners'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_OBB_containPoint(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::OBB* 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.OBB",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_containPoint'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec3 arg0; - - ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.OBB:containPoint"); - if(!ok) - return 0; - bool ret = cobj->containPoint(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:containPoint",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_containPoint'.",&tolua_err); -#endif - - return 0; -} -static int lua_cocos2dx_3d_OBB_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (OBB)"); - return 0; -} - -int lua_register_cocos2dx_3d_OBB(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.OBB"); - tolua_cclass(tolua_S,"OBB","cc.OBB","",nullptr); - - tolua_beginmodule(tolua_S,"OBB"); - tolua_function(tolua_S,"reset",lua_cocos2dx_3d_OBB_reset); - tolua_function(tolua_S,"set",lua_cocos2dx_3d_OBB_set); - tolua_function(tolua_S,"transform",lua_cocos2dx_3d_OBB_transform); - tolua_function(tolua_S,"getCorners",lua_cocos2dx_3d_OBB_getCorners); - tolua_function(tolua_S,"containPoint",lua_cocos2dx_3d_OBB_containPoint); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::OBB).name(); - g_luaType[typeName] = "cc.OBB"; - g_typeCast["OBB"] = "cc.OBB"; - return 1; -} - int lua_cocos2dx_3d_Skeleton3D_getBoneByName(lua_State* tolua_S) { int argc = 0; @@ -2814,8 +2108,6 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) lua_register_cocos2dx_3d_Animate3D(tolua_S); lua_register_cocos2dx_3d_Sprite3D(tolua_S); lua_register_cocos2dx_3d_AttachNode(tolua_S); - lua_register_cocos2dx_3d_AABB(tolua_S); - lua_register_cocos2dx_3d_OBB(tolua_S); lua_register_cocos2dx_3d_BillBoard(tolua_S); lua_register_cocos2dx_3d_Animation3D(tolua_S); lua_register_cocos2dx_3d_Skeleton3D(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index 3963c71800..443f02e21d 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -43,22 +43,6 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); - - - - - - - - - - - - - - - - diff --git a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp index 1de8c91325..55e1ee709f 100644 --- a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp @@ -26,7 +26,7 @@ #include "LuaBasicConversions.h" #include "CCLuaEngine.h" -int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* L) { int argc = 0; cocos2d::Sprite3D* cobj = nullptr; @@ -37,27 +37,27 @@ int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::Sprite3D*)tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'", nullptr); + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'", nullptr); return 0; } #endif - argc = lua_gettop(tolua_S)-1; + argc = lua_gettop(L)-1; if (argc == 2) { GLenum src, dst; - if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src, "cc.Sprite3D:setBlendFunc")) + if (!luaval_to_int32(L, 2, (int32_t*)&src, "cc.Sprite3D:setBlendFunc")) return 0; - if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst, "cc.Sprite3D:setBlendFunc")) + if (!luaval_to_int32(L, 3, (int32_t*)&dst, "cc.Sprite3D:setBlendFunc")) return 0; BlendFunc blendFunc = {src, dst}; @@ -69,7 +69,48 @@ int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'.",&tolua_err); + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_3d_Sprite3D_getAABB(lua_State* L) +{ + int argc = 0; + cocos2d::Sprite3D* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getAABB'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + cocos2d::AABB* ret = const_cast(&(cobj->getAABB())); + object_to_luaval(L, "cc.AABB",(cocos2d::AABB*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getAABB",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getAABB'.",&tolua_err); #endif return 0; } @@ -81,6 +122,7 @@ static void extendSprite3D(lua_State* L) if (lua_istable(L,-1)) { tolua_function(L, "setBlendFunc", lua_cocos2dx_3d_Sprite3D_setBlendFunc); + tolua_function(L, "getAABB", lua_cocos2dx_3d_Sprite3D_getAABB); } lua_pop(L, 1); } @@ -91,6 +133,1688 @@ static int register_all_cocos2dx_3d_manual(lua_State* L) return 0; extendSprite3D(L); + return 0; +} + +int lua_cocos2dx_3d_AABB_reset(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_reset'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->reset(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:reset",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_reset'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_set(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_set'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 2) + { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + + ok &= luaval_to_vec3(L, 2, &arg0, "cc.AABB:set"); + + ok &= luaval_to_vec3(L, 3, &arg1, "cc.AABB:set"); + if(!ok) + return 0; + cobj->set(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:set",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_set'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_transform(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_transform'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Mat4 arg0; + + ok &= luaval_to_mat4(L, 2, &arg0, "cc.AABB:transform"); + if(!ok) + return 0; + cobj->transform(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:transform",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_transform'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_getCenter(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_getCenter'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::Vec3 ret = cobj->getCenter(); + vec3_to_luaval(L, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:getCenter",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_getCenter'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_isEmpty(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_isEmpty'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->isEmpty(); + tolua_pushboolean(L,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:isEmpty",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_isEmpty'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_getCorners(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_getCorners'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Vec3* arg0; + + ok &= luaval_to_object(L, 2, "cc.Vec3",&arg0); + if(!ok) + return 0; + cobj->getCorners(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:getCorners",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_getCorners'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_updateMinMax(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_updateMinMax'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 2) + { + const cocos2d::Vec3* arg0; + ssize_t arg1; + + ok &= luaval_to_object(L, 2, "cc.Vec3",&arg0); + + ok &= luaval_to_ssize(L, 3, &arg1, "cc.AABB:updateMinMax"); + if(!ok) + return 0; + cobj->updateMinMax(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:updateMinMax",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_updateMinMax'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_containPoint(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AABB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_containPoint'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Vec3 arg0; + + ok &= luaval_to_vec3(L, 2, &arg0, "cc.AABB:containPoint"); + if(!ok) + return 0; + bool ret = cobj->containPoint(arg0); + tolua_pushboolean(L,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:containPoint",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_containPoint'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_AABB_constructor(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + argc = lua_gettop(L)-1; + do{ + if (argc == 2) { + cocos2d::Vec3 arg0; + ok &= luaval_to_vec3(L, 2, &arg0, "cc.AABB:AABB"); + + if (!ok) { break; } + cocos2d::Vec3 arg1; + ok &= luaval_to_vec3(L, 3, &arg1, "cc.AABB:AABB"); + + if (!ok) { break; } + cobj = new cocos2d::AABB(arg0, arg1); + tolua_pushusertype(L,(void*)cobj,"cc.AABB"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + cobj = new cocos2d::AABB(); + tolua_pushusertype(L,(void*)cobj,"cc.AABB"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:AABB",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_AABB_constructor'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_get_AABB_min(lua_State* L) +{ + cocos2d::AABB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::AABB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_AABB_min'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_min); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_AABB_min'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_AABB_min(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::AABB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_AABB_min'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_min); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_AABB_min'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_AABB_max(lua_State* L) +{ + cocos2d::AABB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::AABB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_AABB_max'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_max); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_AABB_max'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_AABB_max(lua_State* L) +{ + int argc = 0; + cocos2d::AABB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::AABB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_AABB_max'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_max); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_Ray_direction'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_AABB_finalize(lua_State* L) +{ + cocos2d::AABB* self = (cocos2d::AABB*) tolua_tousertype(L,1,0); + CC_SAFE_DELETE(self); + return 0; +} + +int lua_register_cocos2dx_3d_AABB(lua_State* L) +{ + tolua_usertype(L,"cc.AABB"); + tolua_cclass(L,"AABB","cc.AABB","",lua_cocos2dx_3d_AABB_finalize); + + tolua_beginmodule(L,"AABB"); + tolua_variable(L, "_min", lua_cocos2dx_3d_get_AABB_min, lua_cocos2dx_3d_set_AABB_min); + tolua_variable(L, "_max", lua_cocos2dx_3d_get_AABB_max, lua_cocos2dx_3d_set_AABB_max); + tolua_function(L,"new",lua_cocos2dx_3d_AABB_constructor); + tolua_function(L,"reset",lua_cocos2dx_3d_AABB_reset); + tolua_function(L,"set",lua_cocos2dx_3d_AABB_set); + tolua_function(L,"transform",lua_cocos2dx_3d_AABB_transform); + tolua_function(L,"getCenter",lua_cocos2dx_3d_AABB_getCenter); + tolua_function(L,"isEmpty",lua_cocos2dx_3d_AABB_isEmpty); + tolua_function(L,"getCorners",lua_cocos2dx_3d_AABB_getCorners); + tolua_function(L,"updateMinMax",lua_cocos2dx_3d_AABB_updateMinMax); + tolua_function(L,"containPoint",lua_cocos2dx_3d_AABB_containPoint); + tolua_endmodule(L); + std::string typeName = typeid(cocos2d::AABB).name(); + g_luaType[typeName] = "cc.AABB"; + g_typeCast["AABB"] = "cc.AABB"; + return 1; +} + +int lua_cocos2dx_3d_OBB_reset(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::OBB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_reset'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->reset(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:reset",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_reset'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_OBB_set(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::OBB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_set'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 5) + { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + cocos2d::Vec3 arg2; + cocos2d::Vec3 arg3; + cocos2d::Vec3 arg4; + + ok &= luaval_to_vec3(L, 2, &arg0, "cc.OBB:set"); + + ok &= luaval_to_vec3(L, 3, &arg1, "cc.OBB:set"); + + ok &= luaval_to_vec3(L, 4, &arg2, "cc.OBB:set"); + + ok &= luaval_to_vec3(L, 5, &arg3, "cc.OBB:set"); + + ok &= luaval_to_vec3(L, 6, &arg4, "cc.OBB:set"); + if(!ok) + return 0; + cobj->set(arg0, arg1, arg2, arg3, arg4); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:set",argc, 5); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_set'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_OBB_transform(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::OBB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_transform'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Mat4 arg0; + + ok &= luaval_to_mat4(L, 2, &arg0, "cc.OBB:transform"); + if(!ok) + return 0; + cobj->transform(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:transform",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_transform'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_OBB_containPoint(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::OBB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_containPoint'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Vec3 arg0; + + ok &= luaval_to_vec3(L, 2, &arg0, "cc.OBB:containPoint"); + if(!ok) + return 0; + bool ret = cobj->containPoint(arg0); + tolua_pushboolean(L,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:containPoint",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_containPoint'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_OBB_constructor(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + argc = lua_gettop(L)-1; + do{ + if (argc == 1) { + cocos2d::AABB* arg0; + ok &= luaval_to_object(L, 2, "cc.AABB",&arg0); + + if (!ok) { break; } + cobj = new cocos2d::OBB(*arg0); + tolua_pushusertype(L,(void*)cobj,"cc.OBB"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + cobj = new cocos2d::OBB(); + tolua_pushusertype(L,(void*)cobj,"cc.OBB"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 2) { + const cocos2d::Vec3* arg0; + ok &= luaval_to_object(L, 2, "cc.Vec3",&arg0); + + if (!ok) { break; } + int arg1; + ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.OBB:OBB"); + + if (!ok) { break; } + cobj = new cocos2d::OBB(arg0, arg1); + tolua_pushusertype(L,(void*)cobj,"cc.OBB"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:OBB",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_constructor'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_OBB_intersects(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* self = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_OBB_intersects'\n", nullptr); + return 0; + } +#endif + argc = lua_gettop(L)-1; + if(1 == argc) + { + cocos2d::OBB* arg0; + ok &= luaval_to_object(L, 2, "cc.OBB",&arg0); + + if (!ok) + return 0; + + bool ret = self->intersects(*arg0); + tolua_pushboolean(L, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:intersects",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_intersects'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_OBB_center(lua_State* L) +{ + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_OBB_center'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_center); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_OBB_center'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_OBB_center(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_OBB_center'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_center); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_OBB_center'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_OBB_xAxis(lua_State* L) +{ + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_OBB_xAxis'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_xAxis); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_OBB_xAxis'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_OBB_xAxis(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_OBB_xAxis'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_xAxis); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_OBB_center'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_OBB_yAxis(lua_State* L) +{ + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_OBB_yAxis'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_yAxis); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_OBB_yAxis'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_OBB_yAxis(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_OBB_yAxis'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_yAxis); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_OBB_yAxis'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_OBB_zAxis(lua_State* L) +{ + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_OBB_zAxis'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_zAxis); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_OBB_zAxis'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_OBB_zAxis(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_OBB_zAxis'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_zAxis); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_OBB_zAxis'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_OBB_extents(lua_State* L) +{ + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_OBB_extents'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_extents); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_OBB_extents'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_OBB_extents(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::OBB*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_OBB_extents'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_extents); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_OBB_extents'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_OBB_getCorners(lua_State* L) +{ + int argc = 0; + cocos2d::OBB* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::OBB*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_getCorners'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Vec3* arg0; +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + + size_t len = lua_objlen(L, 2); + if (len == 0 ) + { + CCLOG("Table's len equal 0"); + return 0; + } + + arg0 = new cocos2d::Vec3[len]; + + if (nullptr == arg0) + { + CCLOG("Allocate cocos2d::Vec3 array in the lua_cocos2dx_3d_OBB_getCorners failed!"); + return 0; + } + + for (int i = 1 ; i <= len; i++) + { + lua_pushnumber(L,i); + lua_gettable(L,2); + if (lua_isnil(L, -1)) + { + arg0[i - 1] = cocos2d::Vec3(0,0,0); + } + else + { + luaval_to_vec3(L, -1, &arg0[i - 1], "cc.OBB:getCorners"); + } + lua_pop(L,1); + } + + cobj->getCorners(arg0); + + lua_newtable(L); + + for (int i = 1; i <= len; i++) + { + lua_pushnumber(L, i); + vec3_to_luaval(L, arg0[i - 1]); + lua_rawset(L, -3); + } + CC_SAFE_DELETE_ARRAY(arg0); + + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:getCorners",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_OBB_getCorners'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_OBB_finalize(lua_State* L) +{ + cocos2d::OBB* self = (cocos2d::OBB*) tolua_tousertype(L,1,0); + CC_SAFE_DELETE(self); + return 0; +} + +int lua_register_cocos2dx_3d_OBB(lua_State* L) +{ + tolua_usertype(L,"cc.OBB"); + tolua_cclass(L,"OBB","cc.OBB","",lua_cocos2dx_3d_OBB_finalize); + + tolua_beginmodule(L,"OBB"); + tolua_variable(L, "_center", lua_cocos2dx_3d_get_OBB_center, lua_cocos2dx_3d_set_OBB_center); + tolua_variable(L, "_xAxis", lua_cocos2dx_3d_get_OBB_xAxis, lua_cocos2dx_3d_set_OBB_xAxis); + tolua_variable(L, "_yAxis", lua_cocos2dx_3d_get_OBB_yAxis, lua_cocos2dx_3d_set_OBB_yAxis); + tolua_variable(L, "_zAxis", lua_cocos2dx_3d_get_OBB_zAxis, lua_cocos2dx_3d_set_OBB_zAxis); + tolua_variable(L, "_extents", lua_cocos2dx_3d_get_OBB_extents, lua_cocos2dx_3d_set_OBB_extents); + tolua_function(L, "new", lua_cocos2dx_3d_OBB_constructor); + tolua_function(L,"reset",lua_cocos2dx_3d_OBB_reset); + tolua_function(L,"set",lua_cocos2dx_3d_OBB_set); + tolua_function(L,"transform",lua_cocos2dx_3d_OBB_transform); + tolua_function(L,"containPoint",lua_cocos2dx_3d_OBB_containPoint); + tolua_function(L,"intersects", lua_cocos2dx_3d_OBB_intersects); + tolua_function(L,"getCorners", lua_cocos2dx_3d_OBB_getCorners); + tolua_endmodule(L); + std::string typeName = typeid(cocos2d::OBB).name(); + g_luaType[typeName] = "cc.OBB"; + g_typeCast["OBB"] = "cc.OBB"; + return 1; +} + +int lua_cocos2dx_3d_Ray_set(lua_State* L) +{ + int argc = 0; + cocos2d::Ray* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Ray*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_Ray_set'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 2) + { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + + ok &= luaval_to_vec3(L, 2, &arg0, "cc.Ray:set"); + + ok &= luaval_to_vec3(L, 3, &arg1, "cc.Ray:set"); + if(!ok) + return 0; + cobj->set(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Ray:set",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Ray_set'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Ray_transform(lua_State* L) +{ + int argc = 0; + cocos2d::Ray* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Ray*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_Ray_transform'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 1) + { + cocos2d::Mat4 arg0; + + ok &= luaval_to_mat4(L, 2, &arg0, "cc.Ray:transform"); + if(!ok) + return 0; + cobj->transform(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Ray:transform",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Ray_transform'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_Ray_intersects(lua_State* L) +{ + int argc = 0; + cocos2d::Ray* self = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::Ray*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_Ray_intersects'\n", nullptr); + return 0; + } +#endif + argc = lua_gettop(L)-1; + if(1 == argc) + { + cocos2d::OBB* arg0 = nullptr; + ok &= luaval_to_object(L, 2, "cc.OBB",&arg0); + + if (!ok) + return 0; + + bool ret = self->intersects(*arg0); + tolua_pushboolean(L, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Ray:intersects",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_OBB_center'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_Ray_constructor(lua_State* L) +{ + int argc = 0; + cocos2d::Ray* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + argc = lua_gettop(L)-1; + do{ + if (argc == 2) { + cocos2d::Vec3 arg0; + ok &= luaval_to_vec3(L, 2, &arg0, "cc.Ray:Ray"); + + if (!ok) { break; } + cocos2d::Vec3 arg1; + ok &= luaval_to_vec3(L, 3, &arg1, "cc.Ray:Ray"); + + if (!ok) { break; } + cobj = new cocos2d::Ray(arg0, arg1); + tolua_pushusertype(L,(void*)cobj,"cc.Ray"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + cobj = new cocos2d::Ray(); + tolua_pushusertype(L,(void*)cobj,"cc.Ray"); + tolua_register_gc(L,lua_gettop(L)); + return 1; + } + }while(0); + ok = true; + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Ray:Ray",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Ray_constructor'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_3d_get_Ray_origin(lua_State* L) +{ + cocos2d::Ray* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::Ray*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_Ray_origin'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_origin); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_Ray_origin'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_Ray_origin(lua_State* L) +{ + int argc = 0; + cocos2d::Ray* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::Ray*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_Ray_origin'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_origin); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_Ray_origin'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_get_Ray_direction(lua_State* L) +{ + cocos2d::Ray* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::Ray*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_get_Ray_direction'\n", nullptr); + return 0; + } +#endif + vec3_to_luaval(L, self->_direction); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_get_Ray_direction'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_set_Ray_direction(lua_State* L) +{ + int argc = 0; + cocos2d::Ray* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.Ray",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::Ray*) tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_3d_set_Ray_direction'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_vec3(L, 2, &self->_direction); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_set_Ray_direction'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_3d_Ray_finalize(lua_State* L) +{ + cocos2d::Ray* self = (cocos2d::Ray*) tolua_tousertype(L,1,0); + CC_SAFE_DELETE(self); + return 0; +} + +int lua_register_cocos2dx_3d_Ray(lua_State* L) +{ + tolua_usertype(L,"cc.Ray"); + tolua_cclass(L,"Ray","cc.Ray","",lua_cocos2dx_3d_Ray_finalize); + + tolua_beginmodule(L,"Ray"); + tolua_variable(L, "_origin", lua_cocos2dx_3d_get_Ray_origin, lua_cocos2dx_3d_set_Ray_origin); + tolua_variable(L, "_direction", lua_cocos2dx_3d_get_Ray_direction, lua_cocos2dx_3d_set_Ray_direction); + tolua_function(L,"new",lua_cocos2dx_3d_Ray_constructor); + tolua_function(L,"set",lua_cocos2dx_3d_Ray_set); + tolua_function(L,"transform",lua_cocos2dx_3d_Ray_transform); + tolua_function(L, "intersects", lua_cocos2dx_3d_Ray_intersects); + tolua_endmodule(L); + std::string typeName = typeid(cocos2d::Ray).name(); + g_luaType[typeName] = "cc.Ray"; + g_typeCast["Ray"] = "cc.Ray"; + return 1; +} + +int register_all_cocos3d_manual_class(lua_State* L) +{ + tolua_module(L,"cc",0); + tolua_beginmodule(L,"cc"); + lua_register_cocos2dx_3d_AABB(L); + lua_register_cocos2dx_3d_OBB(L); + lua_register_cocos2dx_3d_Ray(L); + tolua_endmodule(L); return 0; } @@ -102,6 +1826,7 @@ int register_cocos3d_module(lua_State* L) { register_all_cocos2dx_3d(L); register_all_cocos2dx_3d_manual(L); + register_all_cocos3d_manual_class(L); } lua_pop(L, 1); diff --git a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp index 0cc0d2ba61..6a114d5b40 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp @@ -57,9 +57,6 @@ bool LuaEngine::init(void) { _stack = LuaStack::create(); _stack->retain(); - executeScriptFile("DeprecatedCocos2dClass"); - executeScriptFile("DeprecatedCocos2dEnum"); - executeScriptFile("DeprecatedCocos2dFunc"); return true; } diff --git a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp index 6a4193e22c..1933041efc 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -177,7 +177,7 @@ bool LuaStack::init(void) const luaL_reg global_functions [] = { {"print", lua_print}, {"release_print",lua_release_print}, - {NULL, NULL} + {nullptr, nullptr} }; luaL_register(_state, "_G", global_functions); @@ -186,6 +186,7 @@ bool LuaStack::init(void) tolua_opengl_open(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_module_manual(_state); + register_all_cocos2dx_math_manual(_state); register_all_cocos2dx_experimental(_state); register_all_cocos2dx_experimental_manual(_state); @@ -584,7 +585,7 @@ int LuaStack::executeFunctionReturnArray(int handler,int numArgs,int numResults, }else{ - resultArray.addObject(static_cast(tolua_tousertype(_state, -1, NULL))); + resultArray.addObject(static_cast(tolua_tousertype(_state, -1, nullptr))); } // remove return value from stack lua_pop(_state, 1); /* L: ... [G] ret1 ret2 ... ret*/ @@ -731,6 +732,97 @@ void LuaStack::cleanupXXTEAKeyAndSign() } } +int LuaStack::loadChunksFromZIP(const char *zipFilePath) +{ + pushString(zipFilePath); + luaLoadChunksFromZIP(_state); + int ret = lua_toboolean(_state, -1); + lua_pop(_state, 1); + return ret; +} + +int LuaStack::luaLoadChunksFromZIP(lua_State *L) +{ + if (lua_gettop(L) < 1) { + CCLOG("luaLoadChunksFromZIP() - invalid arguments"); + return 0; + } + + const char *zipFilename = lua_tostring(L, -1); + lua_settop(L, 0); + FileUtils *utils = FileUtils::getInstance(); + std::string zipFilePath = utils->fullPathForFilename(zipFilename); + + LuaStack *stack = this; + + do { + ssize_t size = 0; + void *buffer = nullptr; + unsigned char *zipFileData = utils->getFileData(zipFilePath.c_str(), "rb", &size); + ZipFile *zip = nullptr; + + bool isXXTEA = stack && stack->_xxteaEnabled && zipFileData; + for (int i = 0; isXXTEA && i < stack->_xxteaSignLen && i < size; ++i) { + isXXTEA = zipFileData[i] == stack->_xxteaSign[i]; + } + + if (isXXTEA) { // decrypt XXTEA + xxtea_long len = 0; + buffer = xxtea_decrypt(zipFileData + stack->_xxteaSignLen, + (xxtea_long)size - (xxtea_long)stack->_xxteaSignLen, + (unsigned char*)stack->_xxteaKey, + (xxtea_long)stack->_xxteaKeyLen, + &len); + delete []zipFileData; + zipFileData = nullptr; + zip = ZipFile::createWithBuffer(buffer, len); + } else { + if (zipFileData) { + zip = ZipFile::createWithBuffer(zipFileData, size); + } + } + + if (zip) { + CCLOG("lua_loadChunksFromZIP() - load zip file: %s%s", zipFilePath.c_str(), isXXTEA ? "*" : ""); + lua_getglobal(L, "package"); + lua_getfield(L, -1, "preload"); + + int count = 0; + std::string filename = zip->getFirstFilename(); + while (filename.length()) { + ssize_t bufferSize = 0; + unsigned char *zbuffer = zip->getFileData(filename.c_str(), &bufferSize); + if (bufferSize) { + if (stack->luaLoadBuffer(L, (char*)zbuffer, (int)bufferSize, filename.c_str()) == 0) { + lua_setfield(L, -2, filename.c_str()); + ++count; + } + delete []zbuffer; + } + filename = zip->getNextFilename(); + } + CCLOG("lua_loadChunksFromZIP() - loaded chunks count: %d", count); + lua_pop(L, 2); + lua_pushboolean(L, 1); + + delete zip; + } else { + CCLOG("lua_loadChunksFromZIP() - not found or invalid zip file: %s", zipFilePath.c_str()); + lua_pushboolean(L, 0); + } + + if (zipFileData) { + delete []zipFileData; + } + + if (buffer) { + free(buffer); + } + } while (0); + + return 1; +} + int LuaStack::luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, const char *chunkName) { int r = 0; diff --git a/cocos/scripting/lua-bindings/manual/CCLuaStack.h b/cocos/scripting/lua-bindings/manual/CCLuaStack.h index 9d6345282e..5bdb0330bc 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaStack.h +++ b/cocos/scripting/lua-bindings/manual/CCLuaStack.h @@ -133,6 +133,8 @@ public: virtual void cleanupXXTEAKeyAndSign(); int luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, const char *chunkName); + int loadChunksFromZIP(const char *zipFilePath); + int luaLoadChunksFromZIP(lua_State *L); protected: LuaStack(void) diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp index 7e828ebd33..e40cdb84d4 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -371,12 +371,12 @@ bool luaval_to_vec4(lua_State* L,int lo,cocos2d::Vec4* outValue, const char* fun lua_pushstring(L, "z"); lua_gettable(L, lo); - outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->z = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "w"); lua_gettable(L, lo); - outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->w = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); } return ok; @@ -1997,6 +1997,48 @@ bool luaval_to_std_vector_ushort(lua_State* L, int lo, std::vector=1 + luaval_to_native_err(L,"#ferror:",&tolua_err,funcName); +#endif + ok = false; + } + + + if (ok) + { + lua_pushstring(L, "x"); + lua_gettable(L, lo); + outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + + lua_pushstring(L, "y"); + lua_gettable(L, lo); + outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + + lua_pushstring(L, "z"); + lua_gettable(L, lo); + outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + + lua_pushstring(L, "w"); + lua_gettable(L, lo); + outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + } + return ok; +} + void vec2_array_to_luaval(lua_State* L,const cocos2d::Vec2* points, int count) { if (NULL == L) @@ -2939,3 +2981,23 @@ void ccvector_ushort_to_luaval(lua_State* L, const std::vector& ++index; } } + +void quaternion_to_luaval(lua_State* L,const cocos2d::Quaternion& inValue) +{ + if (NULL == L) + return; + + lua_newtable(L); /* L: table */ + lua_pushstring(L, "x"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.x); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "y"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.y); /* L: table key value*/ + lua_rawset(L, -3); + lua_pushstring(L, "z"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.z); /* L: table key value*/ + lua_rawset(L, -3); + lua_pushstring(L, "w"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.w); /* L: table key value*/ + lua_rawset(L, -3); +} diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index 3efe1d9a36..76cd4c3de0 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -235,6 +235,7 @@ bool luaval_to_object(lua_State* L, int lo, const char* type, T** ret) extern bool luaval_to_mesh_vertex_attrib(lua_State* L, int lo, cocos2d::MeshVertexAttrib* ret, const char* funcName = ""); extern bool luaval_to_std_vector_float(lua_State* L, int lo, std::vector* ret, const char* funcName = ""); extern bool luaval_to_std_vector_ushort(lua_State* L, int lo, std::vector* ret, const char* funcName = ""); +extern bool luaval_to_quaternion(lua_State* L,int lo,cocos2d::Quaternion* outValue, const char* funcName = ""); // from native extern void vec2_to_luaval(lua_State* L,const cocos2d::Vec2& vec2); @@ -386,5 +387,6 @@ void ccvector_std_string_to_luaval(lua_State* L, const std::vector& void ccvector_int_to_luaval(lua_State* L, const std::vector& inValue); void ccvector_float_to_luaval(lua_State* L, const std::vector& inValue); void ccvector_ushort_to_luaval(lua_State* L, const std::vector& inValue); +void quaternion_to_luaval(lua_State* L,const cocos2d::Quaternion& inValue); #endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index 9fe9bac783..48b13a2760 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -7232,3 +7232,254 @@ int register_all_cocos2dx_module_manual(lua_State* tolua_S) return 0; } + +static int tolua_cocos2d_Mat4_getInversed(lua_State* tolua_S) +{ +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_istable(tolua_S, 1, 0, &tolua_err)) + goto tolua_lerror; + else +#endif + { + cocos2d::Mat4 mat; + bool ok = luaval_to_mat4(tolua_S, 1, &mat); + if (ok) + { + mat4_to_luaval(tolua_S, mat.getInversed()); + return 1; + } + } + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'mat4_getInversed'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S) +{ + bool ok = true; + int argc = lua_gettop(tolua_S); + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + if (argc == 3) + { +#if COCOS2D_DEBUG >= 1 + + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || + !tolua_istable(tolua_S, 2, 0, &tolua_err) || + !tolua_istable(tolua_S, 3, 0, &tolua_err)) + goto tolua_lerror; + else +#endif + { + cocos2d::Mat4 mat; + cocos2d::Vec4 vector; + cocos2d::Vec4 dst; + ok &= luaval_to_mat4(tolua_S, 1, &mat); + if (!ok) + return 0; + + ok &= luaval_to_vec4(tolua_S, 2, &vector); + if (!ok) + return 0; + + ok &= luaval_to_vec4(tolua_S, 3, &dst); + if (!ok) + return 0; + + mat.transformVector(vector, &dst); + vec4_to_luaval(tolua_S, dst); + return 1; + } + } + else if(argc == 6) + { + /* + float x, float y, float z, float w, Vec3* dst + */ +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 6, 0, &tolua_err)) + goto tolua_lerror; + else +#endif + { + cocos2d::Mat4 mat; + float x,y,z,w; + cocos2d::Vec3 dst; + ok &= luaval_to_mat4(tolua_S, 1, &mat); + if (!ok) + return 0; + + x = tolua_tonumber(tolua_S, 2, 0); + y = tolua_tonumber(tolua_S, 3, 0); + z = tolua_tonumber(tolua_S, 4, 0); + w = tolua_tonumber(tolua_S, 5, 0); + + ok &= luaval_to_vec3(tolua_S, 6, &dst); + if (!ok) + return 0; + + mat.transformVector(x,y,z,w, &dst); + vec3_to_luaval(tolua_S, dst); + return 1; + } + } + + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'mat4_transformVector'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S) +{ +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || + !tolua_istable(tolua_S, 2, 0, &tolua_err) || + !tolua_istable(tolua_S, 3, 0, &tolua_err) || + !tolua_istable(tolua_S, 4, 0, &tolua_err)) + goto tolua_lerror; + else +#endif + { + cocos2d::Mat4 mat; + cocos2d::Vec3 scale; + cocos2d::Quaternion rotation; + cocos2d::Vec3 translation; + bool ok = true; + ok &= luaval_to_mat4(tolua_S, 1, &mat); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 2, &scale); + if (!ok) + return 0; + + ok &= luaval_to_quaternion(tolua_S, 3, &rotation); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 2, &translation); + if (!ok) + return 0; + + mat.decompose(&scale, &rotation, &translation); + vec3_to_luaval(tolua_S, scale); + quaternion_to_luaval(tolua_S, rotation); + vec3_to_luaval(tolua_S, translation); + return 3; + } + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'mat4_decompose'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S) +{ + int argc = lua_gettop(tolua_S); + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || + !tolua_istable(tolua_S, 2, 0, &tolua_err) ) + goto tolua_lerror; + else +#endif + { + cocos2d::Vec3 cobj; + cocos2d::Vec3 v; + + bool ok = true; + + ok &= luaval_to_vec3(tolua_S, 1, &cobj); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 2, &v); + if (!ok) + return 0; + + cobj.cross(v); + + vec3_to_luaval(tolua_S, cobj); + return 1; + } + } + else if (3 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || + !tolua_istable(tolua_S, 2, 0, &tolua_err) || + !tolua_istable(tolua_S, 3, 0, &tolua_err) ) + goto tolua_lerror; + else +#endif + { + cocos2d::Vec3 v1; + cocos2d::Vec3 v2; + cocos2d::Vec3 dst; + bool ok = true; + + + ok &= luaval_to_vec3(tolua_S, 1, &v1); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 2, &v2); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 3, &dst); + if (!ok) + return 0; + + cocos2d::Vec3::cross(v1, v2, &dst); + + vec3_to_luaval(tolua_S, dst); + return 1; + } + } + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'MathUtil_gcrossVec3'.",&tolua_err); + return 0; +#endif +} + +int register_all_cocos2dx_math_manual(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + + tolua_module(tolua_S, nullptr, 0); + tolua_beginmodule(tolua_S, nullptr); + tolua_function(tolua_S, "mat4_getInversed", tolua_cocos2d_Mat4_getInversed); + tolua_function(tolua_S, "mat4_transformVector", tolua_cocos2d_Mat4_transformVector); + tolua_function(tolua_S, "mat4_decompose", tolua_cocos2d_Mat4_decompose); + tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross); + tolua_endmodule(tolua_S); + return 0; +} diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.hpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.hpp index 814b25578c..85d3e4e666 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.hpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.hpp @@ -57,6 +57,8 @@ TOLUA_API int register_cocos2dx_event_releated(lua_State* tolua_S); TOLUA_API int register_all_cocos2dx_module_manual(lua_State* tolua_S); +TOLUA_API int register_all_cocos2dx_math_manual(lua_State* tolua_S); + struct LuaEventAccelerationData { void* acc; diff --git a/cocos/scripting/lua-bindings/manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp b/cocos/scripting/lua-bindings/manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp index 11693b86cb..2af71ea569 100644 --- a/cocos/scripting/lua-bindings/manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp @@ -465,7 +465,5 @@ int register_cocosbuilder_module(lua_State* tolua_S) register_all_cocos2dx_cocosbuilder_manual(tolua_S); } lua_pop(tolua_S, 1); - - LuaEngine::getInstance()->executeScriptFile("DeprecatedCocosBuilderClass"); return 1; } diff --git a/cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp b/cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp index 9098fd949c..6560cf719b 100644 --- a/cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp @@ -33,8 +33,5 @@ int register_cocosdenshion_module(lua_State* L) register_all_cocos2dx_cocosdenshion(L); } lua_pop(L, 1); - - cocos2d::LuaEngine::getInstance()->executeScriptFile("DeprecatedCocosDenshionClass"); - cocos2d::LuaEngine::getInstance()->executeScriptFile("DeprecatedCocosDenshionFunc"); return 1; } \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp index eabfb21ac0..1fe69a01dc 100644 --- a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp @@ -647,8 +647,5 @@ int register_cocostudio_module(lua_State* L) lua_register_cocos2dx_coco_studio_CustomGUIReader(L); } lua_pop(L, 1); - - LuaEngine::getInstance()->executeScriptFile("DeprecatedCocoStudioClass"); - LuaEngine::getInstance()->executeScriptFile("DeprecatedCocoStudioFunc"); return 1; } diff --git a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp index 48a3eda657..5ae4cf3c9a 100644 --- a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp @@ -957,9 +957,5 @@ int register_extension_module(lua_State* tolua_S) register_all_cocos2dx_extension_manual(tolua_S); } lua_pop(tolua_S, 1); - - LuaEngine::getInstance()->executeScriptFile("DeprecatedExtensionClass"); - LuaEngine::getInstance()->executeScriptFile("DeprecatedExtensionEnum"); - LuaEngine::getInstance()->executeScriptFile("DeprecatedExtensionFunc"); return 1; } diff --git a/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp b/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp index d563fdf546..8a79fefe0b 100644 --- a/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp @@ -53,9 +53,5 @@ int register_network_module(lua_State* L) } lua_pop(L, 1); - cocos2d::LuaEngine::getInstance()->executeScriptFile("DeprecatedNetworkClass"); - cocos2d::LuaEngine::getInstance()->executeScriptFile("DeprecatedNetworkEnum"); - cocos2d::LuaEngine::getInstance()->executeScriptFile("DeprecatedNetworkFunc"); - return 1; } diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp index 4318a9173f..c00db6339c 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp @@ -808,7 +808,5 @@ int register_ui_moudle(lua_State* L) } lua_pop(L, 1); - LuaEngine::getInstance()->executeScriptFile("DeprecatedUIEnum"); - LuaEngine::getInstance()->executeScriptFile("DeprecatedUIFunc"); return 1; } diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua index 84c3f25c19..386e19067a 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua @@ -1,10 +1,11 @@ + cc = cc or {} function cc.clampf(value, min_inclusive, max_inclusive) -- body local temp = 0 if min_inclusive > max_inclusive then - temp = min_inclusive + temp = min_inclusive min_inclusive = max_inclusive max_inclusive = temp end @@ -110,7 +111,7 @@ function cc.pIsLineIntersect(A, B, C, D, s, t) return false, s, t end - + s = s / denom t = t / denom @@ -153,7 +154,7 @@ function cc.pFromSize(sz) return { x = sz.width, y = sz.height } end -function cc.pLerp(pt1,pt2,alpha) +function cc.pLerp(pt1,pt2,alpha) return cc.pAdd(cc.pMul(pt1, 1.0 - alpha), cc.pMul(pt2,alpha) ) end @@ -166,13 +167,13 @@ function cc.pFuzzyEqual(pt1,pt2,variance) end function cc.pRotateByAngle(pt1, pt2, angle) - return cc.pAdd(pt2, cc.pRotate( cc.pSub(pt1, pt2),cc.pForAngle(angle))) + return cc.pAdd(pt2, cc.pRotate( cc.pSub(pt1, pt2),cc.pForAngle(angle))) end function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) local s,t,ret = 0,0,false ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t) - + if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then return true; end @@ -182,7 +183,7 @@ end function cc.pGetIntersectPoint(pt1,pt2,pt3,pt4) local s,t, ret = 0,0,false - ret,s,t = cc.pIsLineIntersect(pt1,pt2,pt3,pt4,s,t) + ret,s,t = cc.pIsLineIntersect(pt1,pt2,pt3,pt4,s,t) if ret then return cc.p(pt1.x + s * (pt2.x - pt1.x), pt1.y + s * (pt2.y - pt1.y)) else @@ -235,7 +236,7 @@ end function cc.rectContainsPoint( rect, point ) local ret = false - + if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and (point.y >= rect.y) and (point.y <= rect.y + rect.height) then ret = true @@ -367,6 +368,10 @@ function cc.vec3(_x, _y, _z) return { x = _x, y = _y, z = _z } end +function cc.vec4(_x, _y, _z, _w) + return { x = _x, y = _y, z = _z, w = _w } +end + function cc.vec3normalize(vec3) local n = vec3.x * vec3.x + vec3.y * vec3.y + vec3.z * vec3.z if n == 1.0 then @@ -382,3 +387,45 @@ function cc.vec3normalize(vec3) n = 1.0 / n return {x = vec3.x * n, y = vec3.y * n, z = vec3.z * n} end + +function cc.quaternion(_x, _y ,_z,_w) + return { x = _x, y = _y, z = _z, w = _w } +end + +cc.mat4 = cc.mat4 or {} + +function cc.mat4.new(...) + local params = {...} + local size = #params + + local obj = {} + + if 1 == size then + assert(type(params[1]) == "table" , "type of input params are wrong to new a mat4 when num of params is 1") + for i= 1, 16 do + if params[1][i] ~= nil then + obj[i] = params[1][i] + else + obj[i] = 0 + end + end + elseif 16 == size then + if params[i] ~= nil then + mat4[i] = params[i] + else + mat4[i] = 0 + end + end + + setmetatable(obj, {__index = cc.mat4}) + + return obj +end + +function cc.mat4.getInversed(self) + return mat4_getInversed(self) +end + +function cc.mat4.transformVector(self, vector, dst) + return mat4_transformVector(self, vector, dst) +end diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index 41dc89d60d..469f58aec2 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -1,3 +1,4 @@ + cc = cc or {} cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff @@ -204,7 +205,7 @@ cc.LANGUAGE_ARABIC = 11 cc.NODE_ON_ENTER = 0 cc.NODE_ON_EXIT = 1 cc.NODE_ON_ENTER_TRANSITION_DID_FINISH = 2 -cc.NODE_ON_EXIT_TRANSITION_DID_START = 3 +cc.NODE_ON_EXIT_TRANSITION_DID_START = 3 cc.NODE_ON_CLEAN_UP = 4 cc.Handler = cc.Handler or {} @@ -289,7 +290,7 @@ cc.GLYPHCOLLECTION_NEHE = 1 cc.GLYPHCOLLECTION_ASCII = 2 cc.GLYPHCOLLECTION_CUSTOM = 3 -cc.ResolutionPolicy = +cc.ResolutionPolicy = { EXACT_FIT = 0, NO_BORDER = 1, @@ -299,7 +300,7 @@ cc.ResolutionPolicy = UNKNOWN = 5, } -cc.LabelEffect = +cc.LabelEffect = { NORMAL = 0, OUTLINE = 1, @@ -496,7 +497,7 @@ cc.EventCode = cc.DIRECTOR_PROJECTION_2D = 0 cc.DIRECTOR_PROJECTION_3D = 1 -cc.ConfigType = +cc.ConfigType = { NONE = 0, COCOSTUDIO = 1, @@ -505,7 +506,7 @@ cc.ConfigType = cc.AUDIO_INVAILD_ID = -1 cc.AUDIO_TIME_UNKNOWN = -1.0 -cc.CameraFlag = +cc.CameraFlag = { DEFAULT = 1, USER1 = 2, @@ -518,8 +519,35 @@ cc.CameraFlag = USER8 = 256, } -cc.BillBoard_Mode = +cc.BillBoard_Mode = { VIEW_POINT_ORIENTED = 0, VIEW_PLANE_ORIENTED = 1, } + +cc.GLProgram_VERTEX_ATTRIB = +{ + POSITION = 0, + COLOR = 1, + TEX_COORD = 2, + TEX_COORD1 = 3, + TEX_COORD2 = 4, + TEX_COORD3 = 5, + TEX_COORD4 = 6, + TEX_COORD5 = 7, + TEX_COORD6 = 8, + TEX_COORD7 = 9, + NORMAL = 10, + BLEND_WEIGHT = 11, + BLEND_INDEX =12, + MAX = 13, + --backward compatibility + TEX_COORDS = 2, +} + +cc.MATRIX_STACK_TYPE = +{ + MODELVIEW = 0, + PROJECTION = 1, + TEXTURE = 2, +} diff --git a/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dEnum.lua b/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dEnum.lua index 58419c2d44..4b6b92fea4 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dEnum.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dEnum.lua @@ -1,13 +1,12 @@ -require "Cocos2dConstants.lua" -require "OpenglConstants.lua" + --Enums will be deprecated,begin _G.kCCTextAlignmentLeft = cc.TEXT_ALIGNMENT_LEFT _G.kCCTextAlignmentRight = cc.TEXT_ALIGNMENT_RIGHT _G.kCCTextAlignmentCenter = cc.TEXT_ALIGNMENT_CENTER _G.kCCVerticalTextAlignmentTop = cc.VERTICAL_TEXT_ALIGNMENT_TOP -_G.kCCVerticalTextAlignmentCenter = cc.VERTICAL_TEXT_ALIGNMENT_CENTER +_G.kCCVerticalTextAlignmentCenter = cc.VERTICAL_TEXT_ALIGNMENT_CENTER _G.kCCVerticalTextAlignmentBottom = cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM -_G.kCCDirectorProjection3D = cc.DIRECTOR_PROJECTION3_D +_G.kCCDirectorProjection3D = cc.DIRECTOR_PROJECTION3_D _G.kCCDirectorProjection2D = cc.DIRECTOR_PROJECTION2_D _G.kCCDirectorProjectionCustom = cc.DIRECTOR_PROJECTION_CUSTOM _G.kCCDirectorProjectionDefault = cc.DIRECTOR_PROJECTION_DEFAULT @@ -18,14 +17,14 @@ _G.kCCTexture2DPixelFormat_RGBA8888 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 _G.kCCTexture2DPixelFormat_RGB888 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 _G.kCCTexture2DPixelFormat_RGB565 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 _G.kCCTexture2DPixelFormat_A8 = cc.TEXTURE2_D_PIXEL_FORMAT_A8 -_G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8 +_G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8 _G.kCCTexture2DPixelFormat_AI88 = cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 -_G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 -_G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 +_G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 +_G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 _G.kCCTexture2DPixelFormat_PVRTC4 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 _G.kCCTexture2DPixelFormat_PVRTC2 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 _G.kCCTexture2DPixelFormat_Default = cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT -_G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG +_G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG _G.kCCImageFormatJPEG = cc.IMAGE_FORMAT_JPEG _G.kCCTouchesOneByOne = cc.TOUCHES_ONE_BY_ONE _G.kCCTouchesAllAtOnce = cc.TOUCHES_ALL_AT_ONCE @@ -35,18 +34,18 @@ _G.kCCTransitionOrientationUpOver = cc.TRANSITION_ORIENTATION_UP_OVER _G.kCCTransitionOrientationDownOver = cc.TRANSITION_ORIENTATION_DOWN_OVER _G.kCCActionTagInvalid = cc.ACTION_TAG_INVALID _G.kCCLabelAutomaticWidth = cc.LABEL_AUTOMATIC_WIDTH -_G.kCCMenuStateWaiting = cc.MENU_STATE_WAITING +_G.kCCMenuStateWaiting = cc.MENU_STATE_WAITING _G.kCCMenuStateTrackingTouch = cc.MENU_STATE_TRACKING_TOUCH _G.kCCMenuHandlerPriority = cc.MENU_HANDLER_PRIORITY -_G.kCCParticleDurationInfinity = cc.PARTICLE_DURATION_INFINITY -_G.kCCParticleStartSizeEqualToEndSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE +_G.kCCParticleDurationInfinity = cc.PARTICLE_DURATION_INFINITY +_G.kCCParticleStartSizeEqualToEndSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE _G.kCCParticleStartRadiusEqualToEndRadius = cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS _G.kCCParticleModeGravity = cc.PARTICLE_MODE_GRAVITY _G.kCCParticleModeRadius = cc.PARTICLE_MODE_RADIUS -_G.kCCPositionTypeFree = cc.POSITION_TYPE_FREE +_G.kCCPositionTypeFree = cc.POSITION_TYPE_FREE _G.kCCPositionTypeRelative = cc.POSITION_TYPE_RELATIVE _G.kCCPositionTypeGrouped = cc.POSITION_TYPE_GROUPED -_G.kCCProgressTimerTypeRadial = cc.PROGRESS_TIMER_TYPE_RADIAL +_G.kCCProgressTimerTypeRadial = cc.PROGRESS_TIMER_TYPE_RADIAL _G.kCCProgressTimerTypeBar = cc.PROGRESS_TIMER_TYPE_BAR _G.kCCTMXTileHorizontalFlag = cc.TMX_TILE_HORIZONTAL_FLAG _G.kCCTMXTileVerticalFlag = cc.TMX_TILE_VERTICAL_FLAG @@ -54,9 +53,9 @@ _G.kCCTMXTileDiagonalFlag = cc.TMX_TILE_DIAGONAL_FLAG _G.kCCFlipedAll = cc.FLIPED_ALL _G.kCCFlippedMask = cc.FLIPPED_MASK -_G.kLanguageEnglish = cc.LANGUAGE_ENGLISH -_G.kLanguageChinese = cc.LANGUAGE_CHINESE -_G.kLanguageFrench = cc.LANGUAGE_FRENCH +_G.kLanguageEnglish = cc.LANGUAGE_ENGLISH +_G.kLanguageChinese = cc.LANGUAGE_CHINESE +_G.kLanguageFrench = cc.LANGUAGE_FRENCH _G.kLanguageItalian = cc.LANGUAGE_ITALIAN _G.kLanguageGerman = cc.LANGUAGE_GERMAN _G.kLanguageSpanish = cc.LANGUAGE_SPANISH @@ -67,21 +66,21 @@ _G.kLanguageHungarian = cc.LANGUAGE_HUNGARIAN _G.kLanguagePortuguese = cc.LANGUAGE_PORTUGUESE _G.kLanguageArabic = cc.LANGUAGE_ARABIC _G.kTargetWindows = cc.PLATFORM_OS_WINDOWS -_G.kTargetLinux = cc.PLATFORM_OS_LINUX +_G.kTargetLinux = cc.PLATFORM_OS_LINUX _G.kTargetMacOS = cc.PLATFORM_OS_MAC _G.kTargetAndroid = cc.PLATFORM_OS_ANDROID _G.kTargetIphone = cc.PLATFORM_OS_IPHONE -_G.kTargetIpad = cc.PLATFORM_OS_IPAD +_G.kTargetIpad = cc.PLATFORM_OS_IPAD _G.kTargetBlackBerry = cc.PLATFORM_OS_BLACKBERRY _G.GL_ZERO = gl.ZERO _G.GL_ONE = gl.ONE _G.GL_SRC_COLOR = gl.SRC_COLOR -_G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR -_G.GL_SRC_ALPHA = gl.SRC_ALPHA +_G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR +_G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_DST_ALPHA = gl.DST_ALPHA -_G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA +_G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT diff --git a/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dFunc.lua b/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dFunc.lua index b0e065a8ee..18e3fa684f 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dFunc.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dFunc.lua @@ -1,10 +1,9 @@ -require "Cocos2d.lua" + --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end - --functions of CCDirector will be deprecated,begin local CCDirectorDeprecated = { } function CCDirectorDeprecated.sharedDirector() @@ -308,7 +307,7 @@ rawset(_G,"ccc3",ccc3) local function ccp(x,y) deprecatedTip("ccp(x,y)","cc.p(x,y)") return cc.p(x,y) -end +end rawset(_G,"ccp",ccp) local function CCSizeMake(width,height) @@ -337,7 +336,7 @@ rawset(_G,"ccc4f",ccc4f) local function ccc4FFromccc4B(color4B) deprecatedTip("ccc4FFromccc4B(color4B)","cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)") - return cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0) + return cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0) end rawset(_G,"ccc4FFromccc4B",ccc4FFromccc4B) @@ -360,7 +359,7 @@ rawset(_G,"ccpLineIntersect",ccpLineIntersect) local function CCPointMake(x,y) deprecatedTip("CCPointMake(x,y)","cc.p(x,y)") return cc.p(x,y) -end +end rawset(_G,"CCPointMake",CCPointMake) @@ -494,7 +493,7 @@ rawset(_G,"ccpFromSize",ccpFromSize) local function ccpLerp(pt1,pt2,alpha) deprecatedTip("ccpLerp","cc.pLerp") - return cc.pLerp(pt1,pt2,alpha) + return cc.pLerp(pt1,pt2,alpha) end rawset(_G,"ccpLerp",ccpLerp) @@ -557,11 +556,11 @@ local function tex2(u,v) deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") return cc.tex2f(u,v) end -rawset(_G,"tex2",tex2) +rawset(_G,"tex2",tex2) local function ccc4BFromccc4F(color4F) deprecatedTip("ccc4BFromccc4F(color4F)","Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)") - return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0) + return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0) end rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F) diff --git a/cocos/scripting/lua-bindings/script/cocos2d/DrawPrimitives.lua b/cocos/scripting/lua-bindings/script/cocos2d/DrawPrimitives.lua index 1171947577..5d594cf9df 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/DrawPrimitives.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/DrawPrimitives.lua @@ -1,3 +1,4 @@ + local dp_initialized = false local dp_shader = nil local dp_colorLocation = -1 @@ -31,7 +32,7 @@ end local function setDrawProperty() gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) dp_shader:use() - dp_shader:setUniformsForBuiltins() + dp_shader:setUniformsForBuiltins() dp_shader:setUniformLocationWith4fv(dp_colorLocation, dp_color, 1) end @@ -204,7 +205,7 @@ function ccDrawSolidPoly(points,numOfPoints,color) gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) dp_shader:use() - dp_shader:setUniformsForBuiltins() + dp_shader:setUniformsForBuiltins() dp_shader:setUniformLocationWith4fv(dp_colorLocation, color, 1) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) @@ -316,7 +317,7 @@ function ccDrawQuadBezier(origin, control, destination, segments) local vertexBuffer = { } local function initBuffer() - local vertices = { } + local vertices = { } local i = 1 local t = 0.0 @@ -325,7 +326,7 @@ function ccDrawQuadBezier(origin, control, destination, segments) vertices[2 * i] = math.pow(1 - t,2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y t = t + 1.0 / segments end - + vertices[2 * (segments + 1) - 1] = destination.x vertices[2 * (segments + 1)] = destination.y @@ -353,7 +354,7 @@ function ccDrawCubicBezier(origin, control1, control2, destination, segments) local vertexBuffer = { } local function initBuffer() - local vertices = { } + local vertices = { } local t = 0 local i = 1 diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Opengl.lua b/cocos/scripting/lua-bindings/script/cocos2d/Opengl.lua index 4f70703093..74655234e8 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Opengl.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Opengl.lua @@ -1,6 +1,5 @@ -require "OpenglConstants" -gl = gl or {} +if not gl then return end --Create functions function gl.createTexture() @@ -112,7 +111,7 @@ function gl.bindTexture(target, texture) end gl._bindTexture(target,texture_id) -end +end function gl.bindBuffer( target,buffer ) local buffer_id = 0 @@ -211,7 +210,7 @@ function gl.linkProgram( program ) gl._linkProgram(program_id) end -function gl.getProgramParameter(program, e) +function gl.getProgramParameter(program, e) local program_id = 0 if "number" == type(program) then @@ -296,4 +295,3 @@ end function gl.glNodeCreate() return cc.GLNode:create() end - diff --git a/cocos/scripting/lua-bindings/script/cocos2d/OpenglConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/OpenglConstants.lua index 858d30a1cf..15adb23749 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/OpenglConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/OpenglConstants.lua @@ -1,5 +1,5 @@ ---Encapsulate opengl constants. -gl = gl or {} + +if not gl then return end gl.GCCSO_SHADER_BINARY_FJ = 0x9260 gl._3DC_XY_AMD = 0x87fa @@ -822,3 +822,5 @@ gl.WRITEONLY_RENDERING_QCOM = 0x8823 gl.WRITE_ONLY_OES = 0x88b9 gl.Z400_BINARY_AMD = 0x8740 gl.ZERO = 0x0 +gl.VERTEX_ATTRIB_POINTER_VEC3 = 0 +gl.VERTEX_ATTRIB_POINTER_COLOR4B = 1 diff --git a/cocos/scripting/lua-bindings/script/cocos2d/bitExtend.lua b/cocos/scripting/lua-bindings/script/cocos2d/bitExtend.lua index 1f152bb895..fe024aa160 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/bitExtend.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/bitExtend.lua @@ -2,15 +2,16 @@ bit = bit or {} bit.data32 = {} + for i=1,32 do bit.data32[i]=2^(32-i) end -function bit._b2d(arg) - local nr=0 +function bit._b2d(arg) + local nr=0 for i=1,32 do if arg[i] ==1 then - nr=nr+bit.data32[i] + nr=nr+bit.data32[i] end end return nr @@ -18,23 +19,23 @@ end function bit._d2b(arg) arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1) - local tr={} + local tr={} for i=1,32 do if arg >= bit.data32[i] then - tr[i]=1 - arg=arg-bit.data32[i] + tr[i]=1 + arg=arg-bit.data32[i] else - tr[i]=0 + tr[i]=0 end end return tr end function bit._and(a,b) - local op1=bit._d2b(a) - local op2=bit._d2b(b) - local r={} - + local op1=bit._d2b(a) + local op2=bit._d2b(b) + local r={} + for i=1,32 do if op1[i]==1 and op2[i]==1 then r[i]=1 @@ -43,11 +44,11 @@ function bit._and(a,b) end end return bit._b2d(r) - + end function bit._rshift(a,n) - local op1=bit._d2b(a) + local op1=bit._d2b(a) n = n <= 32 and n or 32 n = n >= 0 and n or 0 @@ -57,13 +58,13 @@ function bit._rshift(a,n) for i=1, n do op1[i] = 0 end - + return bit._b2d(op1) end -function bit._not(a) - local op1=bit._d2b(a) - local r={} +function bit._not(a) + local op1=bit._d2b(a) + local r={} for i=1,32 do if op1[i]==1 then @@ -72,14 +73,14 @@ function bit._not(a) r[i]=1 end end - return bit._b2d(r) + return bit._b2d(r) end function bit._or(a,b) - local op1=bit._d2b(a) - local op2=bit._d2b(b) - local r={} - + local op1=bit._d2b(a) + local op2=bit._d2b(b) + local r={} + for i=1,32 do if op1[i]==1 or op2[i]==1 then r[i]=1 @@ -87,9 +88,9 @@ function bit._or(a,b) r[i]=0 end end - return bit._b2d(r) + return bit._b2d(r) end -bit.band = bit.band or bit._and +bit.band = bit.band or bit._and bit.rshift = bit.rshift or bit._rshift -bit.bnot = bit.bnot or bit._not \ No newline at end of file +bit.bnot = bit.bnot or bit._not diff --git a/cocos/scripting/lua-bindings/script/cocos2d/extern.lua b/cocos/scripting/lua-bindings/script/cocos2d/extern.lua index 61c47e30df..2c6687c55e 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/extern.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/extern.lua @@ -1,3 +1,4 @@ + function clone(object) local lookup_table = {} local function _copy(object) @@ -90,4 +91,3 @@ function performWithDelay(node, callback, delay) node:runAction(sequence) return sequence end - diff --git a/cocos/scripting/lua-bindings/script/cocos2d/json.lua b/cocos/scripting/lua-bindings/script/cocos2d/json.lua index e0b3d17c3e..0192c34eb7 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/json.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/json.lua @@ -18,7 +18,7 @@ -- compat-5.1 if using Lua 5.0 -- -- CHANGELOG --- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix). +-- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix). -- Fixed Lua 5.1 compatibility issues. -- Introduced json.null to have null values in associative arrays. -- encode() performance improvement (more than 50%) through table.concat rather than .. @@ -65,19 +65,19 @@ function encode (v) if v==nil then return "null" end - - local vtype = base.type(v) + + local vtype = base.type(v) -- Handle strings - if vtype=='string' then + if vtype=='string' then return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string end - + -- Handle booleans if vtype=='number' or vtype=='boolean' then return base.tostring(v) end - + -- Handle tables if vtype=='table' then local rval = {} @@ -100,12 +100,12 @@ function encode (v) return '{' .. table.concat(rval,',') .. '}' end end - + -- Handle null values if vtype=='function' and v==null then return 'null' end - + base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v)) end @@ -191,14 +191,14 @@ function decode_scanComment(s, startPos) base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos) local endPos = string.find(s,'*/',startPos+2) base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos) - return endPos+2 + return endPos+2 end --- Scans for given constants: true, false or null -- Returns the appropriate Lua type, and the position of the next character to read. -- @param s The string being scanned. -- @param startPos The position in the string at which to start scanning. --- @return object, int The object (true, false or nil) and the position at which the next character should be +-- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } @@ -290,7 +290,7 @@ function decode_scanString(s,startPos) local stringLen = string.len(s) repeat local curChar = string.sub(s,endPos,endPos) - if not escaped then + if not escaped then if curChar==[[\]] then escaped = true else @@ -306,7 +306,7 @@ function decode_scanString(s,startPos) local stringValue = 'return ' .. string.sub(s, startPos, endPos-1) local stringEval = base.loadstring(stringValue) base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos) - return stringEval(), endPos + return stringEval(), endPos end --- Scans a JSON string skipping all whitespace from the current start position. @@ -334,7 +334,7 @@ function encodeString(s) s = string.gsub(s,"'","\\'") s = string.gsub(s,'\n','\\n') s = string.gsub(s,'\t','\\t') - return s + return s end -- Determines whether the given Lua type is an array or a table / dictionary. @@ -344,9 +344,9 @@ end -- @param t The table to evaluate as an array -- @return boolean, number True if the table can be represented as an array, false otherwise. If true, -- the second returned value is the maximum --- number of indexed elements in the array. +-- number of indexed elements in the array. function isArray(t) - -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable + -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable -- (with the possible exception of 'n') local maxIndex = 0 for k,v in base.pairs(t) do @@ -371,6 +371,6 @@ end -- @return boolean True if the object should be JSON encoded, false if it should be ignored. function isEncodable(o) local t = base.type(o) - return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) + return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) end diff --git a/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua b/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua index 9626275d8e..7a6f78967e 100644 --- a/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua +++ b/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua @@ -1,4 +1,5 @@ ---Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. + +--Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. local M = {} function M.stopAllEffects() @@ -105,16 +106,4 @@ function M.destroyInstance() return cc.SimpleAudioEngine:destroyInstance() end -local modename = "AudioEngine" -local proxy = {} -local mt = { - __index = M, - __newindex = function (t ,k ,v) - print("attemp to update a read-only table") - end -} -setmetatable(proxy,mt) -_G[modename] = proxy -package.loaded[modename] = proxy - - +AudioEngine = M diff --git a/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua b/cocos/scripting/lua-bindings/script/cocosstudio/CocosStudio.lua similarity index 98% rename from cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua rename to cocos/scripting/lua-bindings/script/cocosstudio/CocosStudio.lua index e0df56a60d..9bcf06144e 100644 --- a/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua +++ b/cocos/scripting/lua-bindings/script/cocosstudio/CocosStudio.lua @@ -1,11 +1,15 @@ -require "json" -require "extern" + +if not json then + require "cocos.cocos2d.json" +end ccs = ccs or {} +require "cocos.cocosstudio.StudioConstants" + function ccs.sendTriggerEvent(event) local triggerObjArr = ccs.TriggerMng.getInstance():get(event) - + if nil == triggerObjArr then return end @@ -106,7 +110,7 @@ end function ccs.TriggerObj:detect() if (not self._enable) or (table.getn(self._cons) == 0) then return true - end + end local ret = true local obj = nil @@ -355,7 +359,7 @@ end function ccs.TriggerMng:removeTriggerObj(id) local obj = self.getTriggerObj(id) - + if nil == obj then return false end diff --git a/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua b/cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioClass.lua similarity index 100% rename from cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua rename to cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioClass.lua diff --git a/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua b/cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioFunc.lua similarity index 100% rename from cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua rename to cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioFunc.lua diff --git a/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua b/cocos/scripting/lua-bindings/script/cocosstudio/StudioConstants.lua similarity index 77% rename from cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua rename to cocos/scripting/lua-bindings/script/cocosstudio/StudioConstants.lua index 5f9bca3036..0fc8fc7711 100644 --- a/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocosstudio/StudioConstants.lua @@ -1,8 +1,8 @@ -ccs = ccs or {} +ccs = ccs or {} ccs.MovementEventType = { start = 0, complete = 1, - loopComplete = 2, + loopComplete = 2, } diff --git a/cocos/scripting/lua-bindings/script/controller/ControllerConstants.lua b/cocos/scripting/lua-bindings/script/controller/ControllerConstants.lua index 074e254bfd..730e92afad 100644 --- a/cocos/scripting/lua-bindings/script/controller/ControllerConstants.lua +++ b/cocos/scripting/lua-bindings/script/controller/ControllerConstants.lua @@ -1,3 +1,4 @@ + cc = cc or {} cc.ControllerKey = @@ -13,7 +14,7 @@ cc.ControllerKey = BUTTON_X = 1007, BUTTON_Y = 1008, BUTTON_Z = 1009, - + BUTTON_DPAD_UP = 1010, BUTTON_DPAD_DOWN = 1011, BUTTON_DPAD_LEFT = 1012, diff --git a/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua b/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua index 16065e1790..1aa9634c54 100644 --- a/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua +++ b/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua @@ -1,3 +1,4 @@ + cc = cc or {} cc.CONTROL_STATE_NORMAL = 1 diff --git a/cocos/scripting/lua-bindings/script/init.lua b/cocos/scripting/lua-bindings/script/init.lua new file mode 100644 index 0000000000..c3fe6b93eb --- /dev/null +++ b/cocos/scripting/lua-bindings/script/init.lua @@ -0,0 +1,55 @@ + +require "cocos.cocos2d.Cocos2d" +require "cocos.cocos2d.Cocos2dConstants" +require "cocos.cocos2d.extern" + +-- opengl +require "cocos.cocos2d.Opengl" +require "cocos.cocos2d.OpenglConstants" + +-- cocosdenshion +require "cocos.cocosdenshion.AudioEngine" + +-- cocosstudio +require "cocos.cocosstudio.CocosStudio" + +-- ui +require "cocos.ui.GuiConstants" + +-- extensions +require "cocos.extension.ExtensionConstants" + +-- network +require "cocos.network.NetworkConstants" + +if CC_USE_DEPRECATED_API then + -- CCLuaEngine + require "cocos.cocos2d.DeprecatedCocos2dClass" + require "cocos.cocos2d.DeprecatedCocos2dEnum" + require "cocos.cocos2d.DeprecatedCocos2dFunc" + + -- register_cocostudio_module + require "cocos.cocosstudio.DeprecatedCocoStudioClass" + require "cocos.cocosstudio.DeprecatedCocoStudioFunc" + + -- register_cocosbuilder_module + require "cocos.cocosbuilder.DeprecatedCocosBuilderClass" + + -- register_cocosdenshion_module + require "cocos.cocosdenshion.DeprecatedCocosDenshionClass" + require "cocos.cocosdenshion.DeprecatedCocosDenshionFunc" + + -- register_extension_module + require "cocos.extension.DeprecatedExtensionClass" + require "cocos.extension.DeprecatedExtensionEnum" + require "cocos.extension.DeprecatedExtensionFunc" + + -- register_network_module + require "cocos.network.DeprecatedNetworkClass" + require "cocos.network.DeprecatedNetworkEnum" + require "cocos.network.DeprecatedNetworkFunc" + + -- register_ui_moudle + require "cocos.ui.DeprecatedUIEnum" + require "cocos.ui.DeprecatedUIFunc" +end diff --git a/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua b/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua index 0e7dd0004f..2311657a1a 100644 --- a/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua +++ b/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua @@ -1,3 +1,4 @@ + cc = cc or {} cc.WEBSOCKET_OPEN = 0 @@ -10,9 +11,8 @@ cc.WEBSOCKET_STATE_OPEN = 1 cc.WEBSOCKET_STATE_CLOSING = 2 cc.WEBSOCKET_STATE_CLOSED = 3 - -cc.XMLHTTPREQUEST_RESPONSE_STRING = 0 +cc.XMLHTTPREQUEST_RESPONSE_STRING = 0 cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1 -cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2 -cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3 -cc.XMLHTTPREQUEST_RESPONSE_JSON = 4 +cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2 +cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3 +cc.XMLHTTPREQUEST_RESPONSE_JSON = 4 diff --git a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua index bc3fc5a226..1fd5b4fe5c 100644 --- a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua +++ b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua @@ -1,92 +1,91 @@ -require("GuiConstants") -_G.LAYOUT_COLOR_NONE = ccui.LayoutBackGroundColorType.none -_G.LAYOUT_COLOR_SOLID = ccui.LayoutBackGroundColorType.solid -_G.LAYOUT_COLOR_GRADIENT = ccui.LayoutBackGroundColorType.gradient +LAYOUT_COLOR_NONE = ccui.LayoutBackGroundColorType.none +LAYOUT_COLOR_SOLID = ccui.LayoutBackGroundColorType.solid +LAYOUT_COLOR_GRADIENT = ccui.LayoutBackGroundColorType.gradient -_G.LAYOUT_ABSOLUTE = ccui.LayoutType.ABSOLUTE -_G.LAYOUT_LINEAR_VERTICAL = ccui.LayoutType.VERTICAL -_G.LAYOUT_LINEAR_HORIZONTAL = ccui.LayoutType.HORIZONTAL -_G.LAYOUT_RELATIVE = ccui.LayoutType.RELATIVE +LAYOUT_ABSOLUTE = ccui.LayoutType.ABSOLUTE +LAYOUT_LINEAR_VERTICAL = ccui.LayoutType.VERTICAL +LAYOUT_LINEAR_HORIZONTAL = ccui.LayoutType.HORIZONTAL +LAYOUT_RELATIVE = ccui.LayoutType.RELATIVE -_G.BRIGHT_NONE = ccui.BrightStyle.none -_G.BRIGHT_NORMAL = ccui.BrightStyle.normal -_G.BRIGHT_HIGHLIGHT = ccui.BrightStyle.highlight +BRIGHT_NONE = ccui.BrightStyle.none +BRIGHT_NORMAL = ccui.BrightStyle.normal +BRIGHT_HIGHLIGHT = ccui.BrightStyle.highlight -_G.UI_TEX_TYPE_LOCAL = ccui.TextureResType.localType -_G.UI_TEX_TYPE_PLIST = ccui.TextureResType.plistType +UI_TEX_TYPE_LOCAL = ccui.TextureResType.localType +UI_TEX_TYPE_PLIST = ccui.TextureResType.plistType -_G.TOUCH_EVENT_BEGAN = ccui.TouchEventType.began -_G.TOUCH_EVENT_MOVED = ccui.TouchEventType.moved -_G.TOUCH_EVENT_ENDED = ccui.TouchEventType.ended -_G.TOUCH_EVENT_CANCELED = ccui.TouchEventType.canceled - -_G.SIZE_ABSOLUTE = ccui.SizeType.absolute -_G.SIZE_PERCENT = ccui.SizeType.percent +TOUCH_EVENT_BEGAN = ccui.TouchEventType.began +TOUCH_EVENT_MOVED = ccui.TouchEventType.moved +TOUCH_EVENT_ENDED = ccui.TouchEventType.ended +TOUCH_EVENT_CANCELED = ccui.TouchEventType.canceled -_G.POSITION_ABSOLUTE = ccui.PositionType.absolute -_G.POSITION_PERCENT = ccui.PositionType.percent +SIZE_ABSOLUTE = ccui.SizeType.absolute +SIZE_PERCENT = ccui.SizeType.percent -_G.CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected -_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected +POSITION_ABSOLUTE = ccui.PositionType.absolute +POSITION_PERCENT = ccui.PositionType.percent -_G.CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected -_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected +CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected +CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected -_G.LoadingBarTypeLeft = ccui.LoadingBarDirection.LEFT -_G.LoadingBarTypeRight = ccui.LoadingBarDirection.RIGHT +CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected +CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected -_G.LoadingBarTypeRight = ccui.SliderEventType.percent_changed +LoadingBarTypeLeft = ccui.LoadingBarDirection.LEFT +LoadingBarTypeRight = ccui.LoadingBarDirection.RIGHT -_G.TEXTFIELD_EVENT_ATTACH_WITH_IME = ccui.TextFiledEventType.attach_with_ime -_G.TEXTFIELD_EVENT_DETACH_WITH_IME = ccui.TextFiledEventType.detach_with_ime -_G.TEXTFIELD_EVENT_INSERT_TEXT = ccui.TextFiledEventType.insert_text -_G.TEXTFIELD_EVENT_DELETE_BACKWARD = ccui.TextFiledEventType.delete_backward +LoadingBarTypeRight = ccui.SliderEventType.percent_changed -_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollViewDir.none -_G.SCROLLVIEW_DIR_VERTICAL = ccui.ScrollViewDir.vertical -_G.SCROLLVIEW_DIR_HORIZONTAL = ccui.ScrollViewDir.horizontal -_G.SCROLLVIEW_DIR_BOTH = ccui.ScrollViewDir.both +TEXTFIELD_EVENT_ATTACH_WITH_IME = ccui.TextFiledEventType.attach_with_ime +TEXTFIELD_EVENT_DETACH_WITH_IME = ccui.TextFiledEventType.detach_with_ime +TEXTFIELD_EVENT_INSERT_TEXT = ccui.TextFiledEventType.insert_text +TEXTFIELD_EVENT_DELETE_BACKWARD = ccui.TextFiledEventType.delete_backward -_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollviewEventType.scrollToTop -_G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccui.ScrollviewEventType.scrollToBottom -_G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccui.ScrollviewEventType.scrollToLeft -_G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccui.ScrollviewEventType.scrollToRight -_G.SCROLLVIEW_EVENT_SCROLLING = ccui.ScrollviewEventType.scrolling -_G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccui.ScrollviewEventType.bounceTop -_G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccui.ScrollviewEventType.bounceBottom -_G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccui.ScrollviewEventType.bounceLeft -_G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccui.ScrollviewEventType.bounceRight +SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollViewDir.none +SCROLLVIEW_DIR_VERTICAL = ccui.ScrollViewDir.vertical +SCROLLVIEW_DIR_HORIZONTAL = ccui.ScrollViewDir.horizontal +SCROLLVIEW_DIR_BOTH = ccui.ScrollViewDir.both -_G.PAGEVIEW_EVENT_TURNING = ccui.PageViewEventType.turning +SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollviewEventType.scrollToTop +SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccui.ScrollviewEventType.scrollToBottom +SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccui.ScrollviewEventType.scrollToLeft +SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccui.ScrollviewEventType.scrollToRight +SCROLLVIEW_EVENT_SCROLLING = ccui.ScrollviewEventType.scrolling +SCROLLVIEW_EVENT_BOUNCE_TOP = ccui.ScrollviewEventType.bounceTop +SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccui.ScrollviewEventType.bounceBottom +SCROLLVIEW_EVENT_BOUNCE_LEFT = ccui.ScrollviewEventType.bounceLeft +SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccui.ScrollviewEventType.bounceRight -_G.PAGEVIEW_TOUCHLEFT = ccui.PVTouchDir.touch_left -_G.PAGEVIEW_TOUCHRIGHT = ccui.PVTouchDir.touch_right +PAGEVIEW_EVENT_TURNING = ccui.PageViewEventType.turning -_G.LISTVIEW_DIR_NONE = ccui.ListViewDirection.none -_G.LISTVIEW_DIR_VERTICAL = ccui.ListViewDirection.vertical -_G.LISTVIEW_DIR_HORIZONTAL = ccui.ListViewDirection.horizontal +PAGEVIEW_TOUCHLEFT = ccui.PVTouchDir.touch_left +PAGEVIEW_TOUCHRIGHT = ccui.PVTouchDir.touch_right -_G.LISTVIEW_MOVE_DIR_NONE = ccui.ListViewMoveDirection.none -_G.LISTVIEW_MOVE_DIR_UP = ccui.ListViewMoveDirection.up -_G.LISTVIEW_MOVE_DIR_DOWN = ccui.ListViewMoveDirection.down -_G.LISTVIEW_MOVE_DIR_LEFT = ccui.ListViewMoveDirection.left -_G.LISTVIEW_MOVE_DIR_RIGHT = ccui.ListViewMoveDirection.right +LISTVIEW_DIR_NONE = ccui.ListViewDirection.none +LISTVIEW_DIR_VERTICAL = ccui.ListViewDirection.vertical +LISTVIEW_DIR_HORIZONTAL = ccui.ListViewDirection.horizontal -_G.LISTVIEW_EVENT_INIT_CHILD = ccui.ListViewEventType.init_child -_G.LISTVIEW_EVENT_UPDATE_CHILD = ccui.ListViewEventType.update_child +LISTVIEW_MOVE_DIR_NONE = ccui.ListViewMoveDirection.none +LISTVIEW_MOVE_DIR_UP = ccui.ListViewMoveDirection.up +LISTVIEW_MOVE_DIR_DOWN = ccui.ListViewMoveDirection.down +LISTVIEW_MOVE_DIR_LEFT = ccui.ListViewMoveDirection.left +LISTVIEW_MOVE_DIR_RIGHT = ccui.ListViewMoveDirection.right -_G.LAYOUT_PARAMETER_NONE = ccui.LayoutParameterType.none -_G.LAYOUT_PARAMETER_LINEAR = ccui.LayoutParameterType.linear -_G.LAYOUT_PARAMETER_RELATIVE = ccui.LayoutParameterType.relative +LISTVIEW_EVENT_INIT_CHILD = ccui.ListViewEventType.init_child +LISTVIEW_EVENT_UPDATE_CHILD = ccui.ListViewEventType.update_child -ccui.LoadingBarType = ccui.LoadingBarDirection -ccui.LoadingBarType.left = ccui.LoadingBarDirection.LEFT -ccui.LoadingBarType.right = ccui.LoadingBarDirection.RIGHT +LAYOUT_PARAMETER_NONE = ccui.LayoutParameterType.none +LAYOUT_PARAMETER_LINEAR = ccui.LayoutParameterType.linear +LAYOUT_PARAMETER_RELATIVE = ccui.LayoutParameterType.relative -ccui.LayoutType.absolute = ccui.LayoutType.ABSOLUTE -ccui.LayoutType.linearVertical = ccui.LayoutType.VERTICAL -ccui.LayoutType.linearHorizontal = ccui.LayoutType.HORIZONTAL -ccui.LayoutType.relative = ccui.LayoutType.RELATIVE +ccui.LoadingBarType = ccui.LoadingBarDirection +ccui.LoadingBarType.left = ccui.LoadingBarDirection.LEFT +ccui.LoadingBarType.right = ccui.LoadingBarDirection.RIGHT -ccui.ListViewEventType.onsSelectedItem = ccui.ListViewEventType.ONSELECTEDITEM_START \ No newline at end of file +ccui.LayoutType.absolute = ccui.LayoutType.ABSOLUTE +ccui.LayoutType.linearVertical = ccui.LayoutType.VERTICAL +ccui.LayoutType.linearHorizontal = ccui.LayoutType.HORIZONTAL +ccui.LayoutType.relative = ccui.LayoutType.RELATIVE + +ccui.ListViewEventType.onsSelectedItem = ccui.ListViewEventType.ONSELECTEDITEM_START diff --git a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua index 1b3ce7e439..1ebcaac88d 100644 --- a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua +++ b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua @@ -1,19 +1,20 @@ + ccui = ccui or {} -ccui.BrightStyle = +ccui.BrightStyle = { none = -1, normal = 0, highlight = 1, } -ccui.TextureResType = +ccui.TextureResType = { localType = 0, plistType = 1, } -ccui.TouchEventType = +ccui.TouchEventType = { began = 0, moved = 1, @@ -21,7 +22,7 @@ ccui.TouchEventType = canceled = 3, } -ccui.SizeType = +ccui.SizeType = { absolute = 0, percent = 1, @@ -32,13 +33,13 @@ ccui.PositionType = { percent = 1, } -ccui.CheckBoxEventType = +ccui.CheckBoxEventType = { selected = 0, unselected = 1, } -ccui.TextFiledEventType = +ccui.TextFiledEventType = { attach_with_ime = 0, detach_with_ime = 1, @@ -46,14 +47,14 @@ ccui.TextFiledEventType = delete_backward = 3, } -ccui.LayoutBackGroundColorType = +ccui.LayoutBackGroundColorType = { none = 0, solid = 1, gradient = 2, } -ccui.LayoutType = +ccui.LayoutType = { ABSOLUTE = 0, VERTICAL = 1, @@ -61,14 +62,14 @@ ccui.LayoutType = RELATIVE = 3, } -ccui.LayoutParameterType = +ccui.LayoutParameterType = { none = 0, linear = 1, relative = 2, } -ccui.LinearGravity = +ccui.LinearGravity = { none = 0, left = 1, @@ -79,7 +80,7 @@ ccui.LinearGravity = centerHorizontal = 6, } -ccui.RelativeAlign = +ccui.RelativeAlign = { alignNone = 0, alignParentTopLeft = 1, @@ -156,7 +157,7 @@ ccui.ListViewEventType = { } ccui.PageViewEventType = { - turning = 0, + turning = 0, } ccui.PVTouchDir = { diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 8e938366c4..0edd37554a 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -638,6 +638,11 @@ void Button::setPressedActionEnabled(bool enabled) void Button::setTitleText(const std::string& text) { _titleRenderer->setString(text); + if (_ignoreSize) + { + Size s = getVirtualRendererSize(); + this->setContentSize(s); + } } const std::string& Button::getTitleText() const diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm b/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm index 05822f197e..e6f1e3e884 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm @@ -34,6 +34,60 @@ #define getEditBoxImplMac() ((cocos2d::ui::EditBoxImplMac*)editBox_) +@interface CustomTextFieldFormatter : NSFormatter { + int maxLength; +} +- (void)setMaximumLength:(int)len; +- (int)maximumLength; + +@end + +@implementation CustomTextFieldFormatter + +- (id)init { + + if(self = [super init]){ + + maxLength = INT_MAX; + } + + return self; +} + +- (void)setMaximumLength:(int)len { + maxLength = len; +} + +- (int)maximumLength { + return maxLength; +} + +- (NSString *)stringForObjectValue:(id)object { + return (NSString *)object; +} + +- (BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error { + *object = string; + return YES; +} + +- (BOOL)isPartialStringValid:(NSString **)partialStringPtr + proposedSelectedRange:(NSRangePointer)proposedSelRangePtr + originalString:(NSString *)origString + originalSelectedRange:(NSRange)origSelRange + errorDescription:(NSString **)error { + if ([*partialStringPtr length] > maxLength) { + return NO; + } + + return YES; +} + +- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes { + return nil; +} + +@end @implementation UIEditBoxImplMac @@ -206,28 +260,6 @@ #endif } -/** - * Delegate method called before the text has been changed. - * @param textField The text field containing the text. - * @param range The range of characters to be replaced. - * @param string The replacement string. - * @return YES if the specified text range should be replaced; otherwise, NO to keep the old text. - */ -- (BOOL)textField:(NSTextField *) textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string -{ - if (getEditBoxImplMac()->getMaxLength() < 0) - { - return YES; - } - - NSUInteger oldLength = [[textField stringValue] length]; - NSUInteger replacementLength = [string length]; - NSUInteger rangeLength = range.length; - - NSUInteger newLength = oldLength - rangeLength + replacementLength; - - return newLength <= getEditBoxImplMac()->getMaxLength(); -} /** * Called each time when the text field's text has changed. @@ -364,6 +396,10 @@ void EditBoxImplMac::setInputMode(EditBox::InputMode inputMode) void EditBoxImplMac::setMaxLength(int maxLength) { _maxTextLength = maxLength; + id formater = [[[CustomTextFieldFormatter alloc]init] autorelease]; + [formater setMaximumLength:maxLength]; + [_sysEdit.secureTextField setFormatter:formater]; + [_sysEdit.textField setFormatter:formater]; } int EditBoxImplMac::getMaxLength() diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 10107a69c0..e9d1aecbfe 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -828,7 +828,7 @@ y+=ytranslate; \ void Scale9Sprite::setSpriteFrame(SpriteFrame * spriteFrame, const Rect& capInsets) { Sprite * sprite = Sprite::createWithTexture(spriteFrame->getTexture()); - this->updateWithSprite(sprite, spriteFrame->getRect(), spriteFrame->isRotated(), spriteFrame->getOffset(), spriteFrame->getOriginalSize(), Rect::ZERO); + this->updateWithSprite(sprite, spriteFrame->getRect(), spriteFrame->isRotated(), spriteFrame->getOffset(), spriteFrame->getOriginalSize(), capInsets); // Reset insets this->_insetLeft = capInsets.origin.x; diff --git a/external/config.json b/external/config.json index bea2813538..bb6831839a 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-12", + "version":"v3-deps-14", "zip_file_size":"70810291", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 3352af24e8..ac4efb2235 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -2148,6 +2148,8 @@ "external/unzip/CMakeLists.txt", "external/unzip/ioapi.cpp", "external/unzip/ioapi.h", + "external/unzip/ioapi_mem.cpp", + "external/unzip/ioapi_mem.h", "external/unzip/unzip.cpp", "external/unzip/unzip.h", "external/version.json", @@ -4124,7 +4126,6 @@ ], "lua": [ "cocos/scripting/lua-bindings/CMakeLists.txt", - "cocos/scripting/lua-bindings/auto/api/AABB.lua", "cocos/scripting/lua-bindings/auto/api/Action.lua", "cocos/scripting/lua-bindings/auto/api/ActionCamera.lua", "cocos/scripting/lua-bindings/auto/api/ActionEase.lua", @@ -4331,7 +4332,6 @@ "cocos/scripting/lua-bindings/auto/api/Node.lua", "cocos/scripting/lua-bindings/auto/api/NodeGrid.lua", "cocos/scripting/lua-bindings/auto/api/NodeReader.lua", - "cocos/scripting/lua-bindings/auto/api/OBB.lua", "cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua", "cocos/scripting/lua-bindings/auto/api/PageTurn3D.lua", "cocos/scripting/lua-bindings/auto/api/PageView.lua", @@ -4640,15 +4640,16 @@ "cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua", "cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua", "cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua", - "cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua", - "cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua", - "cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua", - "cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua", + "cocos/scripting/lua-bindings/script/cocosstudio/CocosStudio.lua", + "cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioClass.lua", + "cocos/scripting/lua-bindings/script/cocosstudio/DeprecatedCocoStudioFunc.lua", + "cocos/scripting/lua-bindings/script/cocosstudio/StudioConstants.lua", "cocos/scripting/lua-bindings/script/controller/ControllerConstants.lua", "cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua", "cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua", "cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua", "cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua", + "cocos/scripting/lua-bindings/script/init.lua", "cocos/scripting/lua-bindings/script/network/DeprecatedNetworkClass.lua", "cocos/scripting/lua-bindings/script/network/DeprecatedNetworkEnum.lua", "cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua", diff --git a/templates/lua-template-default/cocos-project-template.json b/templates/lua-template-default/cocos-project-template.json index 0eac97ab0f..2a4a631992 100644 --- a/templates/lua-template-default/cocos-project-template.json +++ b/templates/lua-template-default/cocos-project-template.json @@ -2,6 +2,53 @@ "do_default":{ "exclude_from_template":[ "frameworks/runtime-src" + ], + "append_dir": [ + { + "from": "cocos/scripting/lua-bindings/script", + "to": "src/cocos", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/cocos2d", + "to": "src/cocos/cocos2d", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/cocosbuilder", + "to": "src/cocos/cocosbuilder", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/cocosdenshion", + "to": "src/cocos/cocosdenshion", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/cocosstudio", + "to": "src/cocos/cocosstudio", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/controller", + "to": "src/cocos/controller", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/extension", + "to": "src/cocos/extension", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/network", + "to": "src/cocos/network", + "exclude": [] + }, + { + "from": "cocos/scripting/lua-bindings/script/ui", + "to": "src/cocos/ui", + "exclude": [] + } ] }, "do_add_native_support":{ diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/build-cfg.json b/templates/lua-template-default/frameworks/runtime-src/proj.android/build-cfg.json index 82ee655658..e63488b974 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/build-cfg.json +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/build-cfg.json @@ -14,37 +14,9 @@ "from": "../../../res", "to": "res" }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosdenshion", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosbuilder", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocostudio", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/extension", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/network", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/ui", - "to": "" - }, { "from": "../../cocos2d-x/external/lua/luasocket", - "to": "", + "to": "src", "include": [ "*.lua" ] diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj index 98383bf5e2..945c790335 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj +++ b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj @@ -13,77 +13,7 @@ 15427C79198F1FA200DC375D /* libluacocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15427C49198F1DE400DC375D /* libluacocos2d Mac.a */; }; 15A8A4491834C64F00142BE0 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810C17EBBCAC00990C9B /* Icon-114.png */; }; 15A8A4881834C90F00142BE0 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4871834C90E00142BE0 /* libcurl.dylib */; }; - 15AA96B6199C668400725633 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96B4199C668400725633 /* CCBReaderLoad.lua */; }; - 15AA96B7199C668400725633 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96B4199C668400725633 /* CCBReaderLoad.lua */; }; - 15AA96B8199C668400725633 /* DeprecatedCocosBuilderClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96B5199C668400725633 /* DeprecatedCocosBuilderClass.lua */; }; - 15AA96B9199C668400725633 /* DeprecatedCocosBuilderClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96B5199C668400725633 /* DeprecatedCocosBuilderClass.lua */; }; - 15AA96BE199C66A100725633 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BA199C66A100725633 /* CocoStudio.lua */; }; - 15AA96BF199C66A100725633 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BA199C66A100725633 /* CocoStudio.lua */; }; - 15AA96C0199C66A100725633 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BB199C66A100725633 /* DeprecatedCocoStudioClass.lua */; }; - 15AA96C1199C66A100725633 /* DeprecatedCocoStudioClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BB199C66A100725633 /* DeprecatedCocoStudioClass.lua */; }; - 15AA96C2199C66A100725633 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BC199C66A100725633 /* DeprecatedCocoStudioFunc.lua */; }; - 15AA96C3199C66A100725633 /* DeprecatedCocoStudioFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BC199C66A100725633 /* DeprecatedCocoStudioFunc.lua */; }; - 15AA96C4199C66A100725633 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BD199C66A100725633 /* StudioConstants.lua */; }; - 15AA96C5199C66A100725633 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96BD199C66A100725633 /* StudioConstants.lua */; }; - 15AA96CA199C66B500725633 /* DeprecatedExtensionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C6199C66B500725633 /* DeprecatedExtensionClass.lua */; }; - 15AA96CB199C66B500725633 /* DeprecatedExtensionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C6199C66B500725633 /* DeprecatedExtensionClass.lua */; }; - 15AA96CC199C66B500725633 /* DeprecatedExtensionEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C7199C66B500725633 /* DeprecatedExtensionEnum.lua */; }; - 15AA96CD199C66B500725633 /* DeprecatedExtensionEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C7199C66B500725633 /* DeprecatedExtensionEnum.lua */; }; - 15AA96CE199C66B500725633 /* DeprecatedExtensionFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C8199C66B500725633 /* DeprecatedExtensionFunc.lua */; }; - 15AA96CF199C66B500725633 /* DeprecatedExtensionFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C8199C66B500725633 /* DeprecatedExtensionFunc.lua */; }; - 15AA96D0199C66B500725633 /* ExtensionConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C9199C66B500725633 /* ExtensionConstants.lua */; }; - 15AA96D1199C66B500725633 /* ExtensionConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96C9199C66B500725633 /* ExtensionConstants.lua */; }; - 15AA96D6199C66D500725633 /* DeprecatedNetworkClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D2199C66D500725633 /* DeprecatedNetworkClass.lua */; }; - 15AA96D7199C66D500725633 /* DeprecatedNetworkClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D2199C66D500725633 /* DeprecatedNetworkClass.lua */; }; - 15AA96D8199C66D500725633 /* DeprecatedNetworkEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D3199C66D500725633 /* DeprecatedNetworkEnum.lua */; }; - 15AA96D9199C66D500725633 /* DeprecatedNetworkEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D3199C66D500725633 /* DeprecatedNetworkEnum.lua */; }; - 15AA96DA199C66D500725633 /* DeprecatedNetworkFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D4199C66D500725633 /* DeprecatedNetworkFunc.lua */; }; - 15AA96DB199C66D500725633 /* DeprecatedNetworkFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D4199C66D500725633 /* DeprecatedNetworkFunc.lua */; }; - 15AA96DC199C66D500725633 /* NetworkConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D5199C66D500725633 /* NetworkConstants.lua */; }; - 15AA96DD199C66D500725633 /* NetworkConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96D5199C66D500725633 /* NetworkConstants.lua */; }; - 15AA96E2199C66E600725633 /* DeprecatedUIEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96DE199C66E600725633 /* DeprecatedUIEnum.lua */; }; - 15AA96E3199C66E600725633 /* DeprecatedUIEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96DE199C66E600725633 /* DeprecatedUIEnum.lua */; }; - 15AA96E4199C66E600725633 /* DeprecatedUIFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96DF199C66E600725633 /* DeprecatedUIFunc.lua */; }; - 15AA96E5199C66E600725633 /* DeprecatedUIFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96DF199C66E600725633 /* DeprecatedUIFunc.lua */; }; - 15AA96E6199C66E600725633 /* experimentalUIConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96E0199C66E600725633 /* experimentalUIConstants.lua */; }; - 15AA96E7199C66E600725633 /* experimentalUIConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96E0199C66E600725633 /* experimentalUIConstants.lua */; }; - 15AA96E8199C66E600725633 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96E1199C66E600725633 /* GuiConstants.lua */; }; - 15AA96E9199C66E600725633 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AA96E1199C66E600725633 /* GuiConstants.lua */; }; 15AECE29195D482800907DB0 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15AECE28195D482800907DB0 /* MediaPlayer.framework */; }; - 15D1FE491998730800302043 /* bitExtend.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3B1998730800302043 /* bitExtend.lua */; }; - 15D1FE4A1998730800302043 /* bitExtend.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3B1998730800302043 /* bitExtend.lua */; }; - 15D1FE4B1998730800302043 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3C1998730800302043 /* Cocos2d.lua */; }; - 15D1FE4C1998730800302043 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3C1998730800302043 /* Cocos2d.lua */; }; - 15D1FE4D1998730800302043 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3D1998730800302043 /* Cocos2dConstants.lua */; }; - 15D1FE4E1998730800302043 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3D1998730800302043 /* Cocos2dConstants.lua */; }; - 15D1FE4F1998730800302043 /* DeprecatedCocos2dClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3E1998730800302043 /* DeprecatedCocos2dClass.lua */; }; - 15D1FE501998730800302043 /* DeprecatedCocos2dClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3E1998730800302043 /* DeprecatedCocos2dClass.lua */; }; - 15D1FE511998730800302043 /* DeprecatedCocos2dEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3F1998730800302043 /* DeprecatedCocos2dEnum.lua */; }; - 15D1FE521998730800302043 /* DeprecatedCocos2dEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE3F1998730800302043 /* DeprecatedCocos2dEnum.lua */; }; - 15D1FE531998730800302043 /* DeprecatedCocos2dFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE401998730800302043 /* DeprecatedCocos2dFunc.lua */; }; - 15D1FE541998730800302043 /* DeprecatedCocos2dFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE401998730800302043 /* DeprecatedCocos2dFunc.lua */; }; - 15D1FE551998730800302043 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE411998730800302043 /* DeprecatedOpenglEnum.lua */; }; - 15D1FE561998730800302043 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE411998730800302043 /* DeprecatedOpenglEnum.lua */; }; - 15D1FE571998730800302043 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE421998730800302043 /* DrawPrimitives.lua */; }; - 15D1FE581998730800302043 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE421998730800302043 /* DrawPrimitives.lua */; }; - 15D1FE591998730800302043 /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE431998730800302043 /* extern.lua */; }; - 15D1FE5A1998730800302043 /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE431998730800302043 /* extern.lua */; }; - 15D1FE5B1998730800302043 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE441998730800302043 /* json.lua */; }; - 15D1FE5C1998730800302043 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE441998730800302043 /* json.lua */; }; - 15D1FE5D1998730800302043 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE451998730800302043 /* luaj.lua */; }; - 15D1FE5E1998730800302043 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE451998730800302043 /* luaj.lua */; }; - 15D1FE5F1998730800302043 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE461998730800302043 /* luaoc.lua */; }; - 15D1FE601998730800302043 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE461998730800302043 /* luaoc.lua */; }; - 15D1FE611998730800302043 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE471998730800302043 /* Opengl.lua */; }; - 15D1FE621998730800302043 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE471998730800302043 /* Opengl.lua */; }; - 15D1FE631998730800302043 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE481998730800302043 /* OpenglConstants.lua */; }; - 15D1FE641998730800302043 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE481998730800302043 /* OpenglConstants.lua */; }; - 15D1FE681998732700302043 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE651998732700302043 /* AudioEngine.lua */; }; - 15D1FE691998732700302043 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE651998732700302043 /* AudioEngine.lua */; }; - 15D1FE6A1998732700302043 /* DeprecatedCocosDenshionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE661998732700302043 /* DeprecatedCocosDenshionClass.lua */; }; - 15D1FE6B1998732700302043 /* DeprecatedCocosDenshionClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE661998732700302043 /* DeprecatedCocosDenshionClass.lua */; }; - 15D1FE6C1998732700302043 /* DeprecatedCocosDenshionFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE671998732700302043 /* DeprecatedCocosDenshionFunc.lua */; }; - 15D1FE6D1998732700302043 /* DeprecatedCocosDenshionFunc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15D1FE671998732700302043 /* DeprecatedCocosDenshionFunc.lua */; }; 1AF4C403178663F200122817 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C402178663F200122817 /* libz.dylib */; }; 5023811817EBBCAC00990C9B /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5023810817EBBCAC00990C9B /* AppController.mm */; }; 5023811917EBBCAC00990C9B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810917EBBCAC00990C9B /* Default-568h@2x.png */; }; @@ -194,43 +124,8 @@ 15427C7E198F201A00DC375D /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua_module_register.h; path = ../Classes/lua_module_register.h; sourceTree = ""; }; 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = "../../cocos2d-x/build/cocos2d_libs.xcodeproj"; sourceTree = ""; }; 15A8A4871834C90E00142BE0 /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; - 15AA96B4199C668400725633 /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosbuilder/CCBReaderLoad.lua"; sourceTree = ""; }; - 15AA96B5199C668400725633 /* DeprecatedCocosBuilderClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocosBuilderClass.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosbuilder/DeprecatedCocosBuilderClass.lua"; sourceTree = ""; }; - 15AA96BA199C66A100725633 /* CocoStudio.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocoStudio.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua"; sourceTree = ""; }; - 15AA96BB199C66A100725633 /* DeprecatedCocoStudioClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocoStudioClass.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua"; sourceTree = ""; }; - 15AA96BC199C66A100725633 /* DeprecatedCocoStudioFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocoStudioFunc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua"; sourceTree = ""; }; - 15AA96BD199C66A100725633 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua"; sourceTree = ""; }; - 15AA96C6199C66B500725633 /* DeprecatedExtensionClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedExtensionClass.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua"; sourceTree = ""; }; - 15AA96C7199C66B500725633 /* DeprecatedExtensionEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedExtensionEnum.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua"; sourceTree = ""; }; - 15AA96C8199C66B500725633 /* DeprecatedExtensionFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedExtensionFunc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua"; sourceTree = ""; }; - 15AA96C9199C66B500725633 /* ExtensionConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ExtensionConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua"; sourceTree = ""; }; - 15AA96D2199C66D500725633 /* DeprecatedNetworkClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedNetworkClass.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkClass.lua"; sourceTree = ""; }; - 15AA96D3199C66D500725633 /* DeprecatedNetworkEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedNetworkEnum.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkEnum.lua"; sourceTree = ""; }; - 15AA96D4199C66D500725633 /* DeprecatedNetworkFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedNetworkFunc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua"; sourceTree = ""; }; - 15AA96D5199C66D500725633 /* NetworkConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua"; sourceTree = ""; }; - 15AA96DE199C66E600725633 /* DeprecatedUIEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedUIEnum.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua"; sourceTree = ""; }; - 15AA96DF199C66E600725633 /* DeprecatedUIFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedUIFunc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua"; sourceTree = ""; }; - 15AA96E0199C66E600725633 /* experimentalUIConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = experimentalUIConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua"; sourceTree = ""; }; - 15AA96E1199C66E600725633 /* GuiConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = GuiConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua"; sourceTree = ""; }; 15AECE28195D482800907DB0 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; 15C1568D1683131500D239F2 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = "../../cocos2d-x/cocos2dx/platform/third_party/ios/libraries/libcurl.a"; sourceTree = ""; }; - 15D1FE3B1998730800302043 /* bitExtend.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = bitExtend.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/bitExtend.lua"; sourceTree = ""; }; - 15D1FE3C1998730800302043 /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua"; sourceTree = ""; }; - 15D1FE3D1998730800302043 /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua"; sourceTree = ""; }; - 15D1FE3E1998730800302043 /* DeprecatedCocos2dClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocos2dClass.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dClass.lua"; sourceTree = ""; }; - 15D1FE3F1998730800302043 /* DeprecatedCocos2dEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocos2dEnum.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dEnum.lua"; sourceTree = ""; }; - 15D1FE401998730800302043 /* DeprecatedCocos2dFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocos2dFunc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dFunc.lua"; sourceTree = ""; }; - 15D1FE411998730800302043 /* DeprecatedOpenglEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedOpenglEnum.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/DeprecatedOpenglEnum.lua"; sourceTree = ""; }; - 15D1FE421998730800302043 /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DrawPrimitives.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/DrawPrimitives.lua"; sourceTree = ""; }; - 15D1FE431998730800302043 /* extern.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = extern.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/extern.lua"; sourceTree = ""; }; - 15D1FE441998730800302043 /* json.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = json.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/json.lua"; sourceTree = ""; }; - 15D1FE451998730800302043 /* luaj.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaj.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/luaj.lua"; sourceTree = ""; }; - 15D1FE461998730800302043 /* luaoc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaoc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/luaoc.lua"; sourceTree = ""; }; - 15D1FE471998730800302043 /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/Opengl.lua"; sourceTree = ""; }; - 15D1FE481998730800302043 /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d/OpenglConstants.lua"; sourceTree = ""; }; - 15D1FE651998732700302043 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua"; sourceTree = ""; }; - 15D1FE661998732700302043 /* DeprecatedCocosDenshionClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocosDenshionClass.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua"; sourceTree = ""; }; - 15D1FE671998732700302043 /* DeprecatedCocosDenshionFunc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedCocosDenshionFunc.lua; path = "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua"; sourceTree = ""; }; 1AF4C402178663F200122817 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 5023810717EBBCAC00990C9B /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 5023810817EBBCAC00990C9B /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; @@ -334,48 +229,6 @@ name = Products; sourceTree = ""; }; - 1A0227A417A3AA1A00B867AD /* Lua Common */ = { - isa = PBXGroup; - children = ( - 15AA96DE199C66E600725633 /* DeprecatedUIEnum.lua */, - 15AA96DF199C66E600725633 /* DeprecatedUIFunc.lua */, - 15AA96E0199C66E600725633 /* experimentalUIConstants.lua */, - 15AA96E1199C66E600725633 /* GuiConstants.lua */, - 15AA96D2199C66D500725633 /* DeprecatedNetworkClass.lua */, - 15AA96D3199C66D500725633 /* DeprecatedNetworkEnum.lua */, - 15AA96D4199C66D500725633 /* DeprecatedNetworkFunc.lua */, - 15AA96D5199C66D500725633 /* NetworkConstants.lua */, - 15AA96C6199C66B500725633 /* DeprecatedExtensionClass.lua */, - 15AA96C7199C66B500725633 /* DeprecatedExtensionEnum.lua */, - 15AA96C8199C66B500725633 /* DeprecatedExtensionFunc.lua */, - 15AA96C9199C66B500725633 /* ExtensionConstants.lua */, - 15AA96BA199C66A100725633 /* CocoStudio.lua */, - 15AA96BB199C66A100725633 /* DeprecatedCocoStudioClass.lua */, - 15AA96BC199C66A100725633 /* DeprecatedCocoStudioFunc.lua */, - 15AA96BD199C66A100725633 /* StudioConstants.lua */, - 15AA96B4199C668400725633 /* CCBReaderLoad.lua */, - 15AA96B5199C668400725633 /* DeprecatedCocosBuilderClass.lua */, - 15D1FE651998732700302043 /* AudioEngine.lua */, - 15D1FE661998732700302043 /* DeprecatedCocosDenshionClass.lua */, - 15D1FE671998732700302043 /* DeprecatedCocosDenshionFunc.lua */, - 15D1FE3B1998730800302043 /* bitExtend.lua */, - 15D1FE3C1998730800302043 /* Cocos2d.lua */, - 15D1FE3D1998730800302043 /* Cocos2dConstants.lua */, - 15D1FE3E1998730800302043 /* DeprecatedCocos2dClass.lua */, - 15D1FE3F1998730800302043 /* DeprecatedCocos2dEnum.lua */, - 15D1FE401998730800302043 /* DeprecatedCocos2dFunc.lua */, - 15D1FE411998730800302043 /* DeprecatedOpenglEnum.lua */, - 15D1FE421998730800302043 /* DrawPrimitives.lua */, - 15D1FE431998730800302043 /* extern.lua */, - 15D1FE441998730800302043 /* json.lua */, - 15D1FE451998730800302043 /* luaj.lua */, - 15D1FE461998730800302043 /* luaoc.lua */, - 15D1FE471998730800302043 /* Opengl.lua */, - 15D1FE481998730800302043 /* OpenglConstants.lua */, - ); - name = "Lua Common"; - sourceTree = ""; - }; 5023810617EBBCAC00990C9B /* ios */ = { isa = PBXGroup; children = ( @@ -443,7 +296,6 @@ 5023817117EBBE3400990C9B /* mac */, F293BB7C15EB830F00256477 /* Classes */, F293B3CB15EB7BE500256477 /* Frameworks */, - 1A0227A417A3AA1A00B867AD /* Lua Common */, F293B3C915EB7BE500256477 /* Products */, F293BC4615EB859D00256477 /* Resources */, ); @@ -623,44 +475,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 15D1FE4A1998730800302043 /* bitExtend.lua in Resources */, - 15D1FE561998730800302043 /* DeprecatedOpenglEnum.lua in Resources */, - 15D1FE641998730800302043 /* OpenglConstants.lua in Resources */, - 15D1FE541998730800302043 /* DeprecatedCocos2dFunc.lua in Resources */, C03781BA18BF655400FE4F13 /* res in Resources */, - 15D1FE691998732700302043 /* AudioEngine.lua in Resources */, - 15AA96C5199C66A100725633 /* StudioConstants.lua in Resources */, - 15D1FE601998730800302043 /* luaoc.lua in Resources */, - 15AA96D1199C66B500725633 /* ExtensionConstants.lua in Resources */, - 15D1FE5E1998730800302043 /* luaj.lua in Resources */, - 15D1FE6B1998732700302043 /* DeprecatedCocosDenshionClass.lua in Resources */, - 15D1FE5A1998730800302043 /* extern.lua in Resources */, - 15D1FE501998730800302043 /* DeprecatedCocos2dClass.lua in Resources */, - 15D1FE581998730800302043 /* DrawPrimitives.lua in Resources */, - 15AA96CF199C66B500725633 /* DeprecatedExtensionFunc.lua in Resources */, - 15AA96E7199C66E600725633 /* experimentalUIConstants.lua in Resources */, - 15AA96CB199C66B500725633 /* DeprecatedExtensionClass.lua in Resources */, - 15AA96E3199C66E600725633 /* DeprecatedUIEnum.lua in Resources */, - 15AA96B7199C668400725633 /* CCBReaderLoad.lua in Resources */, - 15D1FE5C1998730800302043 /* json.lua in Resources */, - 15AA96E5199C66E600725633 /* DeprecatedUIFunc.lua in Resources */, - 15D1FE4E1998730800302043 /* Cocos2dConstants.lua in Resources */, - 15D1FE521998730800302043 /* DeprecatedCocos2dEnum.lua in Resources */, - 15AA96C1199C66A100725633 /* DeprecatedCocoStudioClass.lua in Resources */, - 15AA96C3199C66A100725633 /* DeprecatedCocoStudioFunc.lua in Resources */, - 15D1FE6D1998732700302043 /* DeprecatedCocosDenshionFunc.lua in Resources */, - 15D1FE4C1998730800302043 /* Cocos2d.lua in Resources */, - 15AA96CD199C66B500725633 /* DeprecatedExtensionEnum.lua in Resources */, - 15AA96DD199C66D500725633 /* NetworkConstants.lua in Resources */, - 15AA96D9199C66D500725633 /* DeprecatedNetworkEnum.lua in Resources */, - 15AA96E9199C66E600725633 /* GuiConstants.lua in Resources */, - 15AA96D7199C66D500725633 /* DeprecatedNetworkClass.lua in Resources */, C03781BC18BF655400FE4F13 /* src in Resources */, 5023817617EBBE3400990C9B /* Icon.icns in Resources */, - 15AA96BF199C66A100725633 /* CocoStudio.lua in Resources */, - 15AA96B9199C668400725633 /* DeprecatedCocosBuilderClass.lua in Resources */, - 15D1FE621998730800302043 /* Opengl.lua in Resources */, - 15AA96DB199C66D500725633 /* DeprecatedNetworkFunc.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -668,59 +485,24 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 15AA96E6199C66E600725633 /* experimentalUIConstants.lua in Resources */, 15A8A4491834C64F00142BE0 /* Icon-114.png in Resources */, 5023811D17EBBCAC00990C9B /* Icon-120.png in Resources */, 5091733B17ECE17A00D62437 /* Icon-100.png in Resources */, 5023811B17EBBCAC00990C9B /* Default@2x.png in Resources */, - 15AA96BE199C66A100725633 /* CocoStudio.lua in Resources */, 5091733617ECE17A00D62437 /* Icon-29.png in Resources */, - 15D1FE631998730800302043 /* OpenglConstants.lua in Resources */, - 15D1FE5D1998730800302043 /* luaj.lua in Resources */, - 15AA96D0199C66B500725633 /* ExtensionConstants.lua in Resources */, 5023811917EBBCAC00990C9B /* Default-568h@2x.png in Resources */, 5091733917ECE17A00D62437 /* Icon-58.png in Resources */, 5023811F17EBBCAC00990C9B /* Icon-152.png in Resources */, 5023812017EBBCAC00990C9B /* Icon-57.png in Resources */, C03781B918BF655400FE4F13 /* res in Resources */, - 15D1FE5B1998730800302043 /* json.lua in Resources */, 5023812217EBBCAC00990C9B /* Icon-76.png in Resources */, - 15AA96E2199C66E600725633 /* DeprecatedUIEnum.lua in Resources */, - 15D1FE681998732700302043 /* AudioEngine.lua in Resources */, - 15AA96E8199C66E600725633 /* GuiConstants.lua in Resources */, - 15AA96CA199C66B500725633 /* DeprecatedExtensionClass.lua in Resources */, - 15D1FE4D1998730800302043 /* Cocos2dConstants.lua in Resources */, - 15D1FE4F1998730800302043 /* DeprecatedCocos2dClass.lua in Resources */, 5091733A17ECE17A00D62437 /* Icon-80.png in Resources */, - 15D1FE6A1998732700302043 /* DeprecatedCocosDenshionClass.lua in Resources */, - 15AA96CC199C66B500725633 /* DeprecatedExtensionEnum.lua in Resources */, - 15D1FE571998730800302043 /* DrawPrimitives.lua in Resources */, - 15D1FE4B1998730800302043 /* Cocos2d.lua in Resources */, 5091733717ECE17A00D62437 /* Icon-40.png in Resources */, - 15D1FE5F1998730800302043 /* luaoc.lua in Resources */, 5023811E17EBBCAC00990C9B /* Icon-144.png in Resources */, - 15AA96B6199C668400725633 /* CCBReaderLoad.lua in Resources */, 5023811A17EBBCAC00990C9B /* Default.png in Resources */, - 15D1FE511998730800302043 /* DeprecatedCocos2dEnum.lua in Resources */, - 15D1FE531998730800302043 /* DeprecatedCocos2dFunc.lua in Resources */, - 15AA96DA199C66D500725633 /* DeprecatedNetworkFunc.lua in Resources */, - 15AA96D8199C66D500725633 /* DeprecatedNetworkEnum.lua in Resources */, - 15AA96B8199C668400725633 /* DeprecatedCocosBuilderClass.lua in Resources */, C03781BB18BF655400FE4F13 /* src in Resources */, - 15AA96C0199C66A100725633 /* DeprecatedCocoStudioClass.lua in Resources */, - 15D1FE591998730800302043 /* extern.lua in Resources */, - 15D1FE551998730800302043 /* DeprecatedOpenglEnum.lua in Resources */, - 15AA96E4199C66E600725633 /* DeprecatedUIFunc.lua in Resources */, - 15D1FE6C1998732700302043 /* DeprecatedCocosDenshionFunc.lua in Resources */, - 15AA96CE199C66B500725633 /* DeprecatedExtensionFunc.lua in Resources */, - 15D1FE611998730800302043 /* Opengl.lua in Resources */, 5091733817ECE17A00D62437 /* Icon-50.png in Resources */, - 15AA96C2199C66A100725633 /* DeprecatedCocoStudioFunc.lua in Resources */, - 15AA96C4199C66A100725633 /* StudioConstants.lua in Resources */, - 15D1FE491998730800302043 /* bitExtend.lua in Resources */, - 15AA96DC199C66D500725633 /* NetworkConstants.lua in Resources */, 5023812117EBBCAC00990C9B /* Icon-72.png in Resources */, - 15AA96D6199C66D500725633 /* DeprecatedNetworkClass.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.win32/build-cfg.json b/templates/lua-template-default/frameworks/runtime-src/proj.win32/build-cfg.json index 051f1647e3..828d1bf7a5 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.win32/build-cfg.json +++ b/templates/lua-template-default/frameworks/runtime-src/proj.win32/build-cfg.json @@ -7,14 +7,6 @@ { "from": "../../../res", "to": "res" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocos2d", - "to": "" - }, - { - "from": "../../cocos2d-x/cocos/scripting/lua-bindings/script/cocosdenshion", - "to": "" } ] } diff --git a/templates/lua-template-default/src/main.lua b/templates/lua-template-default/src/main.lua index 30ef917c36..87bfbb5dac 100644 --- a/templates/lua-template-default/src/main.lua +++ b/templates/lua-template-default/src/main.lua @@ -1,5 +1,9 @@ -require "Cocos2d" -require "Cocos2dConstants" + +cc.FileUtils:getInstance():addSearchPath("src") +cc.FileUtils:getInstance():addSearchPath("res") + +-- CC_USE_DEPRECATED_API = true +require "cocos.init" -- cclog cclog = function(...) @@ -37,17 +41,15 @@ local function main() --set FPS. the default value is 1.0/60 if you don't call this director:setAnimationInterval(1.0 / 60) - cc.FileUtils:getInstance():addSearchPath("src") - cc.FileUtils:getInstance():addSearchPath("res") - local schedulerID = 0 + local schedulerID = 0 --support debug local targetPlatform = cc.Application:getInstance():getTargetPlatform() - if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or (cc.PLATFORM_OS_MAC == targetPlatform) then cclog("result is ") - --require('debugger')() - + --require('debugger')() + end require "hello2" cclog("result is " .. myadd(1, 1)) @@ -168,7 +170,7 @@ local function main() listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED ) local eventDispatcher = layerFarm:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layerFarm) - + local function onNodeEvent(event) if "exit" == event then cc.Director:getInstance():getScheduler():unscheduleScriptEntry(schedulerID) @@ -207,7 +209,7 @@ local function main() menuPopup:setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2) menuPopup:setVisible(false) layerMenu:addChild(menuPopup) - + -- add the left-bottom "tools" menu to invoke menuPopup local menuToolsItem = cc.MenuItemImage:create("menu1.png", "menu1.png") menuToolsItem:setPosition(0, 0) @@ -222,7 +224,7 @@ local function main() end -- play background music, preload effect - local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3") + local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3") cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true) local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath) @@ -231,12 +233,12 @@ local function main() local sceneGame = cc.Scene:create() sceneGame:addChild(createLayerFarm()) sceneGame:addChild(createLayerMenu()) - - if cc.Director:getInstance():getRunningScene() then - cc.Director:getInstance():replaceScene(sceneGame) - else - cc.Director:getInstance():runWithScene(sceneGame) - end + + if cc.Director:getInstance():getRunningScene() then + cc.Director:getInstance():replaceScene(sceneGame) + else + cc.Director:getInstance():runWithScene(sceneGame) + end end diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 2fbaf3b11f..7d3bfe3879 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -223,7 +223,7 @@ g_guisTests[] = UISceneManager* sceneManager = UISceneManager::sharedUISceneManager(); sceneManager->setCurrentUISceneId(kUIPageViewTest); sceneManager->setMinUISceneId(kUIPageViewTest); - sceneManager->setMaxUISceneId(kUIPageViewTouchPropagationTest); + sceneManager->setMaxUISceneId(kUIPageViewDynamicAddAndRemoveTest); Scene* scene = sceneManager->currentUIScene(); Director::getInstance()->replaceScene(scene); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index bdaa38e9fc..32f2b607e7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -37,6 +37,8 @@ bool UIButtonTest::init() // Create the button Button* button = Button::create("cocosui/animationbuttonnormal.png"); + CCLOG("content size should be greater than 0: width = %f, height = %f", button->getContentSize().width, + button->getContentSize().height); button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest::touchEvent, this)); button->setZoomScale(0.4); @@ -632,7 +634,10 @@ bool UIButtonTextOnly::init() // Create the button auto button = Button::create(); button->setNormalizedPosition(Vec2(0.5, 0.5)); + button->setTitleText("PLAY GAME"); + CCLOG("content size should be greater than 0: width = %f, height = %f", button->getContentSize().width, + button->getContentSize().height); button->setZoomScale(0.3); button->setPressedActionEnabled(true); button->addClickEventListener([this](Ref* sender) { diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index f7d7e5afe3..f4b7d4478d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -505,3 +505,180 @@ void UIPageViewTouchPropagationTest::pageViewEvent(Ref *pSender, PageView::Event } } +// UIPageViewDynamicAddAndRemoveTest +UIPageViewDynamicAddAndRemoveTest::UIPageViewDynamicAddAndRemoveTest() +: _displayValueLabel(nullptr) +{ + +} + +UIPageViewDynamicAddAndRemoveTest::~UIPageViewDynamicAddAndRemoveTest() +{ +} + +bool UIPageViewDynamicAddAndRemoveTest::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add a label in which the dragpanel events will be displayed + _displayValueLabel = Text::create("Click Buttons on the Left", "fonts/Marker Felt.ttf", 32); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + + _displayValueLabel->getContentSize().height * 1.5)); + _uiLayer->addChild(_displayValueLabel); + + // Add the black background + Text* alert = Text::create("PageView Dynamic Modification", "fonts/Marker Felt.ttf", 30); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); + _uiLayer->addChild(alert); + + Layout* root = static_cast(_uiLayer->getChildByTag(81)); + + Layout* background = dynamic_cast(root->getChildByName("background_Panel")); + + // Create the page view + PageView* pageView = PageView::create(); + pageView->setContentSize(Size(240.0f, 130.0f)); + pageView->setAnchorPoint(Vec2(0.5,0.5)); + Size backgroundSize = background->getContentSize(); + pageView->setPosition(Vec2(widgetSize.width / 2.0f ,widgetSize.height / 2.0f)); + pageView->setBackGroundColor(Color3B::GREEN); + pageView->setBackGroundColorType(Layout::BackGroundColorType::SOLID); + + int pageCount = 4; + for (int i = 0; i < pageCount; ++i) + { + HBox* outerBox = HBox::create(); + outerBox->setContentSize(Size(240.0f, 130.0f)); + + for (int k = 0; k < 2; ++k) + { + VBox* innerBox = VBox::create(); + + for (int j = 0; j < 3; j++) + { + Button *btn = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + btn->setName(StringUtils::format("button %d", j)); + + innerBox->addChild(btn); + } + + LinearLayoutParameter *parameter = LinearLayoutParameter::create(); + parameter->setMargin(Margin(0,0,100,0)); + innerBox->setLayoutParameter(parameter); + + outerBox->addChild(innerBox); + + } + + pageView->insertPage(outerBox,i); + } + + pageView->addEventListener(CC_CALLBACK_2(UIPageViewDynamicAddAndRemoveTest::pageViewEvent, this)); + pageView->setName("pageView"); + _uiLayer->addChild(pageView); + + //add buttons + auto button = Button::create(); + button->setNormalizedPosition(Vec2(0.12,0.7)); + button->setTitleText("Add A Page"); + button->setZoomScale(0.3); + button->setPressedActionEnabled(true); + button->setTitleColor(Color3B::RED); + button->addClickEventListener([=](Ref* sender) + { + HBox* outerBox = HBox::create(); + outerBox->setContentSize(Size(240.0f, 130.0f)); + + for (int k = 0; k < 2; ++k) + { + VBox* innerBox = VBox::create(); + + for (int j = 0; j < 3; j++) + { + Button *btn = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + btn->setName(StringUtils::format("button %d", j)); + + innerBox->addChild(btn); + } + + LinearLayoutParameter *parameter = LinearLayoutParameter::create(); + parameter->setMargin(Margin(0,0,100,0)); + innerBox->setLayoutParameter(parameter); + + outerBox->addChild(innerBox); + + } + + pageView->addPage(outerBox); + _displayValueLabel->setString(CCString::createWithFormat("page count = %ld", pageView->getPages().size())->getCString()); + + }); + _uiLayer->addChild(button); + + auto button2 = Button::create(); + button2->setNormalizedPosition(Vec2(0.12,0.5)); + button2->setTitleText("Remove A Page"); + button2->setZoomScale(0.3); + button2->setPressedActionEnabled(true); + button2->setTitleColor(Color3B::RED); + button2->addClickEventListener([=](Ref* sender) + { + if (pageView->getPages().size() > 0) + { + pageView->removePageAtIndex(pageView->getPages().size()-1); + } + else + { + CCLOG("There is no page to remove!"); + } + _displayValueLabel->setString(CCString::createWithFormat("page count = %ld", pageView->getPages().size())->getCString()); + + }); + _uiLayer->addChild(button2); + + auto button3 = Button::create(); + button3->setNormalizedPosition(Vec2(0.12,0.3)); + button3->setTitleText("Remove All Pages"); + button3->setZoomScale(0.3); + button3->setPressedActionEnabled(true); + button3->setTitleColor(Color3B::RED); + button3->addClickEventListener([=](Ref* sender) + { + pageView->removeAllPages(); + _displayValueLabel->setString(CCString::createWithFormat("page count = %ld", pageView->getPages().size())->getCString()); + + }); + _uiLayer->addChild(button3); + + + + return true; + } + return false; +} + + +void UIPageViewDynamicAddAndRemoveTest::pageViewEvent(Ref *pSender, PageView::EventType type) +{ + switch (type) + { + case PageView::EventType::TURNING: + { + PageView* pageView = dynamic_cast(pSender); + + _displayValueLabel->setString(CCString::createWithFormat("page = %ld", pageView->getCurPageIndex() + 1)->getCString()); + } + break; + + default: + break; + } +} + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 922115c52f..5f9c492bc7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -85,4 +85,19 @@ protected: Text* _displayValueLabel; }; +class UIPageViewDynamicAddAndRemoveTest : public UIScene +{ +public: + UIPageViewDynamicAddAndRemoveTest(); + ~UIPageViewDynamicAddAndRemoveTest(); + bool init(); + + void pageViewEvent(Ref* pSender, PageView::EventType type); + void onButtonClicked(Ref* pSender, Widget::TouchEventType type); + +protected: + UI_SCENE_CREATE_FUNC(UIPageViewDynamicAddAndRemoveTest) + Text* _displayValueLabel; +}; + #endif /* defined(__TestCpp__UIPageViewTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp index 242b345111..113deec116 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp @@ -55,6 +55,7 @@ static const char* s_testArray[] = "UIImageViewTest", "UIImageViewTest_Scale9", "UIImageViewTest_ContentSize", + "UILoadingBarTest_Left", "UILoadingBarTest_Right", "UILoadingBarTest_Left_Scale9", @@ -63,17 +64,17 @@ static const char* s_testArray[] = "UITextAtlasTest", "UITextTest", "UITextTest_LineWrap", - "UILabelTest_Effect", - "UITextTest_TTF", "UITextBMFontTest", + "UITextFieldTest", "UITextFieldTest_MaxLength", "UITextFieldTest_Password", "UITextFieldTest_LineWrap", "UITextFieldTest_TrueTypeFont", "UITextFieldTest_PlaceHolderColor", + "UILayoutTest", "UILayoutTest_Color", "UILayoutTest_Gradient", @@ -90,15 +91,20 @@ static const char* s_testArray[] = "UIScrollViewTest_ScrollToPercentBothDirection", "UIScrollViewTest_ScrollToPercentBothDirection_Bounce", "UIScrollViewNestTest", + "UIPageViewTest", "UIPageViewButtonTest", "UIPageViewCustomScrollThreshold", "UIPageViewTouchPropagationTest", + "UIPageViewDynamicAddAndRemoveTest", + "UIListViewTest_Vertical", "UIListViewTest_Horizontal", "UIWidgetAddNodeTest", + "UIRichTextTest", + "UIFocusTest-HBox", "UIFocusTest-VBox", "UIFocusTest-NestedLayout1", @@ -325,7 +331,8 @@ Scene *UISceneManager::currentUIScene() return UIPageViewCustomScrollThreshold::sceneWithTitle(s_testArray[_currentUISceneId]); case kUIPageViewTouchPropagationTest: return UIPageViewTouchPropagationTest::sceneWithTitle(s_testArray[_currentUISceneId]); - + case kUIPageViewDynamicAddAndRemoveTest: + return UIPageViewDynamicAddAndRemoveTest::sceneWithTitle(s_testArray[_currentUISceneId]); case kUIListViewTest_Vertical: return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h index 1a3debeaa3..658cdb4e7c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h @@ -86,6 +86,7 @@ enum kUIPageViewButtonTest, kUIPageViewCustomScrollThreshold, kUIPageViewTouchPropagationTest, + kUIPageViewDynamicAddAndRemoveTest, kUIListViewTest_Vertical, kUIListViewTest_Horizontal, kUIWidgetAddNodeTest, diff --git a/tests/lua-tests/project/CMakeLists.txt b/tests/lua-tests/project/CMakeLists.txt index 89a1a1f15b..8c8114fd88 100644 --- a/tests/lua-tests/project/CMakeLists.txt +++ b/tests/lua-tests/project/CMakeLists.txt @@ -3,6 +3,7 @@ set(APP_NAME lua-tests) set(SAMPLE_SRC Classes/AppDelegate.cpp Classes/lua_assetsmanager_test_sample.cpp + Classes/lua_test_bindings.cpp ) if(LINUX) @@ -48,7 +49,7 @@ pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/cocosdenshion ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/network ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/cocosbuilder ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/cocostudio ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/cocosstudio ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/extension ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ui ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests/cpp-tests/Resources ${APP_BIN_DIR}/Resources/res diff --git a/tests/lua-tests/project/Classes/AppDelegate.cpp b/tests/lua-tests/project/Classes/AppDelegate.cpp index a9185b6afe..cd193e0840 100644 --- a/tests/lua-tests/project/Classes/AppDelegate.cpp +++ b/tests/lua-tests/project/Classes/AppDelegate.cpp @@ -4,6 +4,7 @@ #include "audio/include/SimpleAudioEngine.h" #include "lua_assetsmanager_test_sample.h" #include "lua_module_register.h" +#include "lua_test_bindings.h" using namespace CocosDenshion; @@ -43,6 +44,7 @@ bool AppDelegate::applicationDidFinishLaunching() if (lua_istable(L,-1))//stack:...,_G, { register_assetsmanager_test_sample(L); + register_test_binding(L); } lua_pop(L, 1); #endif diff --git a/tests/lua-tests/project/Classes/lua_test_bindings.cpp b/tests/lua-tests/project/Classes/lua_test_bindings.cpp new file mode 100644 index 0000000000..ca41685d13 --- /dev/null +++ b/tests/lua-tests/project/Classes/lua_test_bindings.cpp @@ -0,0 +1,621 @@ +#include "lua_test_bindings.h" +#include "cocos2d.h" +#include "LuaBasicConversions.h" + +NS_CC_BEGIN + +/** + * Copy DrawNode for 3D geometry drawing. + */ +class DrawNode3D: public Node +{ +public: + /** creates and initialize a DrawNode3D node */ + static DrawNode3D* create(); + + /** + * Draw 3D Line + */ + void drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color); + + /** + * Draw 3D cube + * @param point to a vertex array who has 8 element. + * vertices[0]:Left-top-front, + * vertices[1]:Left-bottom-front, + * vertices[2]:Right-bottom-front, + * vertices[3]:Right-top-front, + * vertices[4]:Right-top-back, + * vertices[5]:Right-bottom-back, + * vertices[6]:Left-bottom-back, + * vertices[7]:Left-top-back. + * @param color + */ + void drawCube(Vec3* vertices, const Color4F &color); + + /** Clear the geometry in the node's buffer. */ + void clear(); + + /** + * @js NA + * @lua NA + */ + const BlendFunc& getBlendFunc() const; + + /** + * @code + * When this function bound into js or lua,the parameter will be changed + * In js: var setBlendFunc(var src, var dst) + * @endcode + * @lua NA + */ + void setBlendFunc(const BlendFunc &blendFunc); + + void onDraw(const Mat4 &transform, uint32_t flags); + + // Overrides + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; + +CC_CONSTRUCTOR_ACCESS: + DrawNode3D(); + virtual ~DrawNode3D(); + virtual bool init(); + +protected: + struct V3F_C4B + { + Vec3 vertices; + Color4B colors; + }; + void ensureCapacity(int count); + + GLuint _vao; + GLuint _vbo; + + int _bufferCapacity; + GLsizei _bufferCount; + V3F_C4B* _buffer; + + BlendFunc _blendFunc; + CustomCommand _customCommand; + + bool _dirty; + +private: + CC_DISALLOW_COPY_AND_ASSIGN(DrawNode3D); +}; + + + + +DrawNode3D::DrawNode3D() +: _vao(0) +, _vbo(0) +, _bufferCapacity(0) +, _bufferCount(0) +, _buffer(nullptr) +, _dirty(false) +{ + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; +} + +DrawNode3D::~DrawNode3D() +{ + free(_buffer); + _buffer = nullptr; + + glDeleteBuffers(1, &_vbo); + _vbo = 0; + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glDeleteVertexArrays(1, &_vao); + GL::bindVAO(0); + _vao = 0; + } +} + +DrawNode3D* DrawNode3D::create() +{ + DrawNode3D* ret = new (std::nothrow) DrawNode3D(); + if (ret && ret->init()) + { + ret->autorelease(); + } + else + { + CC_SAFE_DELETE(ret); + } + + return ret; +} + +void DrawNode3D::ensureCapacity(int count) +{ + CCASSERT(count>=0, "capacity must be >= 0"); + + if(_bufferCount + count > _bufferCapacity) + { + _bufferCapacity += MAX(_bufferCapacity, count); + _buffer = (V3F_C4B*)realloc(_buffer, _bufferCapacity*sizeof(V3F_C4B)); + } +} + +bool DrawNode3D::init() +{ + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; + + setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_COLOR)); + + ensureCapacity(512); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glGenVertexArrays(1, &_vao); + GL::bindVAO(_vao); + } + + glGenBuffers(1, &_vbo); + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)* _bufferCapacity, _buffer, GL_STREAM_DRAW); + + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices)); + + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors)); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(0); + } + + CHECK_GL_ERROR_DEBUG(); + + _dirty = true; + +#if CC_ENABLE_CACHE_TEXTURE_DATA + // Need to listen the event only when not use batchnode, because it will use VBO + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + /** listen the event that coming to foreground on Android */ + this->init(); + }); + + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +#endif + + return true; +} + +void DrawNode3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) +{ + _customCommand.init(_globalZOrder); + _customCommand.func = CC_CALLBACK_0(DrawNode3D::onDraw, this, transform, flags); + renderer->addCommand(&_customCommand); +} + +void DrawNode3D::onDraw(const Mat4 &transform, uint32_t flags) +{ + auto glProgram = getGLProgram(); + glProgram->use(); + glProgram->setUniformsForBuiltins(transform); + glEnable(GL_DEPTH_TEST); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + + if (_dirty) + { + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)*_bufferCapacity, _buffer, GL_STREAM_DRAW); + _dirty = false; + } + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(_vao); + } + else + { + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + // vertex + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices)); + + // color + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors)); + } + + glDrawArrays(GL_LINES, 0, _bufferCount); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCount); + glDisable(GL_DEPTH_TEST); + CHECK_GL_ERROR_DEBUG(); +} + +void DrawNode3D::drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color) +{ + unsigned int vertex_count = 2; + ensureCapacity(vertex_count); + + Color4B col = Color4B(color); + V3F_C4B a = {Vec3(from.x, from.y, from.z), col}; + V3F_C4B b = {Vec3(to.x, to.y, to.z), col, }; + + V3F_C4B *lines = (V3F_C4B *)(_buffer + _bufferCount); + lines[0] = a; + lines[1] = b; + + _bufferCount += vertex_count; + _dirty = true; + +} + +void DrawNode3D::drawCube(Vec3* vertices, const Color4F &color) +{ + // front face + drawLine(vertices[0], vertices[1], color); + drawLine(vertices[1], vertices[2], color); + drawLine(vertices[2], vertices[3], color); + drawLine(vertices[3], vertices[0], color); + + // back face + drawLine(vertices[4], vertices[5], color); + drawLine(vertices[5], vertices[6], color); + drawLine(vertices[6], vertices[7], color); + drawLine(vertices[7], vertices[4], color); + + // edge + drawLine(vertices[0], vertices[7], color); + drawLine(vertices[1], vertices[6], color); + drawLine(vertices[2], vertices[5], color); + drawLine(vertices[3], vertices[4], color); +} + +void DrawNode3D::clear() +{ + _bufferCount = 0; + _dirty = true; +} + +const BlendFunc& DrawNode3D::getBlendFunc() const +{ + return _blendFunc; +} + +void DrawNode3D::setBlendFunc(const BlendFunc &blendFunc) +{ + _blendFunc = blendFunc; +} +NS_CC_END + +int lua_cocos2dx_DrawNode3D_getBlendFunc(lua_State* L) +{ + int argc = 0; + cocos2d::DrawNode3D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_getBlendFunc'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + blendfunc_to_luaval(L, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:getBlendFunc",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_getBlendFunc'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_DrawNode3D_setBlendFunc(lua_State* L) +{ + int argc = 0; + cocos2d::DrawNode3D* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_setBlendFunc'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 2) + { + GLenum src, dst; + if (!luaval_to_int32(L, 2, (int32_t*)&src, "cc.DrawNode3D:setBlendFunc")) + return 0; + + if (!luaval_to_int32(L, 3, (int32_t*)&dst, "cc.DrawNode3D:setBlendFunc")) + return 0; + + BlendFunc blendFunc = {src, dst}; + cobj->setBlendFunc(blendFunc); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:setBlendFunc",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_setBlendFunc'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_DrawNode3D_drawLine(lua_State* L) +{ + int argc = 0; + cocos2d::DrawNode3D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_drawLine'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 3) + { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + cocos2d::Color4F arg2; + + ok &= luaval_to_vec3(L, 2, &arg0, "cc.DrawNode3D:drawLine"); + + ok &= luaval_to_vec3(L, 3, &arg1, "cc.DrawNode3D:drawLine"); + + ok &=luaval_to_color4f(L, 4, &arg2, "cc.DrawNode3D:drawLine"); + if(!ok) + return 0; + cobj->drawLine(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:drawLine",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_drawLine'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_DrawNode3D_clear(lua_State* L) +{ + int argc = 0; + cocos2d::DrawNode3D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_clear'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->clear(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:clear",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_clear'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_DrawNode3D_drawCube(lua_State* L) +{ + int argc = 0; + cocos2d::DrawNode3D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_drawCube'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 2) + { + std::vector arg0; + cocos2d::Color4F arg1; + Vec3 vec3; +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + size_t size = lua_objlen(L, 2); + for (int i = 0; i < size; i++) + { + lua_pushnumber(L, i + 1); + lua_gettable(L, 2); +#ifndef TOLUA_RELEASE + if (!tolua_istable(L, -1, 0, &tolua_err)) + { + lua_pop(L, 1); + goto tolua_lerror; + } +#endif + ok &= luaval_to_vec3(L, lua_gettop(L), &vec3); + +#ifndef TOLUA_RELEASE + if (!ok) + { + lua_pop(L, 1); + goto tolua_lerror; + } +#endif + //arg0[i] = vec3; + arg0.push_back(vec3); + lua_pop(L, 1); + } + + ok &=luaval_to_color4f(L, 3, &arg1, "cc.DrawNode3D:drawCube"); + if(!ok) + return 0; + cobj->drawCube(&arg0[0], arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:drawCube",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_drawCube'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_DrawNode3D_create(lua_State* L) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(L) - 1; + + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::DrawNode3D* ret = cocos2d::DrawNode3D::create(); + object_to_luaval(L, "cc.DrawNode3D",(cocos2d::DrawNode3D*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.DrawNode3D:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_create'.",&tolua_err); +#endif + return 0; +} + +int lua_register_cocos2dx_DrawNode3D(lua_State* L) +{ + tolua_usertype(L,"cc.DrawNode3D"); + tolua_cclass(L,"DrawNode3D","cc.DrawNode3D","cc.Node",nullptr); + + tolua_beginmodule(L,"DrawNode3D"); + tolua_function(L,"getBlendFunc",lua_cocos2dx_DrawNode3D_getBlendFunc); + tolua_function(L,"setBlendFunc",lua_cocos2dx_DrawNode3D_setBlendFunc); + tolua_function(L,"drawLine",lua_cocos2dx_DrawNode3D_drawLine); + tolua_function(L,"clear",lua_cocos2dx_DrawNode3D_clear); + tolua_function(L,"drawCube",lua_cocos2dx_DrawNode3D_drawCube); + tolua_function(L,"create", lua_cocos2dx_DrawNode3D_create); + tolua_endmodule(L); + std::string typeName = typeid(cocos2d::DrawNode3D).name(); + g_luaType[typeName] = "cc.DrawNode3D"; + g_typeCast["DrawNode3D"] = "cc.DrawNode3D"; + return 1; +} + +int register_test_binding(lua_State* L) +{ + tolua_open(L); + tolua_module(L, "cc", 0); + tolua_beginmodule(L, "cc"); + lua_register_cocos2dx_DrawNode3D(L); + tolua_endmodule(L); + return 0; +} diff --git a/tests/lua-tests/project/Classes/lua_test_bindings.h b/tests/lua-tests/project/Classes/lua_test_bindings.h new file mode 100644 index 0000000000..02191a79d5 --- /dev/null +++ b/tests/lua-tests/project/Classes/lua_test_bindings.h @@ -0,0 +1,14 @@ +#ifndef COCOS2DX_TEST_LUA_TESTS_PROJECT_CLASSES_LUA_TEST_BINDINGS_H +#define COCOS2DX_TEST_LUA_TESTS_PROJECT_CLASSES_LUA_TEST_BINDINGS_H + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +TOLUA_API int register_test_binding(lua_State* tolua_S); + +#endif // #ifndef COCOS2DX_TEST_LUA_TESTS_PROJECT_CLASSES_LUA_TEST_BINDINGS_H diff --git a/tests/lua-tests/project/proj.android/build-cfg.json b/tests/lua-tests/project/proj.android/build-cfg.json index 797d851ebc..476b9ef682 100644 --- a/tests/lua-tests/project/proj.android/build-cfg.json +++ b/tests/lua-tests/project/proj.android/build-cfg.json @@ -33,7 +33,7 @@ "to": "" }, { - "from": "../../../../cocos/scripting/lua-bindings/script/cocostudio", + "from": "../../../../cocos/scripting/lua-bindings/script/cocosstudio", "to": "" }, { diff --git a/tests/lua-tests/project/proj.android/jni/Android.mk b/tests/lua-tests/project/proj.android/jni/Android.mk index 877693bf1b..2776ac7475 100644 --- a/tests/lua-tests/project/proj.android/jni/Android.mk +++ b/tests/lua-tests/project/proj.android/jni/Android.mk @@ -8,7 +8,8 @@ LOCAL_MODULE_FILENAME := liblua_tests LOCAL_SRC_FILES += main.cpp \ ../../Classes/AppDelegate.cpp \ - ../../Classes/lua_assetsmanager_test_sample.cpp + ../../Classes/lua_assetsmanager_test_sample.cpp \ + ../../Classes/lua_test_bindings.cpp LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj index 897aaa6864..1201e19204 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj @@ -112,7 +112,7 @@ xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosdenshion" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\network" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosbuilder" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocostudio" "$(ProjectDir)..\..\" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosstudio" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\extension" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\ui" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\external\lua\luasocket\*.lua" "$(ProjectDir)..\..\" /e /Y @@ -167,7 +167,7 @@ xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(ProjectDir)..\..\res" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosdenshion" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\network" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosbuilder" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocostudio" "$(ProjectDir)..\..\" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosstudio" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\extension" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\ui" "$(ProjectDir)..\..\" /e /Y xcopy "$(ProjectDir)..\..\..\..\external\lua\luasocket\*.lua" "$(ProjectDir)..\..\" /e /Y @@ -182,12 +182,14 @@ xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(ProjectDir)..\..\res" /e /Y + + diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters index e6cf7a3008..4cd4b112a8 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters @@ -21,6 +21,9 @@ Classes + + Classes + @@ -32,5 +35,8 @@ Classes + + Classes + \ No newline at end of file diff --git a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua index 56e8edd6d3..98a60968e0 100644 --- a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua +++ b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua @@ -413,7 +413,22 @@ function Camera3DTestDemo:onEnter() self:SwitchViewCallback(self, CameraType.ThirdCamera) - --UNDO DrawLine3D drwaline + local line = cc.DrawNode3D:create() + --draw x + for i = -20 ,20 do + line:drawLine(cc.vec3(-100, 0, 5 * i), cc.vec3(100, 0, 5 * i), cc.c4f(1, 0, 0, 0)) + end + + --draw z + for i = -20, 20 do + line:drawLine(cc.vec3(5 * i, 0, -100), cc.vec3(5 * i, 0, 100), cc.c4f(0, 0, 1, 1)) + end + + --draw y + line:drawLine(cc.vec3(0, -50, 0), cc.vec3(0,0,0), cc.c4f(0, 0.5, 0, 1)) + line:drawLine(cc.vec3(0, 0, 0), cc.vec3(0,50,0), cc.c4f(0, 1, 0, 1)) + self._layer3D:addChild(line) + self._layer3D:setCameraMask(2) end diff --git a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua index 773ff20289..bb95144f61 100644 --- a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua +++ b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua @@ -629,6 +629,245 @@ function Sprite3DReskinTest.create() return layer end +---------------------------------------- +----Sprite3DWithOBBPerfromanceTest +---------------------------------------- +local Sprite3DWithOBBPerfromanceTest = class("Sprite3DWithOBBPerfromanceTest",function() + return cc.Layer:create() +end) + +function Sprite3DWithOBBPerfromanceTest:ctor() + self._obb = {} + local listener = cc.EventListenerTouchAllAtOnce:create() + listener:registerScriptHandler(function (touches, event) + for i,touch in ipairs(touches) do + local location = touch:getLocationInView() + if nil ~= self._obb and #self._obb > 0 then + self._intersetList = {} + local ray = cc.Ray:new() + self:calculateRayByLocationInView(ray, location) + + for idx,value in ipairs(self._obb) do + if ray:intersects(value) then + table.insert(self._intersetList, idx) + return + end + end + end + end + end,cc.Handler.EVENT_TOUCHES_BEGAN) + + listener:registerScriptHandler(function (touches, event) + + end,cc.Handler.EVENT_TOUCHES_ENDED) + + listener:registerScriptHandler(function (touches, event) + for i,touch in ipairs(touches) do + local location = touch:getLocation() + + for idx,value in ipairs(self._obb) do + for lstIdx,lstValue in ipairs(self._intersetList) do + if idx == lstValue then + self._obb[idx]._center = cc.vec3(location.x,location.y,0) + end + end + end + end + end,cc.Handler.EVENT_TOUCHES_MOVED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) + + local s = cc.Director:getInstance():getWinSize() + self:initDrawBox() + + self:addNewSpriteWithCoords(cc.p(s.width/2, s.height/2)) + + cc.MenuItemFont:setFontName("fonts/arial.ttf") + cc.MenuItemFont:setFontSize(65) + + local decrease = cc.MenuItemFont:create(" - ") + decrease:registerScriptTapHandler(function(tag, sender) + self:delOBBWithCount(10) + end) + decrease:setColor(cc.c3b(0, 200, 20)) + + local increase = cc.MenuItemFont:create(" + ") + increase:registerScriptTapHandler(function(tag, sender) + self:addOBBWithCount(10) + end) + increase:setColor(cc.c3b(0, 200, 20)) + + local menu = cc.Menu:create(decrease, increase) + menu:alignItemsHorizontally() + menu:setPosition(cc.p(s.width/2, s.height - 90)) + self:addChild(menu, 1) + + local ttfConfig = {} + ttfConfig.fontFilePath = "fonts/Marker Felt.ttf" + ttfConfig.fontSize = 30 + self._labelCubeCount = cc.Label:createWithTTF(ttfConfig,"0 cubes") + self._labelCubeCount:setColor(cc.c3b(0,200,20)) + self._labelCubeCount:setPosition(cc.p(s.width/2, s.height-90)) + self:addChild(self._labelCubeCount) + + self:addOBBWithCount(10) + self:scheduleUpdateWithPriorityLua(function(dt) + self._labelCubeCount:setString(string.format("%u cubes", #self._obb)) + if nil ~= self._drawDebug then + self._drawDebug:clear() + local mat = self._sprite:getNodeToWorldTransform() + + self._obbt._xAxis = cc.vec3(mat[1], mat[2], mat[3]) + self._obbt._xAxis = cc.vec3normalize(self._obbt._xAxis) + + self._obbt._yAxis = cc.vec3(mat[5], mat[6], mat[7]) + self._obbt._yAxis = cc.vec3normalize(self._obbt._yAxis) + + self._obbt._zAxis = cc.vec3(-mat[9], -mat[10], -mat[11]) + self._obbt._zAxis = cc.vec3normalize(self._obbt._zAxis) + + self._obbt._center = self._sprite:getPosition3D() + + local corners = {} + for i=1,8 do + corners[i] = {} + end + corners = self._obbt:getCorners(corners) + self._drawDebug:drawCube(corners, cc.c4f(0, 0, 1, 1)) + end + + if #self._obb > 0 then + self._drawOBB:clear() + + for i= 1, #self._obb do + local corners = {} + for i=1,8 do + corners[i] = {} + end + + corners = self._obb[i]:getCorners(corners) + if self._obbt:intersects(self._obb[i]) then + self._drawOBB:drawCube(corners, cc.c4f(1, 0, 0, 1)) + else + self._drawOBB:drawCube(corners, cc.c4f(0, 1, 0, 1)) + end + + end + end + end, 0) +end + +function Sprite3DWithOBBPerfromanceTest:addOBBWithCount( value ) + for i=1,value do + local randompos = cc.p(math.random() * cc.Director:getInstance():getWinSize().width, math.random() * cc.Director:getInstance():getWinSize().height) + local extents = cc.vec3(10, 10, 10) + local aabb = cc.AABB:new({x = -10, y = -10, z = -10}, extents) + local obb = cc.OBB:new(aabb) + obb._center = cc.vec3(randompos.x,randompos.y,0) + table.insert(self._obb, obb) + end +end + +function Sprite3DWithOBBPerfromanceTest:delOBBWithCount( value ) + if #self._obb >= 10 then + for i= 1, 10 do + table.remove(self._obb) + end + self._drawOBB:clear() + end +end + +function Sprite3DWithOBBPerfromanceTest:initDrawBox() + self._drawOBB = cc.DrawNode3D:create() + self:addChild(self._drawOBB ) +end + +function Sprite3DWithOBBPerfromanceTest:unproject( viewProjection, viewport, src, dst) + assert(viewport.width ~= 0.0 and viewport.height ~= 0) + local screen = cc.vec4(src.x / viewport.width, (viewport.height - src.y) / viewport.height, src.z, 1.0) + screen.x = screen.x * 2.0 - 1.0 + screen.y = screen.y * 2.0 - 1.0 + screen.z = screen.z * 2.0 - 1.0 + local inversed = cc.mat4.new(viewProjection:getInversed()) + screen = inversed:transformVector(screen, screen) + if screen.w ~= 0.0 then + screen.x = screen.x / screen.w + screen.y = screen.y / screen.w + screen.z = screen.z / screen.w + end + + dst.x = screen.x + dst.y = screen.y + dst.z = screen.z + return viewport, src, dst +end + +function Sprite3DWithOBBPerfromanceTest:calculateRayByLocationInView(ray, location) + local dir = cc.Director:getInstance() + local view = dir:getWinSize() + local mat = cc.mat4.new(dir:getMatrix(cc.MATRIX_STACK_TYPE.PROJECTION)) + local src = cc.vec3(location.x, location.y, -1) + local nearPoint = {} + view, src, nearPoint = self:unproject(mat, view, src, nearPoint) + src = cc.vec3(location.x, location.y, 1) + local farPoint = {} + view, src, farPoint = self:unproject(mat, view, src, farPoint) + local direction = {} + direction.x = farPoint.x - nearPoint.x + direction.y = farPoint.y - nearPoint.y + direction.z = farPoint.z - nearPoint.z + direction = cc.vec3normalize(direction) + + ray._origin = nearPoint + ray._direction = direction +end + +function Sprite3DWithOBBPerfromanceTest:addNewSpriteWithCoords(vec2) + local fileName = "Sprite3DTest/tortoise.c3b" + local sprite = cc.Sprite3D:create(fileName) + sprite:setScale(0.1) + local s = cc.Director:getInstance():getWinSize() + sprite:setPosition(cc.p(s.width * 4.0 / 5.0, s.height / 2.0)) + self:addChild(sprite) + self._sprite = sprite + local animation = cc.Animation3D:create(fileName) + if nil ~= animation then + local animate = cc.Animate3D:create(animation, 0.0, 1.933) + sprite:runAction(cc.RepeatForever:create(animate)) + end + + self._moveAction = cc.MoveTo:create(4.0, cc.p(s.width / 5.0, s.height / 2.0)) + self._moveAction:retain() + local function reachEndCallBack() + self._sprite:stopActionByTag(100) + local inverse = self._moveAction:reverse() + inverse:retain() + self._moveAction:release() + self._moveAction = inverse + local rot = cc.RotateBy:create(1.0, { x = 0.0, y = 180.0, z = 0.0}) + local seq = cc.Sequence:create(rot, self._moveAction, cc.CallFunc:create(reachEndCallBack)) + seq:setTag(100) + self._sprite:runAction(seq) + end + local seq = cc.Sequence:create(self._moveAction, cc.CallFunc:create(reachEndCallBack)) + seq:setTag(100) + sprite:runAction(seq) + + local aabb = self._sprite:getAABB() + self._obbt = cc.OBB:new(aabb) + + self._drawDebug = cc.DrawNode3D:create() + self:addChild(self._drawDebug) +end + +function Sprite3DWithOBBPerfromanceTest.create() + local layer = Sprite3DWithOBBPerfromanceTest.new() + Helper.initWithLayer(layer) + Helper.titleLabel:setString("OBB Collison Perfromance Test") + return layer +end + ---------------------------------------- ----Sprite3DMirrorTest ---------------------------------------- @@ -680,7 +919,6 @@ function Sprite3DMirrorTest.create() return layer end - function Sprite3DTest() local scene = cc.Scene:create() @@ -692,6 +930,7 @@ function Sprite3DTest() Animate3DTest.create, AttachmentTest.create, Sprite3DReskinTest.create, + Sprite3DWithOBBPerfromanceTest.create, Sprite3DMirrorTest.create, } diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 1a71fe7be4..b49fad3fb2 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 1a71fe7be45db504f3bdc0e24e8d7eca83f2fc1a +Subproject commit b49fad3fb2dbc396e71a5b1178cf2532309cd174 diff --git a/tools/tolua/cocos2dx_3d.ini b/tools/tolua/cocos2dx_3d.ini index 02e57c6f50..0e779cf550 100644 --- a/tools/tolua/cocos2dx_3d.ini +++ b/tools/tolua/cocos2dx_3d.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h # 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 = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode AABB OBB BillBoard +classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard # 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 @@ -39,8 +39,6 @@ skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getMeshVertexAttrib Sprite3D::[getSkin getAABB setBlendFunc], Skeleton3D::[create], Animation3D::[getBoneCurveByName], - AABB::[intersects merge], - OBB::[intersects], BillBoard::[draw] @@ -59,7 +57,7 @@ base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = OBB +abstract_classes = # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no