diff --git a/CHANGELOG b/CHANGELOG index 8cf7b01ae0..2f4916503f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,10 +4,18 @@ cocos2d-x-4.0 ?? [HIGHLIGHT] Use CMake for all platforms [REFINE] Update glfw to 3.3 +[REFINE] Update minizip to 1.2 [CHANGE] remove deprecated functions [CHANGE] remove h5 engine and JSB [CHANGE] remove tiff +[CHANGE] remove `experimental` namespace + +[FIX] system font can not work correctly on macOS 15 +[FIX] TextField can not work if using system input to get Chinese characters with iOS13 +[FIX] UIWebView uses WKWebView instead +[FIX] VideoPlayer uses AVPlayerController instead +[FX] lua crashes on 64it devcices cocos2d-x-3.17 May.21 2018 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7deb315259..856d9843e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,13 @@ cmake_minimum_required(VERSION 3.6) project(Cocos2d-x) +# set default minimum deployment target +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + # cocos2dx root path set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) diff --git a/cmake/Modules/CocosBuildHelpers.cmake b/cmake/Modules/CocosBuildHelpers.cmake index 38ece29037..f512262d65 100644 --- a/cmake/Modules/CocosBuildHelpers.cmake +++ b/cmake/Modules/CocosBuildHelpers.cmake @@ -202,6 +202,10 @@ function(setup_cocos_app_config app_name) if(XCODE OR VS) cocos_mark_code_files(${app_name}) endif() + + if (XCODE) + cocos_config_app_xcode_property(${app_name}) + endif() endfunction() # if cc_variable not set, then set it cc_value @@ -211,52 +215,6 @@ macro(cocos_set_default_value cc_variable cc_value) endif() endmacro() -# generate macOS app package infomations, need improve for example, the using of info.plist -function(cocos_pak_xcode cocos_target) - set(oneValueArgs - INFO_PLIST - BUNDLE_NAME - BUNDLE_VERSION - COPYRIGHT - GUI_IDENTIFIER - ICON_FILE - INFO_STRING - LONG_VERSION_STRING - SHORT_VERSION_STRING - ) - set(multiValueArgs) - cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - string(TIMESTAMP ARGS_COPYRIGHT_YEAR "%Y") - # set default value - cocos_set_default_value(ARGS_INFO_PLIST "MacOSXBundleInfo.plist.in") - cocos_set_default_value(ARGS_BUNDLE_NAME "\${PRODUCT_NAME}") - cocos_set_default_value(ARGS_BUNDLE_VERSION "1") - cocos_set_default_value(ARGS_COPYRIGHT "Copyright © ${ARGS_COPYRIGHT_YEAR}. All rights reserved.") - cocos_set_default_value(ARGS_GUI_IDENTIFIER "org.cocos2dx.${APP_NAME}") - cocos_set_default_value(ARGS_ICON_FILE "Icon") - cocos_set_default_value(ARGS_INFO_STRING "cocos2d-x app") - cocos_set_default_value(ARGS_LONG_VERSION_STRING "1.0.0") - cocos_set_default_value(ARGS_SHORT_VERSION_STRING "1.0") - # set default values for Info.plist template - set_target_properties(${cocos_target} - PROPERTIES - MACOSX_BUNDLE_INFO_PLIST ${ARGS_INFO_PLIST} - ) - set(MACOSX_BUNDLE_BUNDLE_NAME ${ARGS_BUNDLE_NAME} PARENT_SCOPE) - set(MACOSX_BUNDLE_BUNDLE_VERSION ${ARGS_BUNDLE_VERSION} PARENT_SCOPE) - set(MACOSX_BUNDLE_COPYRIGHT ${ARGS_COPYRIGHT} PARENT_SCOPE) - set(MACOSX_BUNDLE_GUI_IDENTIFIER ${ARGS_GUI_IDENTIFIER} PARENT_SCOPE) - set(MACOSX_BUNDLE_ICON_FILE ${ARGS_ICON_FILE} PARENT_SCOPE) - set(MACOSX_BUNDLE_INFO_STRING ${ARGS_INFO_STRING} PARENT_SCOPE) - set(MACOSX_BUNDLE_LONG_VERSION_STRING ${ARGS_LONG_VERSION_STRING} PARENT_SCOPE) - set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${ARGS_SHORT_VERSION_STRING} PARENT_SCOPE) - - message(STATUS "cocos package: ${cocos_target}, plist file: ${ARGS_INFO_PLIST}") - - cocos_config_app_xcode_property(${cocos_target}) -endfunction() - # set Xcode property for application, include all depend target macro(cocos_config_app_xcode_property cocos_app) set(depend_libs) @@ -271,7 +229,6 @@ endmacro() # custom Xcode property for iOS target macro(cocos_config_target_xcode_property cocos_target) if(IOS) - set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "8.0") set_xcode_property(${cocos_target} ENABLE_BITCODE "NO") set_xcode_property(${cocos_target} ONLY_ACTIVE_ARCH "YES") endif() @@ -368,4 +325,3 @@ function(cocos_use_pkg target pkg) endif() endfunction() - diff --git a/cmake/Modules/CocosBuildSet.cmake b/cmake/Modules/CocosBuildSet.cmake index 738127c270..0c063a4c71 100644 --- a/cmake/Modules/CocosBuildSet.cmake +++ b/cmake/Modules/CocosBuildSet.cmake @@ -22,8 +22,7 @@ message(STATUS "CMAKE_MODULE_PATH:" ${CMAKE_MODULE_PATH}) message(STATUS "PROJECT_BINARY_DIR:" ${PROJECT_BINARY_DIR}) message(STATUS "ENGINE_BINARY_PATH:" ${ENGINE_BINARY_PATH}) -# the default behavior of build module -option(DEBUG_MODE "Debug or Release?" ON) + option(BUILD_LUA_LIBS "Build lua libraries" OFF) # include helper functions diff --git a/cmake/Modules/CocosConfigDefine.cmake b/cmake/Modules/CocosConfigDefine.cmake index 54ae371fa8..12f1300aea 100644 --- a/cmake/Modules/CocosConfigDefine.cmake +++ b/cmake/Modules/CocosConfigDefine.cmake @@ -45,20 +45,6 @@ elseif(CMAKE_GENERATOR MATCHES Visual) endif() message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}") -if(CMAKE_CONFIGURATION_TYPES) - set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Reset the configurations to what we need" FORCE) - message(STATUS "CMAKE_CONFIGURATION_TYPES: ${CMAKE_CONFIGURATION_TYPES}") -else() - if(NOT CMAKE_BUILD_TYPE) - if(DEBUG_MODE) # build mode, Debug is default value - set(CMAKE_BUILD_TYPE Debug) - else() - set(CMAKE_BUILD_TYPE Release) - endif() - endif() - message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -endif() - # custom target property for lua/js link define_property(TARGET PROPERTY CC_JS_DEPEND @@ -76,6 +62,7 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # check visual studio version if(WINDOWS) diff --git a/cmake/Modules/CocosConfigDepend.cmake b/cmake/Modules/CocosConfigDepend.cmake index 8d0969a3ba..8919459869 100644 --- a/cmake/Modules/CocosConfigDepend.cmake +++ b/cmake/Modules/CocosConfigDepend.cmake @@ -24,7 +24,6 @@ macro(cocos2dx_depend) elseif(APPLE) include_directories(/System/Library/Frameworks) - find_library(ICONV_LIBRARY iconv) find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) find_library(FOUNDATION_LIBRARY Foundation) find_library(OPENAL_LIBRARY OpenAL) @@ -36,7 +35,6 @@ macro(cocos2dx_depend) ${AUDIOTOOLBOX_LIBRARY} ${QUARTZCORE_LIBRARY} ${FOUNDATION_LIBRARY} - ${ICONV_LIBRARY} ${GAMECONTROLLER_LIBRARY} ${METAL_LIBRARY} ) @@ -49,6 +47,7 @@ macro(cocos2dx_depend) find_library(APPLICATIONSERVICES_LIBRARY ApplicationServices) find_library(IOKIT_LIBRARY IOKit) find_library(APPKIT_LIBRARY AppKit) + find_library(ICONV_LIBRARY iconv) list(APPEND PLATFORM_SPECIFIC_LIBS ${COCOA_LIBRARY} ${OPENGL_LIBRARY} @@ -56,6 +55,7 @@ macro(cocos2dx_depend) ${IOKIT_LIBRARY} ${COCOS_APPLE_LIBS} ${APPKIT_LIBRARY} + ${ICONV_LIBRARY} ) elseif(IOS) # Locate system libraries on iOS @@ -68,7 +68,6 @@ macro(cocos2dx_depend) find_library(SECURITY_LIBRARY Security) find_library(CORE_GRAPHICS_LIBRARY CoreGraphics) find_library(AV_FOUNDATION_LIBRARY AVFoundation) - find_library(Z_LIBRARY z) find_library(WEBKIT_LIBRARY WebKit) list(APPEND PLATFORM_SPECIFIC_LIBS ${UIKIT_LIBRARY} @@ -80,9 +79,10 @@ macro(cocos2dx_depend) ${SECURITY_LIBRARY} ${CORE_GRAPHICS_LIBRARY} ${AV_FOUNDATION_LIBRARY} - ${Z_LIBRARY} ${WEBKIT_LIBRARY} ${COCOS_APPLE_LIBS} + "/usr/lib/libz.dylib" + "/usr/lib/libiconv.dylib" ) endif() endif() diff --git a/cmake/Modules/iOSBundleInfo.plist.in b/cmake/Modules/iOSBundleInfo.plist.in deleted file mode 100644 index fa2a779a2d..0000000000 --- a/cmake/Modules/iOSBundleInfo.plist.in +++ /dev/null @@ -1,51 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} - CFBundleGetInfoString - ${MACOSX_BUNDLE_INFO_STRING} - CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} - CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} - CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} - CFBundleSignature - ???? - CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} - CSResourcesFileMapped - - LSRequiresIPhoneOS - - UIStatusBarHidden - - UIRequiresFullScreen - - UILaunchStoryboardName - LaunchScreen - UISupportedInterfaceOrientations - - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationLandscapeLeft - - NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} - CFBundleIconFiles - - ${MACOSX_BUNDLE_ICON_FILE} - - - diff --git a/cmake/README.md b/cmake/README.md index ce9e6b785b..cfa80ffaf8 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -60,9 +60,52 @@ cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos open Cocos2d-x.xcodeproj ``` -The parameter `-DCMAKE_OSX_SYSROOT=iphoneos` is optional, it generates a build for running on the iOS device. If you want to run in the simulator, please add `-DCMAKE_OSX_SYSROOT=iphonesimulator`, but remember you can't run a metal-support app in the simulator until Xcode 11 and MacOS 10.15. +#### How do I customize the generated Xcode project? + +Xcode project settings that you want to affect both the app project and the Cocos2d-X library project should be passed on the command +line when invoking `cmake`. + +Xcode project settings that you want to affect the app project only shoudl be put into the its `CMakeLists.txt` file. + +Any Xcode Build Setting can be changed by setting `CMAKE_XCODE_ATTRIBUTE_XXX` where `XXX` is the name found within the Xcode Build +Settings page of the target. The following image shows the name of the iOS Deployment Target: + +![Find Xcode Build Setting](images/Xcode_Find_Setting_Name.png) + +Cocos also provides the function `set_xcode_property()` to make this easier to set from within a `CMakeLists.txt` file, where only +the `XXX` part needed to be specified: + +``` +set_xcode_property(${APP_NAME} XXX "Value") +``` + +##### Deployment Target + +As explained above, pass this on the command line so both the app the Cocos2d-x are built using the same version: + +For iOS pass `-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=version`, where `version` is `9.0`, `10.0`, etc. + +For macOS pass `-DCMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET=version`, where `version` is `10.12`, `10.13`, etc. + +##### Code Signing Development Team + +This should be set in the app `CMakeLists.txt` file. You only need to set the "Development Team" as Xcode will automatically manage the +other settings (certificate type, etc.). However the value you set is the 10-digit serial number following the development team name, +which you can see in the top-right of the [Apple Developer Certificates](https://developer.apple.com/account/resources/certificates/list) page. + +Set it like this: +``` +set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") +``` + +##### Bundle Identifier, Version numbers and Device Support + +All this information is held in the `Info.plist` file that is part of the app's source files and is therefore not generated by `cmake`. Therefore +you can update these values from the `General` page of the Xcode target and the values will be preserved the next time you regenerate the project +from `cmake`: + +![Xcode General Page](images/Xcode_General_Page.png) -if you want to sign iOS app in CMake, you will need to fill development team ID into `set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")`, or select to sign in Xcode after project files generated. ### Android Studio diff --git a/cmake/images/Xcode_Find_Setting_Name.png b/cmake/images/Xcode_Find_Setting_Name.png new file mode 100644 index 0000000000..2ce8a61818 Binary files /dev/null and b/cmake/images/Xcode_Find_Setting_Name.png differ diff --git a/cmake/images/Xcode_General_Page.png b/cmake/images/Xcode_General_Page.png new file mode 100644 index 0000000000..fc1eea565b Binary files /dev/null and b/cmake/images/Xcode_General_Page.png differ diff --git a/cocos/2d/CCActionCatmullRom.cpp b/cocos/2d/CCActionCatmullRom.cpp index 4f1eb6d131..9e7d9f5c35 100644 --- a/cocos/2d/CCActionCatmullRom.cpp +++ b/cocos/2d/CCActionCatmullRom.cpp @@ -269,8 +269,8 @@ void CardinalSplineTo::update(float time) } else { - p = time / _deltaT; - lt = (time - _deltaT * (float)p) / _deltaT; + p = (ssize_t)(time / _deltaT); + lt = (time - _deltaT * p) / _deltaT; } // Interpolate diff --git a/cocos/2d/CCActionGrid3D.cpp b/cocos/2d/CCActionGrid3D.cpp index 4bf8960f88..5f69e581f8 100644 --- a/cocos/2d/CCActionGrid3D.cpp +++ b/cocos/2d/CCActionGrid3D.cpp @@ -71,10 +71,11 @@ void Waves3D::update(float time) { for (j = 0; j < _gridSize.height + 1; ++j) { - Vec3 v = getOriginalVertex(Vec2(i ,j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate); //CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate)); - setVertex(Vec2(i, j), v); + setVertex(pos, v); } } } @@ -347,7 +348,8 @@ void Lens3D::update(float /*time*/) { for (j = 0; j < _gridSize.height + 1; ++j) { - Vec3 v = getOriginalVertex(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); Vec2 vect = _position - Vec2(v.x, v.y); float r = vect.getLength(); @@ -371,7 +373,7 @@ void Lens3D::update(float /*time*/) } } - setVertex(Vec2(i, j), v); + setVertex(pos, v); } } @@ -439,7 +441,8 @@ void Ripple3D::update(float time) { for (j = 0; j < (_gridSize.height+1); ++j) { - Vec3 v = getOriginalVertex(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); Vec2 vect = _position - Vec2(v.x,v.y); float r = vect.getLength(); @@ -450,7 +453,7 @@ void Ripple3D::update(float time) v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate); } - setVertex(Vec2(i, j), v); + setVertex(pos, v); } } } @@ -506,7 +509,8 @@ void Shaky3D::update(float /*time*/) { for (j = 0; j < (_gridSize.height+1); ++j) { - Vec3 v = getOriginalVertex(Vec2(i ,j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); v.x += (rand() % (_randrange*2)) - _randrange; v.y += (rand() % (_randrange*2)) - _randrange; if (_shakeZ) @@ -514,7 +518,7 @@ void Shaky3D::update(float /*time*/) v.z += (rand() % (_randrange*2)) - _randrange; } - setVertex(Vec2(i, j), v); + setVertex(pos, v); } } } @@ -571,10 +575,11 @@ void Liquid::update(float time) { for (j = 1; j < _gridSize.height; ++j) { - Vec3 v = getOriginalVertex(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate)); - setVertex(Vec2(i, j), v); + setVertex(pos, v); } } } @@ -633,7 +638,8 @@ void Waves::update(float time) { for (j = 0; j < _gridSize.height + 1; ++j) { - Vec3 v = getOriginalVertex(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); if (_vertical) { @@ -645,7 +651,7 @@ void Waves::update(float time) v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); } - setVertex(Vec2(i, j), v); + setVertex(pos, v); } } } @@ -709,7 +715,8 @@ void Twirl::update(float time) { for (j = 0; j < (_gridSize.height+1); ++j) { - Vec3 v = getOriginalVertex(Vec2(i ,j)); + Vec2 pos((float)i, (float)j); + Vec3 v = getOriginalVertex(pos); Vec2 avg(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f)); float r = avg.getLength(); @@ -724,7 +731,7 @@ void Twirl::update(float time) v.x = c.x + d.x; v.y = c.y + d.y; - setVertex(Vec2(i ,j), v); + setVertex(pos, v); } } } diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index b862e1f6ed..8dd7612254 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -2095,7 +2095,7 @@ Blink* Blink::reverse() const FadeIn* FadeIn::create(float d) { FadeIn* action = new (std::nothrow) FadeIn(); - if (action && action->initWithDuration(d,255.0f)) + if (action && action->initWithDuration(d,255)) { action->autorelease(); return action; @@ -2132,7 +2132,7 @@ void FadeIn::startWithTarget(cocos2d::Node *target) if (nullptr != _reverseAction) this->_toOpacity = this->_reverseAction->_fromOpacity; else - _toOpacity = 255.0f; + _toOpacity = 255; if (target) _fromOpacity = target->getOpacity(); @@ -2145,7 +2145,7 @@ void FadeIn::startWithTarget(cocos2d::Node *target) FadeOut* FadeOut::create(float d) { FadeOut* action = new (std::nothrow) FadeOut(); - if (action && action->initWithDuration(d,0.0f)) + if (action && action->initWithDuration(d,0)) { action->autorelease(); return action; @@ -2168,7 +2168,7 @@ void FadeOut::startWithTarget(cocos2d::Node *target) if (nullptr != _reverseAction) _toOpacity = _reverseAction->_fromOpacity; else - _toOpacity = 0.0f; + _toOpacity = 0; if (target) _fromOpacity = target->getOpacity(); diff --git a/cocos/2d/CCActionPageTurn3D.cpp b/cocos/2d/CCActionPageTurn3D.cpp index 2d5630de1b..b5f149c680 100644 --- a/cocos/2d/CCActionPageTurn3D.cpp +++ b/cocos/2d/CCActionPageTurn3D.cpp @@ -74,7 +74,7 @@ void PageTurn3D::update(float time) float deltaTheta = sqrtf(time); float theta = deltaTheta > 0.5f ? (float)M_PI_2*deltaTheta : (float)M_PI_2*(1-deltaTheta); - float rotateByYAxis = (2-time)* M_PI; + float rotateByYAxis = (2-time)* (float)M_PI; float sinTheta = sinf(theta); float cosTheta = cosf(theta); @@ -83,8 +83,9 @@ void PageTurn3D::update(float time) { for (int j = 0; j <= _gridSize.height; ++j) { + Vec2 pos((float)i, (float)j); // Get original vertex - Vec3 p = getOriginalVertex(Vec2(i ,j)); + Vec3 p = getOriginalVertex(pos); p.x -= getGridRect().origin.x; float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay))); @@ -124,7 +125,7 @@ void PageTurn3D::update(float time) // Set new coords p.x += getGridRect().origin.x; - setVertex(Vec2(i, j), p); + setVertex(pos, p); } } diff --git a/cocos/2d/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp index b24ccd1134..3e624729f2 100644 --- a/cocos/2d/CCActionTiledGrid.cpp +++ b/cocos/2d/CCActionTiledGrid.cpp @@ -82,7 +82,8 @@ void ShakyTiles3D::update(float /*time*/) { for (j = 0; j < _gridSize.height; ++j) { - Quad3 coords = getOriginalTile(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Quad3 coords = getOriginalTile(pos); // X coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; @@ -104,7 +105,7 @@ void ShakyTiles3D::update(float /*time*/) coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; } - setTile(Vec2(i, j), coords); + setTile(pos, coords); } } } @@ -155,7 +156,8 @@ void ShatteredTiles3D::update(float /*time*/) { for (j = 0; j < _gridSize.height; ++j) { - Quad3 coords = getOriginalTile(Vec2(i ,j)); + Vec2 pos((float)i, (float)j); + Quad3 coords = getOriginalTile(pos); // X coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; @@ -177,7 +179,7 @@ void ShatteredTiles3D::update(float /*time*/) coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; } - setTile(Vec2(i, j), coords); + setTile(pos, coords); } } @@ -240,10 +242,8 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len) Size ShuffleTiles::getDelta(const Size& pos) const { + unsigned int idx = static_cast(pos.width * _gridSize.height + pos.height); Vec2 pos2; - - unsigned int idx = pos.width * _gridSize.height + pos.height; - pos2.x = (float)(_tilesOrder[idx] / (int)_gridSize.height); pos2.y = (float)(_tilesOrder[idx] % (int)_gridSize.height); @@ -279,7 +279,7 @@ void ShuffleTiles::startWithTarget(Node *target) std::srand(_seed); } - _tilesCount = _gridSize.width * _gridSize.height; + _tilesCount = (unsigned int)(_gridSize.width * _gridSize.height); _tilesOrder = new unsigned int[_tilesCount]; /** @@ -302,7 +302,7 @@ void ShuffleTiles::startWithTarget(Node *target) { tileArray->position.set((float)i, (float)j); tileArray->startPosition.set((float)i, (float)j); - tileArray->delta = getDelta(Size(i, j)); + tileArray->delta = getDelta(Size((float)i, (float)j)); ++tileArray; } } @@ -317,7 +317,7 @@ void ShuffleTiles::update(float time) for (int j = 0; j < _gridSize.height; ++j) { tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time; - placeTile(Vec2(i, j), tileArray); + placeTile(Vec2((float)i, (float)j), tileArray); ++tileArray; } } @@ -394,18 +394,19 @@ void FadeOutTRTiles::update(float time) { for (int j = 0; j < _gridSize.height; ++j) { - float distance = testFunc(Size(i, j), time); + Vec2 pos((float)i, (float)j); + float distance = testFunc(Size((float)i, (float)j), time); if ( distance == 0 ) { - turnOffTile(Vec2(i, j)); + turnOffTile(pos); } else if (distance < 1) { - transformTile(Vec2(i, j), distance); + transformTile(pos, distance); } else { - turnOnTile(Vec2(i, j)); + turnOnTile(pos); } } } @@ -604,7 +605,7 @@ void TurnOffTiles::startWithTarget(Node *target) std::srand(_seed); } - _tilesCount = _gridSize.width * _gridSize.height; + _tilesCount = (unsigned int)(_gridSize.width * _gridSize.height); _tilesOrder = new unsigned int[_tilesCount]; for (unsigned int i = 0; i < _tilesCount; ++i) @@ -623,7 +624,9 @@ void TurnOffTiles::update(float time) for (unsigned int i = 0; i < _tilesCount; i++ ) { t = _tilesOrder[i]; - Vec2 tilePos( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height ); + //needs integer value + unsigned int x = (unsigned int)(t / _gridSize.height); + Vec2 tilePos((float)x, (float)(t % (unsigned int)_gridSize.height)); if ( i < l ) { @@ -678,7 +681,8 @@ void WavesTiles3D::update(float time) { for (int j = 0; j < _gridSize.height; j++ ) { - Quad3 coords = getOriginalTile(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Quad3 coords = getOriginalTile(pos); coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 + (coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate ); @@ -686,7 +690,7 @@ void WavesTiles3D::update(float time) coords.tl.z = coords.bl.z; coords.tr.z = coords.bl.z; - setTile(Vec2(i, j), coords); + setTile(pos, coords); } } } @@ -736,7 +740,8 @@ void JumpTiles3D::update(float time) { for (int j = 0; j < _gridSize.height; j++ ) { - Quad3 coords = getOriginalTile(Vec2(i, j)); + Vec2 pos((float)i, (float)j); + Quad3 coords = getOriginalTile(pos); if ( ((i+j) % 2) == 0 ) { @@ -753,7 +758,7 @@ void JumpTiles3D::update(float time) coords.tr.z += sinz2; } - setTile(Vec2(i, j), coords); + setTile(pos, coords); } } } @@ -778,7 +783,7 @@ bool SplitRows::initWithDuration(float duration, unsigned int rows) { _rows = rows; - return TiledGrid3DAction::initWithDuration(duration, Size(1, rows)); + return TiledGrid3DAction::initWithDuration(duration, Size(1.0f, (float)rows)); } SplitRows* SplitRows::clone() const @@ -795,9 +800,10 @@ void SplitRows::startWithTarget(Node *target) void SplitRows::update(float time) { - for (unsigned int j = 0; j < _gridSize.height; ++j) + for (int j = 0; j < _gridSize.height; ++j) { - Quad3 coords = getOriginalTile(Vec2(0, j)); + Vec2 pos(0, (float)j); + Quad3 coords = getOriginalTile(pos); float direction = 1; if ( (j % 2 ) == 0 ) @@ -810,7 +816,7 @@ void SplitRows::update(float time) coords.tl.x += direction * _winSize.width * time; coords.tr.x += direction * _winSize.width * time; - setTile(Vec2(0, j), coords); + setTile(pos, coords); } } @@ -833,7 +839,7 @@ SplitCols* SplitCols::create(float duration, unsigned int cols) bool SplitCols::initWithDuration(float duration, unsigned int cols) { _cols = cols; - return TiledGrid3DAction::initWithDuration(duration, Size(cols, 1)); + return TiledGrid3DAction::initWithDuration(duration, Size((float)cols, 1.0f)); } SplitCols* SplitCols::clone() const @@ -852,7 +858,8 @@ void SplitCols::update(float time) { for (unsigned int i = 0; i < _gridSize.width; ++i) { - Quad3 coords = getOriginalTile(Vec2(i, 0)); + Vec2 pos((float)i, 0); + Quad3 coords = getOriginalTile(pos); float direction = 1; if ( (i % 2 ) == 0 ) @@ -865,7 +872,7 @@ void SplitCols::update(float time) coords.tl.y += direction * _winSize.height * time; coords.tr.y += direction * _winSize.height * time; - setTile(Vec2(i, 0), coords); + setTile(pos, coords); } } diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 6eea8166d8..91183550d3 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -25,8 +25,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "2d/CCAtlasNode.h" +#include // offsetof +#include "base/ccTypes.h" #include "renderer/CCTextureAtlas.h" #include "base/CCDirector.h" #include "renderer/CCTextureCache.h" @@ -44,7 +45,8 @@ NS_CC_BEGIN AtlasNode::AtlasNode() { auto& pipelineDescriptor = _quadCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture"); diff --git a/cocos/2d/CCAutoPolygon.cpp b/cocos/2d/CCAutoPolygon.cpp index f2cff63a92..e35b62a749 100644 --- a/cocos/2d/CCAutoPolygon.cpp +++ b/cocos/2d/CCAutoPolygon.cpp @@ -166,7 +166,7 @@ float PolygonInfo::getArea() const float area = 0; V3F_C4B_T2F *verts = triangles.verts; unsigned short *indices = triangles.indices; - for(int i = 0; i < triangles.indexCount; i+=3) + for(unsigned int i = 0; i < triangles.indexCount; i+=3) { auto A = verts[indices[i]].vertices; auto B = verts[indices[i+1]].vertices; @@ -249,13 +249,13 @@ unsigned int AutoPolygon::getSquareValue(unsigned int x, unsigned int y, const R //NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel auto fixedRect = Rect(rect.origin, rect.size-Size(2,2)); - Vec2 tl = Vec2(x-1, y-1); + Vec2 tl = Vec2(x-1.0f, y-1.0f); sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0; - Vec2 tr = Vec2(x, y-1); + Vec2 tr = Vec2(x-0.0f, y-1.0f); sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold)? 2 : 0; - Vec2 bl = Vec2(x-1, y); + Vec2 bl = Vec2(x-1.0f, y-0.0f); sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold)? 4 : 0; - Vec2 br = Vec2(x, y); + Vec2 br = Vec2(x-0.0f, y-0.0f); sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold)? 8 : 0; CCASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15"); return sv; @@ -267,8 +267,8 @@ std::vector AutoPolygon::marchSquare(const Rect& rect, const Vec2 int stepy = 0; int prevx = 0; int prevy = 0; - int startx = start.x; - int starty = start.y; + int startx = (int)start.x; + int starty = (int)start.y; int curx = startx; int cury = starty; unsigned int count = 0; @@ -526,7 +526,7 @@ std::vector AutoPolygon::expand(const std::vector& points, const coc ClipperLib::PolyTree out; for(const auto& pt : points) { - subj << ClipperLib::IntPoint(pt.x* PRECISION, pt.y * PRECISION); + subj << ClipperLib::IntPoint(static_cast(pt.x* PRECISION), static_cast(pt.y * PRECISION)); } ClipperLib::ClipperOffset co; co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon); @@ -551,9 +551,10 @@ std::vector AutoPolygon::expand(const std::vector& points, const coc //create the clipping rect ClipperLib::Path clamp; clamp.push_back(ClipperLib::IntPoint(0, 0)); - clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, 0)); - clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, rect.size.height/_scaleFactor * PRECISION)); - clamp.push_back(ClipperLib::IntPoint(0, rect.size.height/_scaleFactor * PRECISION)); + clamp.push_back(ClipperLib::IntPoint(static_cast(rect.size.width/_scaleFactor * PRECISION), 0)); + clamp.push_back(ClipperLib::IntPoint(static_cast(rect.size.width/_scaleFactor * PRECISION), + static_cast(rect.size.height/_scaleFactor * PRECISION))); + clamp.push_back(ClipperLib::IntPoint(0, static_cast(rect.size.height/_scaleFactor * PRECISION))); cl.AddPath(clamp, ClipperLib::ptClip, true); cl.Execute(ClipperLib::ctIntersection, out); @@ -599,10 +600,10 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po for(int i = 0; i < 3; ++i) { auto p = ite->GetPoint(i); - auto v3 = Vec3(p->x, p->y, 0); + auto v3 = Vec3((float)p->x, (float)p->y, 0); bool found = false; - size_t j; - size_t length = vdx; + unsigned short j; + auto length = vdx; for(j = 0; j < length; j++) { if(verts[j].vertices == v3) @@ -668,8 +669,8 @@ void AutoPolygon::calculateUV(const Rect& rect, V3F_C4B_T2F* verts, ssize_t coun */ CCASSERT(_width && _height, "please specify width and height for this AutoPolygon instance"); - float texWidth = _width; - float texHeight = _height; + auto texWidth = _width; + auto texHeight = _height; auto end = &verts[count]; for(auto i = verts; i != end; ++i) @@ -690,7 +691,7 @@ Rect AutoPolygon::getRealRect(const Rect& rect) { //if the instance doesn't have width and height, then the whole operation is kaput CCASSERT(_height && _width, "Please specify a width and height for this instance before using its functions"); - realRect = Rect(0,0, _width, _height); + realRect = Rect(0,0, (float)_width, (float)_height); } else{ //rect is specified, so convert to real rect diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index f21282d21f..defd7332ec 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -45,7 +45,7 @@ Camera* Camera::create() Camera* camera = new (std::nothrow) Camera(); camera->initDefault(); camera->autorelease(); - camera->setDepth(0.f); + camera->setDepth(0); return camera; } diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index f38c4f5d6d..01ad20741f 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -24,6 +24,8 @@ ****************************************************************************/ #include "2d/CCCameraBackgroundBrush.h" +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCCamera.h" #include "base/ccMacros.h" #include "base/ccUtils.h" @@ -122,7 +124,8 @@ CameraBackgroundDepthBrush* CameraBackgroundDepthBrush::create(float depth) bool CameraBackgroundDepthBrush::init() { CC_SAFE_RELEASE_NULL(_programState); - _programState = new backend::ProgramState(cameraClear_vert, cameraClear_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::CAMERA_CLEAR); + _programState = new backend::ProgramState(program); _locDepth = _programState->getUniformLocation("dpeth"); @@ -409,7 +412,8 @@ bool CameraBackgroundSkyBoxBrush::init() _customCommand.setAfterCallback(CC_CALLBACK_0(CameraBackgroundSkyBoxBrush::onAfterDraw, this)); CC_SAFE_RELEASE_NULL(_programState); - _programState = new backend::ProgramState(CC3D_skybox_vert, CC3D_skybox_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKYBOX_3D); + _programState = new backend::ProgramState(program); _uniformColorLoc = _programState->getUniformLocation("u_color"); _uniformCameraRotLoc = _programState->getUniformLocation("u_cameraRot"); _uniformEnvLoc = _programState->getUniformLocation("u_Env"); diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 0917331c71..9b99db4606 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -198,7 +198,8 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 auto alphaThreshold = this->getAlphaThreshold(); if (alphaThreshold < 1) { - auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColorAlphaTest_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST); + auto programState = new (std::nothrow) backend::ProgramState(program); auto alphaLocation = programState->getUniformLocation("u_alpha_value"); programState->setUniform(alphaLocation, &alphaThreshold, sizeof(alphaThreshold)); setProgramStateRecursively(_stencil, programState); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 97506debc3..cfdb282b68 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -23,6 +23,8 @@ */ #include "2d/CCDrawNode.h" +#include // offsetof +#include "base/ccTypes.h" #include "base/CCEventType.h" #include "base/CCConfiguration.h" #include "renderer/CCRenderer.h" @@ -30,7 +32,6 @@ #include "base/CCEventListenerCustom.h" #include "base/CCEventDispatcher.h" #include "2d/CCActionCatmullRom.h" -#include "platform/CCGL.h" #include "base/ccUtils.h" #include "renderer/ccShaders.h" #include "renderer/backend/ProgramState.h" @@ -149,21 +150,24 @@ bool DrawNode::init() void DrawNode::updateShader() { CC_SAFE_RELEASE(_programState); - _programState = new (std::nothrow) backend::ProgramState(positionColorLengthTexture_vert, positionColorLengthTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_LENGTH_TEXTURE); + _programState = new (std::nothrow) backend::ProgramState(program); _customCommand.getPipelineDescriptor().programState = _programState; setVertexLayout(_customCommand); _customCommand.setDrawType(CustomCommand::DrawType::ARRAY); _customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE); CC_SAFE_RELEASE(_programStatePoint); - _programStatePoint = new (std::nothrow) backend::ProgramState(positionColorTextureAsPointsize_vert, positionColor_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_TEXTURE_AS_POINTSIZE); + _programStatePoint = new (std::nothrow) backend::ProgramState(program); _customCommandGLPoint.getPipelineDescriptor().programState = _programStatePoint; setVertexLayout(_customCommandGLPoint); _customCommandGLPoint.setDrawType(CustomCommand::DrawType::ARRAY); _customCommandGLPoint.setPrimitiveType(CustomCommand::PrimitiveType::POINT); CC_SAFE_RELEASE(_programStateLine); - _programStateLine = new (std::nothrow) backend::ProgramState(positionColorLengthTexture_vert, positionColorLengthTexture_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_LENGTH_TEXTURE); + _programStateLine = new (std::nothrow) backend::ProgramState(program); _customCommandGLLine.getPipelineDescriptor().programState = _programStateLine; setVertexLayout(_customCommandGLLine); _customCommandGLLine.setDrawType(CustomCommand::DrawType::ARRAY); @@ -225,7 +229,7 @@ void DrawNode::updateUniforms(const Mat4 &transform, CustomCommand& cmd) auto mvpLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); pipelineDescriptor.programState->setUniform(mvpLocation, matrixMVP.m, sizeof(matrixMVP.m)); - float alpha = _displayedOpacity / 255.0; + float alpha = _displayedOpacity / 255.0f; auto alphaUniformLocation = pipelineDescriptor.programState->getUniformLocation("u_alpha"); pipelineDescriptor.programState->setUniform(alphaUniformLocation, &alpha, sizeof(alpha)); } @@ -444,7 +448,7 @@ void DrawNode::drawCardinalSpline(PointArray *config, float tension, unsigned i p = config->count() - 1; lt = 1; } else { - p = dt / deltaT; + p = static_cast(dt / deltaT); lt = (dt - deltaT * (float)p) / deltaT; } diff --git a/cocos/2d/CCFastTMXLayer.cpp b/cocos/2d/CCFastTMXLayer.cpp index 7841b2c6ac..a11c0cd1ec 100644 --- a/cocos/2d/CCFastTMXLayer.cpp +++ b/cocos/2d/CCFastTMXLayer.cpp @@ -36,6 +36,8 @@ THE SOFTWARE. */ #include "2d/CCFastTMXLayer.h" +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCFastTMXTiledMap.h" #include "2d/CCSprite.h" #include "2d/CCCamera.h" @@ -49,16 +51,15 @@ THE SOFTWARE. #include "renderer/backend/ProgramState.h" NS_CC_BEGIN -namespace experimental { -const int TMXLayer::FAST_TMX_ORIENTATION_ORTHO = 0; -const int TMXLayer::FAST_TMX_ORIENTATION_HEX = 1; -const int TMXLayer::FAST_TMX_ORIENTATION_ISO = 2; +const int FastTMXLayer::FAST_TMX_ORIENTATION_ORTHO = 0; +const int FastTMXLayer::FAST_TMX_ORIENTATION_HEX = 1; +const int FastTMXLayer::FAST_TMX_ORIENTATION_ISO = 2; // FastTMXLayer - init & alloc & dealloc -TMXLayer * TMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) +FastTMXLayer * FastTMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { - TMXLayer *ret = new (std::nothrow) TMXLayer(); + FastTMXLayer *ret = new (std::nothrow) FastTMXLayer(); if (ret->initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo)) { ret->autorelease(); @@ -68,7 +69,7 @@ TMXLayer * TMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo return nullptr; } -bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) +bool FastTMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { if( tilesetInfo ) @@ -107,11 +108,11 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la return true; } -TMXLayer::TMXLayer() +FastTMXLayer::FastTMXLayer() { } -TMXLayer::~TMXLayer() +FastTMXLayer::~FastTMXLayer() { CC_SAFE_RELEASE(_tileSet); CC_SAFE_RELEASE(_texture); @@ -126,7 +127,7 @@ TMXLayer::~TMXLayer() } } -void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) +void FastTMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) { updateTotalQuads(); @@ -170,7 +171,7 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) } } -void TMXLayer::updateTiles(const Rect& culledRect) +void FastTMXLayer::updateTiles(const Rect& culledRect) { Rect visibleTiles = Rect(culledRect.origin, culledRect.size * Director::getInstance()->getContentScaleFactor()); Size mapTileSize = CC_SIZE_PIXELS_TO_POINTS(_mapTileSize); @@ -194,8 +195,8 @@ void TMXLayer::updateTiles(const Rect& culledRect) float tileSizeMax = std::max(tileSize.width, tileSize.height); if (_layerOrientation == FAST_TMX_ORIENTATION_ORTHO) { - tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1; - tilesOverY = ceil(tileSizeMax / mapTileSize.height) - 1; + tilesOverX = (int)ceil(tileSizeMax / mapTileSize.width) - 1; + tilesOverY = (int)ceil(tileSizeMax / mapTileSize.height) - 1; if (tilesOverX < 0) tilesOverX = 0; if (tilesOverY < 0) tilesOverY = 0; @@ -207,8 +208,8 @@ void TMXLayer::updateTiles(const Rect& culledRect) if (overTileRect.size.height < 0) overTileRect.size.height = 0; overTileRect = RectApplyTransform(overTileRect, nodeToTileTransform); - tilesOverX = ceil(overTileRect.origin.x + overTileRect.size.width) - floor(overTileRect.origin.x); - tilesOverY = ceil(overTileRect.origin.y + overTileRect.size.height) - floor(overTileRect.origin.y); + tilesOverX = (int)(ceil(overTileRect.origin.x + overTileRect.size.width) - floor(overTileRect.origin.x)); + tilesOverY = (int)(ceil(overTileRect.origin.y + overTileRect.size.height) - floor(overTileRect.origin.y)); } else { @@ -223,10 +224,10 @@ void TMXLayer::updateTiles(const Rect& culledRect) _indicesVertexZNumber[iter.first] = iter.second; } - int yBegin = std::max(0.f,visibleTiles.origin.y - tilesOverY); - int yEnd = std::min(_layerSize.height,visibleTiles.origin.y + visibleTiles.size.height + tilesOverY); - int xBegin = std::max(0.f,visibleTiles.origin.x - tilesOverX); - int xEnd = std::min(_layerSize.width,visibleTiles.origin.x + visibleTiles.size.width + tilesOverX); + int yBegin = static_cast(std::max(0.f,visibleTiles.origin.y - tilesOverY)); + int yEnd = static_cast(std::min(_layerSize.height,visibleTiles.origin.y + visibleTiles.size.height + tilesOverY)); + int xBegin = static_cast(std::max(0.f,visibleTiles.origin.x - tilesOverX)); + int xEnd = static_cast(std::min(_layerSize.width,visibleTiles.origin.x + visibleTiles.size.width + tilesOverX)); for (int y = yBegin; y < yEnd; ++y) { @@ -235,13 +236,12 @@ void TMXLayer::updateTiles(const Rect& culledRect) int tileIndex = getTileIndexByPos(x, y); if(_tiles[tileIndex] == 0) continue; - int vertexZ = getVertexZForPos(Vec2(x,y)); + int vertexZ = getVertexZForPos(Vec2((float)x,(float)y)); auto iter = _indicesVertexZNumber.find(vertexZ); int offset = iter->second; iter->second++; - int quadIndex = _tileToQuadIndex[tileIndex]; - CC_ASSERT(-1 != quadIndex); + unsigned short quadIndex = static_cast(_tileToQuadIndex[tileIndex]); _indices[6 * offset + 0] = quadIndex * 4 + 0; _indices[6 * offset + 1] = quadIndex * 4 + 1; _indices[6 * offset + 2] = quadIndex * 4 + 2; @@ -263,7 +263,7 @@ void TMXLayer::updateTiles(const Rect& culledRect) } -void TMXLayer::updateVertexBuffer() +void FastTMXLayer::updateVertexBuffer() { unsigned int vertexBufferSize = (unsigned int)(sizeof(V3F_C4B_T2F) * _totalQuads.size() * 4); if (!_vertexBuffer) @@ -274,7 +274,7 @@ void TMXLayer::updateVertexBuffer() _vertexBuffer->updateData(&_totalQuads[0], vertexBufferSize); } -void TMXLayer::updateIndexBuffer() +void FastTMXLayer::updateIndexBuffer() { #ifdef CC_FAST_TILEMAP_32_BIT_INDICES unsigned int indexBufferSize = (unsigned int)(sizeof(unsigned int) * _indices.size()); @@ -290,7 +290,7 @@ void TMXLayer::updateIndexBuffer() } // FastTMXLayer - setup Tiles -void TMXLayer::setupTiles() +void FastTMXLayer::setupTiles() { // Optimization: quick hack that sets the image size on the tileset _tileSet->_imageSize = _texture->getContentSizeInPixels(); @@ -326,11 +326,11 @@ void TMXLayer::setupTiles() break; } - _screenTileCount = _screenGridSize.width * _screenGridSize.height; + _screenTileCount = (int)(_screenGridSize.width * _screenGridSize.height); } -Mat4 TMXLayer::tileToNodeTransform() +Mat4 FastTMXLayer::tileToNodeTransform() { float w = _mapTileSize.width / CC_CONTENT_SCALE_FACTOR(); float h = _mapTileSize.height / CC_CONTENT_SCALE_FACTOR(); @@ -382,7 +382,7 @@ Mat4 TMXLayer::tileToNodeTransform() } -void TMXLayer::updatePrimitives() +void FastTMXLayer::updatePrimitives() { auto blendfunc = _texture->hasPremultipliedAlpha() ? BlendFunc::ALPHA_PREMULTIPLIED : BlendFunc::ALPHA_NON_PREMULTIPLIED; for(const auto& iter : _indicesVertexZNumber) @@ -408,16 +408,17 @@ void TMXLayer::updatePrimitives() if (_useAutomaticVertexZ) { CC_SAFE_RELEASE(pipelineDescriptor.programState); - auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColorAlphaTest_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST); + auto programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = programState; _alphaValueLocation = pipelineDescriptor.programState->getUniformLocation("u_alpha_value"); pipelineDescriptor.programState->setUniform(_alphaValueLocation, &_alphaFuncValue, sizeof(_alphaFuncValue)); - } else { CC_SAFE_RELEASE(pipelineDescriptor.programState); - auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + auto programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = programState; } auto vertexLayout = pipelineDescriptor.programState->getVertexLayout(); @@ -452,14 +453,14 @@ void TMXLayer::updatePrimitives() } } -void TMXLayer::setOpacity(uint8_t opacity) +void FastTMXLayer::setOpacity(uint8_t opacity) { Node::setOpacity(opacity); _quadsDirty = true; } -void TMXLayer::updateTotalQuads() +void FastTMXLayer::updateTotalQuads() { if(_quadsDirty) { @@ -476,12 +477,12 @@ void TMXLayer::updateTotalQuads() if (_texture->hasPremultipliedAlpha()) { - color.r *= color.a / 255.0f; - color.g *= color.a / 255.0f; - color.b *= color.a / 255.0f; + auto alpha = color.a / 255.0f; + color.r = static_cast(color.r * alpha); + color.g = static_cast(color.g * alpha); + color.b = static_cast(color.b * alpha); } - int quadIndex = 0; for(int y = 0; y < _layerSize.height; ++y) { @@ -501,11 +502,12 @@ void TMXLayer::updateTotalQuads() float left, right, top, bottom, z; - z = getVertexZForPos(Vec2(x, y)); - auto iter = _indicesVertexZOffsets.find(z); + int zPos = getVertexZForPos(Vec2((float)x, (float)y)); + z = (float)zPos; + auto iter = _indicesVertexZOffsets.find(zPos); if(iter == _indicesVertexZOffsets.end()) { - _indicesVertexZOffsets[z] = 1; + _indicesVertexZOffsets[zPos] = 1; } else { @@ -603,7 +605,7 @@ void TMXLayer::updateTotalQuads() } // removing / getting tiles -Sprite* TMXLayer::getTileAt(const Vec2& tileCoordinate) +Sprite* FastTMXLayer::getTileAt(const Vec2& tileCoordinate) { CCASSERT( tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position"); CCASSERT( _tiles, "TMXLayer: the tiles map has been released"); @@ -613,7 +615,7 @@ Sprite* TMXLayer::getTileAt(const Vec2& tileCoordinate) // if GID == 0, then no tile is present if( gid ) { - int index = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width; + int index = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width); auto it = _spriteContainer.find(index); if (it != _spriteContainer.end()) @@ -643,7 +645,7 @@ Sprite* TMXLayer::getTileAt(const Vec2& tileCoordinate) return tile; } -int TMXLayer::getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags/* = nullptr*/) +int FastTMXLayer::getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags/* = nullptr*/) { CCASSERT(tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles, "TMXLayer: the tiles map has been released"); @@ -669,12 +671,12 @@ int TMXLayer::getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags/* = n return (tile & kTMXFlippedMask); } -Vec2 TMXLayer::getPositionAt(const Vec2& pos) +Vec2 FastTMXLayer::getPositionAt(const Vec2& pos) { return PointApplyTransform(pos, _tileToNodeTransform); } -int TMXLayer::getVertexZForPos(const Vec2& pos) +int FastTMXLayer::getVertexZForPos(const Vec2& pos) { int ret = 0; int maxVal = 0; @@ -705,7 +707,7 @@ int TMXLayer::getVertexZForPos(const Vec2& pos) return ret; } -void TMXLayer::removeTileAt(const Vec2& tileCoordinate) +void FastTMXLayer::removeTileAt(const Vec2& tileCoordinate) { CCASSERT( tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position"); @@ -714,7 +716,7 @@ void TMXLayer::removeTileAt(const Vec2& tileCoordinate) if( gid ) { - int z = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width; + int z = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width); // remove tile from GID map setFlaggedTileGIDByIndex(z, 0); @@ -728,7 +730,7 @@ void TMXLayer::removeTileAt(const Vec2& tileCoordinate) } } -void TMXLayer::setFlaggedTileGIDByIndex(int index, uint32_t gid) +void FastTMXLayer::setFlaggedTileGIDByIndex(int index, uint32_t gid) { if(gid == _tiles[index]) return; _tiles[index] = gid; @@ -736,7 +738,7 @@ void TMXLayer::setFlaggedTileGIDByIndex(int index, uint32_t gid) _dirty = true; } -void TMXLayer::removeChild(Node* node, bool cleanup) +void FastTMXLayer::removeChild(Node* node, bool cleanup) { int tag = node->getTag(); auto it = _spriteContainer.find(tag); @@ -748,7 +750,7 @@ void TMXLayer::removeChild(Node* node, bool cleanup) } // TMXLayer - Properties -Value TMXLayer::getProperty(const std::string& propertyName) const +Value FastTMXLayer::getProperty(const std::string& propertyName) const { auto propItr = _properties.find(propertyName); if (propItr != _properties.end()) @@ -757,7 +759,7 @@ Value TMXLayer::getProperty(const std::string& propertyName) const return Value(); } -void TMXLayer::parseInternalProperties() +void FastTMXLayer::parseInternalProperties() { auto vertexz = getProperty("cc_vertexz"); if (vertexz.isNull()) return; @@ -777,7 +779,7 @@ void TMXLayer::parseInternalProperties() } //CCTMXLayer2 - obtaining positions, offset -Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos) +Vec2 FastTMXLayer::calculateLayerOffset(const Vec2& pos) { Vec2 ret; switch (_layerOrientation) @@ -798,12 +800,12 @@ Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos) } // TMXLayer - adding / remove tiles -void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate) +void FastTMXLayer::setTileGID(int gid, const Vec2& tileCoordinate) { setTileGID(gid, tileCoordinate, (TMXTileFlags)0); } -void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flags) +void FastTMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flags) { CCASSERT(tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles, "TMXLayer: the tiles map has been released"); @@ -824,13 +826,13 @@ void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flag // empty tile. create a new one else if (currentGID == 0) { - int z = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width; + int z = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width); setFlaggedTileGIDByIndex(z, gidAndFlags); } // modifying an existing tile with a non-empty tile else { - int z = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width; + int z = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width); auto it = _spriteContainer.find(z); if (it != _spriteContainer.end()) { @@ -854,7 +856,7 @@ void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flag } } -void TMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, uint32_t gid) +void FastTMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, uint32_t gid) { sprite->setPosition(getPositionAt(pos)); sprite->setPositionZ((float)getVertexZForPos(pos)); @@ -910,11 +912,10 @@ void TMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, uint32_t gid) } } -std::string TMXLayer::getDescription() const +std::string FastTMXLayer::getDescription() const { return StringUtils::format("", _tag, (int)_mapTileSize.width, (int)_mapTileSize.height); } -} //end of namespace experimental NS_CC_END diff --git a/cocos/2d/CCFastTMXLayer.h b/cocos/2d/CCFastTMXLayer.h index db8c92ab0d..f50bf7608b 100644 --- a/cocos/2d/CCFastTMXLayer.h +++ b/cocos/2d/CCFastTMXLayer.h @@ -45,8 +45,6 @@ namespace backend class Buffer; } -namespace experimental{ - /** * @addtogroup _2d * @{ @@ -78,7 +76,7 @@ namespace experimental{ * @js NA */ -class CC_DLL TMXLayer : public Node +class CC_DLL FastTMXLayer : public Node { public: /** Possible orientations of the TMX map */ @@ -93,16 +91,16 @@ public: * @param mapInfo A map info. * @return Return an autorelease object. */ - static TMXLayer * create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); + static FastTMXLayer * create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); /** * @js ctor */ - TMXLayer(); + FastTMXLayer(); /** * @js NA * @lua NA */ - virtual ~TMXLayer(); + virtual ~FastTMXLayer(); /** Returns the tile gid at a given tile coordinate. It also returns the tile flags. * @@ -278,7 +276,7 @@ public: void removeChild(Node* child, bool cleanup = true) override; protected: - virtual void setOpacity(GLubyte opacity) override; + virtual void setOpacity(uint8_t opacity) override; bool initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); void updateTiles(const Rect& culledRect); @@ -361,5 +359,4 @@ protected: // end of tilemap_parallax_nodes group /// @} -} //end of namespace experimental NS_CC_END diff --git a/cocos/2d/CCFastTMXTiledMap.cpp b/cocos/2d/CCFastTMXTiledMap.cpp index 7a29a3bb18..1a7e5ffff1 100644 --- a/cocos/2d/CCFastTMXTiledMap.cpp +++ b/cocos/2d/CCFastTMXTiledMap.cpp @@ -30,13 +30,12 @@ THE SOFTWARE. #include "base/ccUTF8.h" NS_CC_BEGIN -namespace experimental { // implementation FastTMXTiledMap -TMXTiledMap * TMXTiledMap::create(const std::string& tmxFile) +FastTMXTiledMap * FastTMXTiledMap::create(const std::string& tmxFile) { - TMXTiledMap *ret = new (std::nothrow) TMXTiledMap(); + FastTMXTiledMap *ret = new (std::nothrow) FastTMXTiledMap(); if (ret->initWithTMXFile(tmxFile)) { ret->autorelease(); @@ -46,9 +45,9 @@ TMXTiledMap * TMXTiledMap::create(const std::string& tmxFile) return nullptr; } -TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std::string& resourcePath) +FastTMXTiledMap* FastTMXTiledMap::createWithXML(const std::string& tmxString, const std::string& resourcePath) { - TMXTiledMap *ret = new (std::nothrow) TMXTiledMap(); + FastTMXTiledMap *ret = new (std::nothrow) FastTMXTiledMap(); if (ret->initWithXML(tmxString, resourcePath)) { ret->autorelease(); @@ -58,7 +57,7 @@ TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std: return nullptr; } -bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile) +bool FastTMXTiledMap::initWithTMXFile(const std::string& tmxFile) { CCASSERT(tmxFile.size()>0, "FastTMXTiledMap: tmx file should not be empty"); @@ -76,7 +75,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile) return true; } -bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath) +bool FastTMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath) { setContentSize(Size::ZERO); @@ -88,24 +87,24 @@ bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& r return true; } -TMXTiledMap::TMXTiledMap() +FastTMXTiledMap::FastTMXTiledMap() :_mapSize(Size::ZERO) ,_tileSize(Size::ZERO) { } -TMXTiledMap::~TMXTiledMap() +FastTMXTiledMap::~FastTMXTiledMap() { } // private -TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) +FastTMXLayer * FastTMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo); if (tileset == nullptr) return nullptr; - TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo); + FastTMXLayer *layer = FastTMXLayer::create(tileset, layerInfo, mapInfo); // tell the layerinfo to release the ownership of the tiles map. layerInfo->_ownTiles = false; @@ -114,7 +113,7 @@ TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) return layer; } -TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) +TMXTilesetInfo * FastTMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { Size size = layerInfo->_layerSize; auto& tilesets = mapInfo->getTilesets(); @@ -158,7 +157,7 @@ TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInf return nullptr; } -void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) +void FastTMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) { _mapSize = mapInfo->getMapSize(); _tileSize = mapInfo->getTileSize(); @@ -176,7 +175,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) for(const auto &layerInfo : layers) { if (layerInfo->_visible) { - TMXLayer *child = parseLayer(layerInfo, mapInfo); + FastTMXLayer *child = parseLayer(layerInfo, mapInfo); if (child == nullptr) { idx++; continue; @@ -196,13 +195,13 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) } // public -TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const +FastTMXLayer * FastTMXTiledMap::getLayer(const std::string& layerName) const { CCASSERT(layerName.size() > 0, "Invalid layer name!"); for (auto& child : _children) { - TMXLayer* layer = dynamic_cast(child); + FastTMXLayer* layer = dynamic_cast(child); if(layer) { if(layerName.compare( layer->getLayerName()) == 0) @@ -216,7 +215,7 @@ TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const return nullptr; } -TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const +TMXObjectGroup * FastTMXTiledMap::getObjectGroup(const std::string& groupName) const { CCASSERT(groupName.size() > 0, "Invalid group name!"); @@ -235,7 +234,7 @@ TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const return nullptr; } -Value TMXTiledMap::getProperty(const std::string& propertyName) const +Value FastTMXTiledMap::getProperty(const std::string& propertyName) const { auto propsItr = _properties.find(propertyName); if (propsItr != _properties.end()) @@ -244,7 +243,7 @@ Value TMXTiledMap::getProperty(const std::string& propertyName) const return Value(); } -Value TMXTiledMap::getPropertiesForGID(int GID) const +Value FastTMXTiledMap::getPropertiesForGID(int GID) const { auto propsItr = _tileProperties.find(GID); if (propsItr != _tileProperties.end()) @@ -253,12 +252,9 @@ Value TMXTiledMap::getPropertiesForGID(int GID) const return Value(); } -std::string TMXTiledMap::getDescription() const +std::string FastTMXTiledMap::getDescription() const { return StringUtils::format("(_children.size())); } -} //end of namespace experimental - NS_CC_END - diff --git a/cocos/2d/CCFastTMXTiledMap.h b/cocos/2d/CCFastTMXTiledMap.h index 477761ca45..9b344dd8f6 100644 --- a/cocos/2d/CCFastTMXTiledMap.h +++ b/cocos/2d/CCFastTMXTiledMap.h @@ -25,8 +25,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_FAST_TMX_TILEMAP_H__ -#define __CC_FAST_TMX_TILEMAP_H__ +#pragma once #include "2d/CCNode.h" #include "2d/CCTMXObjectGroup.h" @@ -36,10 +35,7 @@ NS_CC_BEGIN class TMXLayerInfo; class TMXTilesetInfo; class TMXMapInfo; - -namespace experimental { - -class TMXLayer; +class FastTMXLayer; /** * @addtogroup _2d * @{ @@ -97,14 +93,14 @@ class TMXLayer; * @since v3.2 * @js NA */ -class CC_DLL TMXTiledMap : public Node +class CC_DLL FastTMXTiledMap : public Node { public: /** Creates a TMX Tiled Map with a TMX file. * * @return An autorelease object. */ - static TMXTiledMap* create(const std::string& tmxFile); + static FastTMXTiledMap* create(const std::string& tmxFile); /** Initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources. * @@ -112,13 +108,13 @@ public: * @param resourcePath A path to TMX resources. * @return An autorelease object. */ - static TMXTiledMap* createWithXML(const std::string& tmxString, const std::string& resourcePath); + static FastTMXTiledMap* createWithXML(const std::string& tmxString, const std::string& resourcePath); /** Return the FastTMXLayer for the specific layer. * * @return Return the FastTMXLayer for the specific layer. */ - TMXLayer* getLayer(const std::string& layerName) const; + FastTMXLayer* getLayer(const std::string& layerName) const; /** Return the TMXObjectGroup for the specific group. * @@ -209,12 +205,12 @@ protected: /** * @js ctor */ - TMXTiledMap(); + FastTMXTiledMap(); /** * @js NA * @lua NA */ - virtual ~TMXTiledMap(); + virtual ~FastTMXTiledMap(); /** initializes a TMX Tiled Map with a TMX file */ bool initWithTMXFile(const std::string& tmxFile); @@ -222,7 +218,7 @@ protected: /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */ bool initWithXML(const std::string& tmxString, const std::string& resourcePath); - TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); + FastTMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); void buildWithMapInfo(TMXMapInfo* mapInfo); @@ -241,17 +237,12 @@ protected: ValueMapIntKey _tileProperties; private: - CC_DISALLOW_COPY_AND_ASSIGN(TMXTiledMap); + CC_DISALLOW_COPY_AND_ASSIGN(FastTMXTiledMap); }; // end of tilemap_parallax_nodes group /** @} */ -} //end of namespace experimental NS_CC_END - -#endif //__CCTMX_TILE_MAP2_H__ - - diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index fbe43779cc..5818b2c204 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -52,7 +52,7 @@ FontAtlas::FontAtlas(Font &theFont) _fontFreeType = dynamic_cast(_font); if (_fontFreeType) { - _lineHeight = _font->getFontMaxHeight(); + _lineHeight = (float)_font->getFontMaxHeight(); _fontAscender = _fontFreeType->getFontAscender(); _letterEdgeExtend = 2; @@ -60,6 +60,13 @@ FontAtlas::FontAtlas(Font &theFont) { _letterPadding += 2 * FontFreeType::DistanceMapSpread; } + + auto outlineSize = _fontFreeType->getOutlineSize(); + if (outlineSize > 0) + { + _lineHeight += 2 * outlineSize; + } + #if CC_ENABLE_CACHE_TEXTURE_DATA auto eventDispatcher = Director::getInstance()->getEventDispatcher(); @@ -87,7 +94,6 @@ void FontAtlas::reinit() auto outlineSize = _fontFreeType->getOutlineSize(); if(outlineSize > 0) { - _lineHeight += 2 * outlineSize; _currentPageDataSize *= 2; _currentPageDataSizeRGBA = _currentPageDataSize * 2; @@ -203,7 +209,7 @@ void FontAtlas::scaleFontLetterDefinition(float scaleFactor) letterDefinition.height *= scaleFactor; letterDefinition.offsetX *= scaleFactor; letterDefinition.offsetY *= scaleFactor; - letterDefinition.xAdvance *= scaleFactor; + letterDefinition.xAdvance = (int)(letterDefinition.xAdvance * scaleFactor); } } @@ -379,7 +385,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text) auto scaleFactor = CC_CONTENT_SCALE_FACTOR(); auto pixelFormat = _fontFreeType->getOutlineSize() > 0 ? backend::PixelFormat::AI88 : backend::PixelFormat::A8; - float startY = _currentPageOrigY; + int startY = (int)_currentPageOrigY; for (auto&& it : codeMapOfNewChar) { @@ -401,7 +407,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text) { updateTextureContent(pixelFormat, startY); - startY = 0.0f; + startY = 0; _currentPageOrigY = 0; memset(_currentPageData, 0, _currentPageDataSize); @@ -428,7 +434,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text) { _currLineHeight = glyphHeight; } - _fontFreeType->renderCharAt(_currentPageData, _currentPageOrigX + adjustForExtend, _currentPageOrigY + adjustForExtend, bitmap, bitmapWidth, bitmapHeight); + _fontFreeType->renderCharAt(_currentPageData, (int)_currentPageOrigX + adjustForExtend, (int)_currentPageOrigY + adjustForExtend, bitmap, bitmapWidth, bitmapHeight); tempDef.U = _currentPageOrigX; tempDef.V = _currentPageOrigY; @@ -471,7 +477,7 @@ void FontAtlas::updateTextureContent(backend::PixelFormat format, int startY) auto outlineSize = _fontFreeType->getOutlineSize(); if (outlineSize > 0 && format == backend::PixelFormat::AI88) { - int nLen = CacheTextureWidth * (_currentPageOrigY - startY + _currLineHeight); + int nLen = CacheTextureWidth * ((int)_currentPageOrigY - startY + _currLineHeight); data = _currentPageData + CacheTextureWidth * (int)startY * 2; memset(_currentPageDataRGBA, 0, 4 * nLen); for (auto i = 0; i < nLen; i++) @@ -479,12 +485,12 @@ void FontAtlas::updateTextureContent(backend::PixelFormat format, int startY) _currentPageDataRGBA[i*4] = data[i*2]; _currentPageDataRGBA[i*4+3] = data[i*2+1]; } - _atlasTextures[_currentPage]->updateWithData(_currentPageDataRGBA, 0, startY, CacheTextureWidth, _currentPageOrigY - startY + _currLineHeight); + _atlasTextures[_currentPage]->updateWithData(_currentPageDataRGBA, 0, startY, CacheTextureWidth, (int)_currentPageOrigY - startY + _currLineHeight); } else { data = _currentPageData + CacheTextureWidth * (int)startY; - _atlasTextures[_currentPage]->updateWithData(data, 0, startY, CacheTextureWidth, _currentPageOrigY - startY + _currLineHeight); + _atlasTextures[_currentPage]->updateWithData(data, 0, startY, CacheTextureWidth, (int)_currentPageOrigY - startY + _currLineHeight); } } diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index 790f67cdd9..6240c16a3d 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -71,7 +71,7 @@ FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config) if ( it == _atlasMap.end() ) { auto font = FontFreeType::create(realFontFilename, config->fontSize, config->glyphs, - config->customGlyphs, useDistanceField, config->outlineSize); + config->customGlyphs, useDistanceField, (float)config->outlineSize); if (font) { auto tempAtlas = font->createFontAtlas(); diff --git a/cocos/2d/CCFontCharMap.cpp b/cocos/2d/CCFontCharMap.cpp index ab958166ab..ee4f1b796b 100644 --- a/cocos/2d/CCFontCharMap.cpp +++ b/cocos/2d/CCFontCharMap.cpp @@ -114,7 +114,7 @@ FontAtlas * FontCharMap::createFontAtlas() int itemsPerColumn = (int)(s.height / _itemHeight); int itemsPerRow = (int)(s.width / _itemWidth); - tempAtlas->setLineHeight(_itemHeight); + tempAtlas->setLineHeight((float)_itemHeight); auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR(); diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index daa5720810..4724e13450 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -617,7 +617,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffse } FontFNT *tempFont = new FontFNT(newConf,imageOffset); - tempFont->setFontSize(newConf->_fontSize); + tempFont->setFontSize((float)newConf->_fontSize); if (!tempFont) { return nullptr; @@ -713,7 +713,7 @@ FontAtlas * FontFNT::createFontAtlas() // common height int originalFontSize = _configuration->_fontSize; - float originalLineHeight = _configuration->_commonHeight; + float originalLineHeight = (float)_configuration->_commonHeight; float factor = 0.0f; if (std::abs(_fontSize - originalFontSize) < FLT_EPSILON) { factor = 1.0f; diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 78e82b6bf8..63d36d391e 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -257,13 +257,13 @@ int * FontFreeType::getHorizontalKerningForTextUTF32(const std::u32string& text, int FontFreeType::getHorizontalKerningForChars(uint64_t firstChar, uint64_t secondChar) const { // get the ID to the char we need - int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar); + int glyphIndex1 = FT_Get_Char_Index(_fontRef, static_cast(firstChar)); if (!glyphIndex1) return 0; // get the ID to the char we need - int glyphIndex2 = FT_Get_Char_Index(_fontRef, secondChar); + int glyphIndex2 = FT_Get_Char_Index(_fontRef, static_cast(secondChar)); if (!glyphIndex2) return 0; @@ -301,20 +301,20 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo if (_distanceFieldEnabled) { - if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT)) + if (FT_Load_Char(_fontRef, static_cast(theChar), FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT)) break; } else { - if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT)) + if (FT_Load_Char(_fontRef, static_cast(theChar), FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT)) break; } auto& metrics = _fontRef->glyph->metrics; - outRect.origin.x = metrics.horiBearingX >> 6; - outRect.origin.y = -(metrics.horiBearingY >> 6); - outRect.size.width = (metrics.width >> 6); - outRect.size.height = (metrics.height >> 6); + outRect.origin.x = static_cast(metrics.horiBearingX >> 6); + outRect.origin.y = static_cast(-(metrics.horiBearingY >> 6)); + outRect.size.width = static_cast((metrics.width >> 6)); + outRect.size.height = static_cast((metrics.height >> 6)); xAdvance = (static_cast(_fontRef->glyph->metrics.horiAdvance >> 6)); @@ -336,10 +336,10 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo break; } - long glyphMinX = outRect.origin.x; - long glyphMaxX = outRect.origin.x + outWidth; - long glyphMinY = -outHeight - outRect.origin.y; - long glyphMaxY = -outRect.origin.y; + int glyphMinX = (int)outRect.origin.x; + int glyphMaxX = (int)(outRect.origin.x + outWidth); + int glyphMinY = (int)(-outHeight - outRect.origin.y); + int glyphMaxY = (int)-outRect.origin.y; auto outlineMinX = bbox.xMin >> 6; auto outlineMaxX = bbox.xMax >> 6; @@ -353,15 +353,16 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo auto blendWidth = MAX(outlineMaxX, glyphMaxX) - blendImageMinX; auto blendHeight = blendImageMaxY - MIN(outlineMinY, glyphMinY); - outRect.origin.x = blendImageMinX; + outRect.origin.x = (float)blendImageMinX; outRect.origin.y = -blendImageMaxY + _outlineSize; unsigned char *blendImage = nullptr; if (blendWidth > 0 && blendHeight > 0) { - long index, index2; - blendImage = new (std::nothrow) unsigned char[blendWidth * blendHeight * 2]; - memset(blendImage, 0, blendWidth * blendHeight * 2); + FT_Pos index, index2; + auto imageSize = blendWidth * blendHeight * 2; + blendImage = new (std::nothrow) unsigned char[imageSize]; + memset(blendImage, 0, imageSize); auto px = outlineMinX - blendImageMinX; auto py = blendImageMaxY - outlineMaxY; @@ -388,8 +389,8 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo } } - outRect.size.width = blendWidth; - outRect.size.height = blendHeight; + outRect.size.width = (float)blendWidth; + outRect.size.height = (float)blendHeight; outWidth = blendWidth; outHeight = blendHeight; @@ -418,7 +419,7 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo unsigned char * FontFreeType::getGlyphBitmapWithOutline(uint64_t theChar, FT_BBox &bbox) { unsigned char* ret = nullptr; - if (FT_Load_Char(_fontRef, theChar, FT_LOAD_NO_BITMAP) == 0) + if (FT_Load_Char(_fontRef, static_cast(theChar), FT_LOAD_NO_BITMAP) == 0) { if (_fontRef->glyph->format == FT_GLYPH_FORMAT_OUTLINE) { diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index efd0f1559c..3517a0b3a1 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -32,9 +32,10 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "renderer/CCTexture2D.h" #include "renderer/ccShaders.h" +#include "renderer/backend/ProgramState.h" #include "renderer/backend/Device.h" #include "2d/CCCamera.h" -#include "renderer/backend/ProgramState.h" + NS_CC_BEGIN // implementation of GridBase @@ -108,7 +109,8 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipp auto& pipelineDescriptor = _drawCommand.getPipelineDescriptor(); CC_SAFE_RELEASE(_programState); - _programState = new (std::nothrow) backend::ProgramState(positionTexture_vert, positionTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture"); @@ -212,7 +214,7 @@ void GridBase::beforeDraw() _directorProjection = director->getProjection(); set2DProjection(); Size size = director->getWinSizeInPixels(); - renderer->setViewPort(0, 0, size.width, size.height); + renderer->setViewPort(0, 0, (unsigned int)size.width, (unsigned int)size.height); RenderTargetFlag flags = RenderTargetFlag::COLOR; _oldColorAttachment = renderer->getColorAttachment(); @@ -407,20 +409,20 @@ void Grid3D::calculateVertexPoints() float height = (float)_texture->getPixelsHigh(); float imageH = _texture->getContentSizeInPixels().height; - size_t x = 0, y = 0, i = 0; + int x = 0, y = 0, i = 0; CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_originalVertices); CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_vertexBuffer); CC_SAFE_FREE(_indices); - size_t numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); + size_t numOfPoints = static_cast((_gridSize.width+1) * (_gridSize.height+1)); _vertices = malloc(numOfPoints * sizeof(Vec3)); _originalVertices = malloc(numOfPoints * sizeof(Vec3)); _texCoordinates = malloc(numOfPoints * sizeof(Vec2)); _vertexBuffer = malloc(numOfPoints * (sizeof(Vec3) + sizeof(Vec2))); - _indices = (unsigned short*)malloc(_gridSize.width * _gridSize.height * sizeof(unsigned short) * 6); + _indices = (unsigned short*)malloc(static_cast(_gridSize.width * _gridSize.height * sizeof(unsigned short) * 6)); float *vertArray = (float*)_vertices; float *texArray = (float*)_texCoordinates; @@ -430,7 +432,7 @@ void Grid3D::calculateVertexPoints() { for (y = 0; y < _gridSize.height; ++y) { - int idx = (y * _gridSize.width) + x; + int idx = (int)(y * _gridSize.width) + x; float x1 = x * _step.x + _gridRect.origin.x; float x2 = x1 + _step.x; @@ -479,14 +481,14 @@ void Grid3D::calculateVertexPoints() updateVertexAndTexCoordinate(); - memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3)); + memcpy(_originalVertices, _vertices, static_cast((_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3))); } Vec3 Grid3D::getVertex(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); - int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; + int index = (int)(pos.x * (_gridSize.height+1) + pos.y) * 3; float *vertArray = (float*)_vertices; Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); @@ -498,7 +500,7 @@ Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); - int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; + int index = (int)(pos.x * (_gridSize.height+1) + pos.y) * 3; float *vertArray = (float*)_originalVertices; Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); @@ -509,7 +511,7 @@ Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const void Grid3D::setVertex(const Vec2& pos, const Vec3& vertex) { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); - int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3; + int index = (int)(pos.x * (_gridSize.height + 1) + pos.y) * 3; float *vertArray = (float*)_vertices; vertArray[index] = vertex.x; vertArray[index+1] = vertex.y; @@ -520,14 +522,14 @@ void Grid3D::reuse() { if (_reuseGrid > 0) { - memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3)); + memcpy(_originalVertices, _vertices, static_cast((_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3))); --_reuseGrid; } } void Grid3D::updateVertexBuffer() { - size_t numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); + size_t numOfPoints = static_cast((_gridSize.width+1) * (_gridSize.height+1)); auto tempVecPointer = (Vec3*)_vertices; for (size_t i = 0; i < numOfPoints; ++i) { @@ -536,15 +538,15 @@ void Grid3D::updateVertexBuffer() } _drawCommand.updateVertexBuffer(_vertexBuffer, (unsigned int)(numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2)) ); - _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short)); + _drawCommand.updateIndexBuffer(_indices, static_cast(_gridSize.width * _gridSize.height * 6 * sizeof(unsigned short))); } void Grid3D::updateVertexAndTexCoordinate() { - unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); + unsigned int numOfPoints = static_cast((_gridSize.width+1) * (_gridSize.height+1)); auto tempVecPointer = (Vec3*)_vertices; auto tempTexPointer = (Vec2*)_texCoordinates; - for (size_t i = 0; i < numOfPoints; ++i) + for (unsigned int i = 0; i < numOfPoints; ++i) { auto offset = i * (sizeof(Vec3) + sizeof(Vec2)); memcpy((char*)_vertexBuffer + offset, &tempVecPointer[i], sizeof(Vec3)); @@ -553,8 +555,9 @@ void Grid3D::updateVertexAndTexCoordinate() _drawCommand.createVertexBuffer((unsigned int)(sizeof(Vec3) + sizeof(Vec2)), numOfPoints, CustomCommand::BufferUsage::DYNAMIC); _drawCommand.updateVertexBuffer(_vertexBuffer, numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2)); - _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, _gridSize.width * _gridSize.height * 6, CustomCommand::BufferUsage::DYNAMIC); - _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short)); + unsigned int capacity = (unsigned int)(_gridSize.width * _gridSize.height) * 6; + _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, capacity, CustomCommand::BufferUsage::DYNAMIC); + _drawCommand.updateIndexBuffer(_indices, capacity * sizeof(unsigned short)); } // implementation of TiledGrid3D @@ -663,7 +666,7 @@ void TiledGrid3D::calculateVertexPoints() float height = (float)_texture->getPixelsHigh(); float imageH = _texture->getContentSizeInPixels().height; - int numQuads = _gridSize.width * _gridSize.height; + int numQuads = (int)(_gridSize.width * _gridSize.height); CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_originalVertices); CC_SAFE_FREE(_texCoordinates); @@ -741,7 +744,7 @@ void TiledGrid3D::calculateVertexPoints() void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords) { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); - int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; + int idx = (int)(_gridSize.height * pos.x + pos.y) * 4 * 3; float *vertArray = (float*)_vertices; memcpy(&vertArray[idx], &coords, sizeof(Quad3)); } @@ -749,7 +752,7 @@ void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords) Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); - int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; + int idx = (int)(_gridSize.height * pos.x + pos.y) * 4 * 3; float *vertArray = (float*)_originalVertices; Quad3 ret; @@ -761,7 +764,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const Quad3 TiledGrid3D::getTile(const Vec2& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); - int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; + int idx = (int)(_gridSize.height * pos.x + pos.y) * 4 * 3; float *vertArray = (float*)_vertices; Quad3 ret; @@ -774,7 +777,7 @@ void TiledGrid3D::reuse() { if (_reuseGrid > 0) { - int numQuads = _gridSize.width * _gridSize.height; + int numQuads = (int)(_gridSize.width * _gridSize.height); memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(float)); --_reuseGrid; @@ -783,7 +786,8 @@ void TiledGrid3D::reuse() void TiledGrid3D::updateVertexBuffer() { - size_t numOfPoints = _gridSize.width * _gridSize.height * 4; + size_t gradSize = static_cast(_gridSize.width * _gridSize.height); + size_t numOfPoints = gradSize * 4; auto tempVecPointer = (Vec3*)_vertices; for (size_t i = 0; i < numOfPoints; ++i) { @@ -792,12 +796,13 @@ void TiledGrid3D::updateVertexBuffer() } _drawCommand.updateVertexBuffer(_vertexBuffer, (unsigned int)(numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2)) ); - _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short)); + _drawCommand.updateIndexBuffer(_indices, gradSize * 6 * sizeof(unsigned short)); } void TiledGrid3D::updateVertexAndTexCoordinate() { - unsigned int numOfPoints = _gridSize.width * _gridSize.height * 4; + size_t gradSize = static_cast(_gridSize.width * _gridSize.height); + auto numOfPoints = gradSize * 4; auto tempVecPointer = (Vec3*)_vertices; auto tempTexPointer = (Vec2*)_texCoordinates; for (size_t i = 0; i < numOfPoints; ++i) @@ -806,11 +811,11 @@ void TiledGrid3D::updateVertexAndTexCoordinate() memcpy((char*)_vertexBuffer + offset, &tempVecPointer[i], sizeof(Vec3)); memcpy((char*)_vertexBuffer + offset + sizeof(Vec3), &tempTexPointer[i], sizeof(Vec2)); } - _drawCommand.createVertexBuffer((unsigned int)(sizeof(Vec3) + sizeof(Vec2) ), numOfPoints, CustomCommand::BufferUsage::DYNAMIC); + _drawCommand.createVertexBuffer((sizeof(Vec3) + sizeof(Vec2) ), numOfPoints, CustomCommand::BufferUsage::DYNAMIC); _drawCommand.updateVertexBuffer(_vertexBuffer, numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2)); - _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, _gridSize.width * _gridSize.height * 6, CustomCommand::BufferUsage::DYNAMIC); - _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short)); + _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, gradSize * 6, CustomCommand::BufferUsage::DYNAMIC); + _drawCommand.updateIndexBuffer(_indices, gradSize * 6 * sizeof(unsigned short)); } NS_CC_END diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 055d9b6138..b06c151702 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -25,9 +25,9 @@ ****************************************************************************/ #include "2d/CCLabel.h" - #include - +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCFont.h" #include "2d/CCFontAtlasCache.h" #include "2d/CCFontAtlas.h" @@ -688,7 +688,8 @@ void Label::updateShaderProgram() } CC_SAFE_RELEASE(_programState); - _programState = new backend::ProgramState(programType); + auto* program = backend::Program::getBuiltinProgram(programType); + _programState = new backend::ProgramState(program); updateUniformLocations(); @@ -1568,7 +1569,7 @@ void Label::updateContent() // FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is POT y += spriteSize.height / 2; // FIXME: Might not work with different vertical alignments - _underlineNode->drawLine(Vec2(0,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor())); + _underlineNode->drawLine(Vec2(0.0f,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor())); } } @@ -1581,9 +1582,9 @@ void Label::updateContent() Vec2 vertices[4] = { Vec2::ZERO, - Vec2(_contentSize.width, 0), + Vec2(_contentSize.width, 0.0f), Vec2(_contentSize.width, _contentSize.height), - Vec2(0, _contentSize.height) + Vec2(0.0f, _contentSize.height) }; _debugDrawNode->drawPoly(vertices, 4, true, Color4F::WHITE); #endif diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 27b40f9061..9fa24cada0 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -264,7 +264,7 @@ void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) Vec2::ZERO, Vec2(size.width, 0), Vec2(size.width, size.height), - Vec2(0, size.height) + Vec2(0.0f, size.height) }; _debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0)); } diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 602834e78a..941b2e4ab9 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -288,7 +288,8 @@ LayerColor::LayerColor() _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(positionColor_vert, positionColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; auto vertexLayout = _programState->getVertexLayout(); @@ -705,7 +706,8 @@ LayerRadialGradient* LayerRadialGradient::create() LayerRadialGradient::LayerRadialGradient() { auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(position_vert, layer_radialGradient_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::LAYER_RADIA_GRADIENT); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); _startColorLocation = pipelineDescriptor.programState->getUniformLocation("u_startColor"); diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index cc77216152..38e62b61a8 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -427,7 +427,7 @@ protected: Color3B _endColor = Color3B::BLACK; uint8_t _startOpacity = 255; uint8_t _endOpacity = 255; - Vec2 _alongVector = {0, -1}; + Vec2 _alongVector = {0.0f, -1.0f}; bool _compressedInterpolation = true; }; diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index a24eddc948..fa7f129e42 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -42,7 +42,8 @@ MotionStreak::MotionStreak() _customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP); auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture"); diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 7ecf261ffe..f203c62dc6 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -809,22 +809,27 @@ void Node::enumerateChildren(const std::string &name, std::functiondoEnumerateRecursive(target, newName, callback); } else { // name is xxx - doEnumerate(newName, callback); + target->doEnumerate(newName, callback); } } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 2f1dccd7b2..bbab0deef6 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -794,7 +794,7 @@ public: * @param name The name to search for, supports c++11 regular expression. * Search syntax options: * `//`: Can only be placed at the begin of the search string. This indicates that it will search recursively. - * `..`: The search should move up to the node's parent. Can only be placed at the end of string. + * `/..`: The search should move up to the node's parent. Can only be placed at the end of string. * `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children. * * @code diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index ebc58f12da..e6ab3b9ea0 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -29,6 +29,8 @@ * */ #include "2d/CCParticleBatchNode.h" +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCGrid.h" #include "2d/CCParticleSystem.h" #include "renderer/CCTextureCache.h" @@ -46,7 +48,8 @@ NS_CC_BEGIN ParticleBatchNode::ParticleBatchNode() { auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture"); diff --git a/cocos/2d/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp index 1cda033e87..3fe170d78a 100644 --- a/cocos/2d/CCParticleExamples.cpp +++ b/cocos/2d/CCParticleExamples.cpp @@ -1076,7 +1076,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(winSize.width/2, winSize.height + 10); - setPosVar(Vec2(winSize.width/2, 0)); + setPosVar(Vec2(winSize.width/2, 0.0f)); // angle _angle = -90; @@ -1188,7 +1188,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles) // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(winSize.width/2, winSize.height); - setPosVar(Vec2(winSize.width/2, 0)); + setPosVar(Vec2(winSize.width/2, 0.0f)); // life of particles _life = 4.5f; diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 09dc7d2ff7..f69c9048d2 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -26,12 +26,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - - #include "2d/CCParticleSystemQuad.h" - #include - +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCSpriteFrame.h" #include "2d/CCParticleBatchNode.h" #include "renderer/CCTextureAtlas.h" @@ -50,7 +48,8 @@ NS_CC_BEGIN ParticleSystemQuad::ParticleSystemQuad() { auto& pipelieDescriptor = _quadCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + _programState = new (std::nothrow) backend::ProgramState(program); pipelieDescriptor.programState = _programState; _mvpMatrixLocaiton = pipelieDescriptor.programState->getUniformLocation("u_MVPMatrix"); _textureLocation = pipelieDescriptor.programState->getUniformLocation("u_texture"); diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index ac05931f9a..d385c3d570 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -25,9 +25,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "2d/CCProgressTimer.h" - #include - +#include // offsetof +#include "base/ccTypes.h" #include "base/ccMacros.h" #include "base/CCDirector.h" #include "2d/CCSprite.h" @@ -47,7 +47,8 @@ namespace backend::ProgramState* initPipelineDescriptor(cocos2d::CustomCommand& command, bool ridal, backend::UniformLocation &locMVP, backend::UniformLocation &locTexture) { auto& pipelieDescriptor = command.getPipelineDescriptor(); - auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + auto programState = new (std::nothrow) backend::ProgramState(program); CC_SAFE_RELEASE(pipelieDescriptor.programState); pipelieDescriptor.programState = programState; diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index c66d1a3ddc..c7bdcf7599 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -196,7 +196,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, backend::PixelFormat fo _texture2D = new (std::nothrow) Texture2D(); if (_texture2D) { - _texture2D->initWithBackendTexture(texture); + _texture2D->initWithBackendTexture(texture, CC_ENABLE_PREMULTIPLIED_ALPHA != 0); _texture2D->setRenderTarget(true); texture->release(); } @@ -240,8 +240,14 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, backend::PixelFormat fo #if defined(CC_USE_GL) || defined(CC_USE_GLES) _sprite->setFlippedY(true); #endif - _sprite->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); + +#if CC_ENABLE_PREMULTIPLIED_ALPHA != 0 + _sprite->setBlendFunc(BlendFunc::ALPHA_PREMULTIPLIED); _sprite->setOpacityModifyRGB(true); +#else + _sprite->setBlendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED); + _sprite->setOpacityModifyRGB(false); +#endif // Disabled by default. _autoDraw = false; @@ -472,7 +478,7 @@ void RenderTexture::newImage(std::function imageCallback, bool fli Image *image = new (std::nothrow) Image(); auto initCallback = [&, savedBufferWidth, savedBufferHeight, imageCallback](Image* image, const unsigned char* tempData){ - image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, true); + image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, _texture2D->hasPremultipliedAlpha()); imageCallback(image); }; auto callback = std::bind(initCallback, image, std::placeholders::_1); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 0e1f1709ab..eb20451354 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -26,9 +26,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "2d/CCSprite.h" - #include - +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCSpriteBatchNode.h" #include "2d/CCAnimationCache.h" #include "2d/CCSpriteFrame.h" @@ -42,6 +42,7 @@ THE SOFTWARE. #include "platform/CCFileUtils.h" #include "renderer/ccShaders.h" #include "renderer/backend/ProgramState.h" +#include "renderer/backend/Device.h" NS_CC_BEGIN @@ -259,10 +260,6 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) _recursiveDirty = false; setDirty(false); - _opacityModifyRGB = true; - - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - _flippedX = _flippedY = false; // default transform anchor: center @@ -378,9 +375,11 @@ void Sprite::setVertexLayout() void Sprite::updateShaders(const char* vert, const char* frag) { - auto programState = new (std::nothrow) backend::ProgramState(vert, frag); + auto* program = backend::Device::getInstance()->newProgram(vert, frag); + auto programState = new (std::nothrow) backend::ProgramState(program); setProgramState(programState); - CC_SAFE_RELEASE_NULL(programState); + CC_SAFE_RELEASE(programState); + CC_SAFE_RELEASE(program); } void Sprite::setProgramState(backend::ProgramType type) @@ -389,7 +388,8 @@ void Sprite::setProgramState(backend::ProgramType type) _programState->getProgram()->getProgramType() == type) return; - auto programState = new (std::nothrow) backend::ProgramState(type); + auto* program = backend::Program::getBuiltinProgram(type); + auto programState = new (std::nothrow) backend::ProgramState(program); setProgramState(programState); CC_SAFE_RELEASE_NULL(programState); } @@ -411,7 +411,7 @@ void Sprite::setProgramState(backend::ProgramState *programState) _alphaTextureLocation = pipelineDescriptor.programState->getUniformLocation(backend::Uniform::TEXTURE1); setVertexLayout(); - updateProgramState(); + updateProgramStateTexture(); setMVPMatrixUniform(); } @@ -419,7 +419,6 @@ void Sprite::setTexture(Texture2D *texture) { auto isETC1 = texture && texture->getAlphaTextureName(); setProgramState((isETC1) ? backend::ProgramType::ETC1 : backend::ProgramType::POSITION_TEXTURE_COLOR); - CCASSERT(! _batchNode || (texture && texture == _batchNode->getTexture()), "CCSprite: Batched sprites should use the same texture as the batchnode"); // accept texture==nil as argument CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument"); @@ -451,11 +450,10 @@ void Sprite::setTexture(Texture2D *texture) } updateBlendFunc(); } - - updateProgramState(); + updateProgramStateTexture(); } -void Sprite::updateProgramState() +void Sprite::updateProgramStateTexture() { if (_texture == nullptr || _texture->getBackendTexture() == nullptr) return; diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index d5f012a00a..0f0d5c14ab 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -635,7 +635,7 @@ protected: virtual void setDirtyRecursively(bool value); virtual void flipX(); virtual void flipY(); - virtual void updateProgramState(); + virtual void updateProgramStateTexture(); void updatePoly(); void updateStretchFactor(); diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 66174a08d5..5082f4d9b3 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -26,8 +26,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "2d/CCSpriteBatchNode.h" +#include // offsetof +#include "base/ccTypes.h" #include "2d/CCSprite.h" #include "base/CCDirector.h" #include "base/CCProfiling.h" @@ -37,7 +38,7 @@ THE SOFTWARE. #include "renderer/CCQuadCommand.h" #include "renderer/ccShaders.h" #include "renderer/backend/ProgramState.h" - +#include "renderer/backend/Device.h" NS_CC_BEGIN @@ -115,12 +116,14 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAU void SpriteBatchNode::updateShaders(const std::string &vertexShader, const std::string &fragmentShader) { auto& pipelineDescriptor = _quadCommand.getPipelineDescriptor(); + auto* program = backend::Device::getInstance()->newProgram(vertexShader, fragmentShader); CC_SAFE_RELEASE(_programState); - _programState = new (std::nothrow) backend::ProgramState(vertexShader, fragmentShader); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture"); - + CC_SAFE_RELEASE(program); + auto vertexLayout = _programState->getVertexLayout(); const auto& attributeInfo = _programState->getProgram()->getActiveAttributes(); auto iter = attributeInfo.find("a_position"); diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index a5316ae876..57bd730af0 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -384,7 +384,10 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist) // remove .xxx size_t startPos = texturePath.find_last_of('.'); - texturePath = texturePath.erase(startPos); + if(startPos != string::npos) + { + texturePath = texturePath.erase(startPos); + } // append .png texturePath = texturePath.append(".png"); @@ -686,8 +689,11 @@ bool SpriteFrameCache::reloadTexture(const std::string& plist) // remove .xxx size_t startPos = texturePath.find_last_of('.'); - texturePath = texturePath.erase(startPos); - + if(startPos != string::npos) + { + texturePath = texturePath.erase(startPos); + } + // append .png texturePath = texturePath.append(".png"); } diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 0fa38414cd..f4bc2ee17d 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -424,7 +424,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vec2& pos) for(const auto &child : _children) { Sprite* sp = static_cast(child); - ssize_t ai = sp->getAtlasIndex(); + auto ai = sp->getAtlasIndex(); if ( ai >= indexForZ ) { sp->setAtlasIndex(ai+1); @@ -449,8 +449,8 @@ Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vec2& pos) setupTileSprite(tile ,pos ,gid); // get atlas index - ssize_t indexForZ = atlasIndexForExistantZ(z); - tile->setAtlasIndex(indexForZ); + auto indexForZ = atlasIndexForExistantZ(z); + tile->setAtlasIndex(static_cast(indexForZ) ); tile->setDirty(true); tile->updateTransform(); _tiles[z] = gid; @@ -671,7 +671,7 @@ void TMXLayer::removeTileAt(const Vec2& pos) // update possible children for(const auto &obj : _children) { Sprite* child = static_cast(obj); - ssize_t ai = child->getAtlasIndex(); + auto ai = child->getAtlasIndex(); if ( ai >= atlasIndex ) { child->setAtlasIndex(ai-1); diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index 1dcb12b749..ba3245d575 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -416,9 +416,9 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts { TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back(); - double tileOffsetX = attributeDict["x"].asDouble(); + float tileOffsetX = attributeDict["x"].asFloat(); - double tileOffsetY = attributeDict["y"].asDouble(); + float tileOffsetY = attributeDict["y"].asFloat(); tileset->_tileOffset = Vec2(tileOffsetX, tileOffsetY); diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 50ceddd665..922b6cb547 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -360,7 +360,7 @@ void TransitionJumpZoom::onEnter() _inScene->setAnchorPoint(Vec2(0.5f, 0.5f)); _outScene->setAnchorPoint(Vec2(0.5f, 0.5f)); - ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0), s.width/4, 2); + ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0.0f), s.width/4, 2); ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f); ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f); @@ -425,7 +425,7 @@ void TransitionMoveInL::onEnter() ActionInterval* TransitionMoveInL::action() { - return MoveTo::create(_duration, Vec2(0,0)); + return MoveTo::create(_duration, Vec2(0.0f,0.0f)); } ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action) @@ -569,13 +569,13 @@ void TransitionSlideInL::sceneOrder() void TransitionSlideInL:: initScenes() { Size s = Director::getInstance()->getWinSize(); - _inScene->setPosition(-(s.width-ADJUST_FACTOR),0); + _inScene->setPosition(-(s.width-ADJUST_FACTOR),0.0f); } ActionInterval* TransitionSlideInL::action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0)); + return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0.0f)); } ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action) @@ -632,7 +632,7 @@ void TransitionSlideInR::initScenes() ActionInterval* TransitionSlideInR:: action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0)); + return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0.0f)); } @@ -673,7 +673,7 @@ void TransitionSlideInT::initScenes() ActionInterval* TransitionSlideInT::action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vec2(0,-(s.height-ADJUST_FACTOR))); + return MoveBy::create(_duration, Vec2(0.0f,-(s.height-ADJUST_FACTOR))); } // @@ -713,7 +713,7 @@ void TransitionSlideInB:: initScenes() ActionInterval* TransitionSlideInB:: action() { Size s = Director::getInstance()->getWinSize(); - return MoveBy::create(_duration, Vec2(0,s.height-ADJUST_FACTOR)); + return MoveBy::create(_duration, Vec2(0.0f,s.height-ADJUST_FACTOR)); } // diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index 717113237a..25aacd7aec 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -100,7 +100,7 @@ void getChildMap(std::map >& map, SkinData* skinData, cons const rapidjson::Value& parent_transform = val[OLDTRANSFORM]; for (rapidjson::SizeType j = 0, size = parent_transform.Size(); j < size; ++j) { - transform.m[j] = parent_transform[j].GetDouble(); + transform.m[j] = parent_transform[j].GetFloat(); } // set origin matrices @@ -758,7 +758,7 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas) meshData->vertexSizeInFloat = mesh_data_vertex_array_size; for (rapidjson::SizeType i = 0; i < mesh_data_vertex_array_size; ++i) { - meshData->vertex.push_back(mesh_data_vertex_array[i].GetDouble()); + meshData->vertex.push_back(mesh_data_vertex_array[i].GetFloat()); } // mesh part //////////////////////////////////////////////////////////////////////////////////////////////// @@ -781,10 +781,10 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas) const rapidjson::Value& mesh_part_aabb = mesh_part[AABBS]; if (mesh_part.HasMember(AABBS) && mesh_part_aabb.Size() == 6) { - Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(), - mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble()); - Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(), - mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble()); + Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetFloat(), + mesh_part_aabb[(rapidjson::SizeType)1].GetFloat(), mesh_part_aabb[(rapidjson::SizeType)2].GetFloat()); + Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetFloat(), + mesh_part_aabb[(rapidjson::SizeType)4].GetFloat(), mesh_part_aabb[(rapidjson::SizeType)5].GetFloat()); meshData->subMeshAABB.push_back(AABB(min, max)); } else @@ -1162,7 +1162,7 @@ bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas) const rapidjson::Value& mesh_data_body_vertices = mesh_data_body_array_0[VERTICES]; for (rapidjson::SizeType i = 0; i < mesh_data_body_vertices.Size(); ++i) - meshdata->vertex[i] = mesh_data_body_vertices[i].GetDouble(); + meshdata->vertex[i] = mesh_data_body_vertices[i].GetFloat(); // index_number unsigned int indexnum = mesh_data_body_array_0[INDEXNUM].GetUint(); @@ -1209,7 +1209,7 @@ bool Bundle3D::loadMeshDataJson_0_2(MeshDatas& meshdatas) const rapidjson::Value& mesh_data_body_vertices = mesh_data_vertex_0[VERTICES]; for (rapidjson::SizeType i = 0; i < mesh_data_body_vertices.Size(); ++i) - meshdata->vertex[i] = mesh_data_body_vertices[i].GetDouble(); + meshdata->vertex[i] = mesh_data_body_vertices[i].GetFloat(); // submesh const rapidjson::Value& mesh_submesh_array = mesh_array_0[SUBMESH]; @@ -1259,7 +1259,7 @@ bool Bundle3D::loadSkinDataJson(SkinData* skindata) const rapidjson::Value& bind_pos = skin_data_bone[BINDSHAPE]; for (rapidjson::SizeType j = 0; j < bind_pos.Size(); ++j) { - mat_bind_pos.m[j] = bind_pos[j].GetDouble(); + mat_bind_pos.m[j] = bind_pos[j].GetFloat(); } skindata->inverseBindPoseMatrices.push_back(mat_bind_pos); } @@ -1473,7 +1473,7 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani const rapidjson::Value& animation_data_array_val_0 = animation_data_array[(rapidjson::SizeType)the_index]; - animationdata->_totalTime = animation_data_array_val_0[LENGTH].GetDouble(); + animationdata->_totalTime = animation_data_array_val_0[LENGTH].GetFloat(); const rapidjson::Value& bones = animation_data_array_val_0[BONES]; for (rapidjson::SizeType i = 0; i < bones.Size(); ++i) @@ -1496,24 +1496,24 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani if ( bone_keyframe.HasMember(TRANSLATION)) { const rapidjson::Value& bone_keyframe_translation = bone_keyframe[TRANSLATION]; - float keytime = bone_keyframe[KEYTIME].GetDouble(); - Vec3 val(bone_keyframe_translation[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_translation[1].GetDouble(), bone_keyframe_translation[2].GetDouble()); + float keytime = bone_keyframe[KEYTIME].GetFloat(); + Vec3 val(bone_keyframe_translation[(rapidjson::SizeType)0].GetFloat(), bone_keyframe_translation[1].GetFloat(), bone_keyframe_translation[2].GetFloat()); animationdata->_translationKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val)); } if ( bone_keyframe.HasMember(ROTATION)) { const rapidjson::Value& bone_keyframe_rotation = bone_keyframe[ROTATION]; - float keytime = bone_keyframe[KEYTIME].GetDouble(); - Quaternion val = Quaternion(bone_keyframe_rotation[(rapidjson::SizeType)0].GetDouble(),bone_keyframe_rotation[1].GetDouble(),bone_keyframe_rotation[2].GetDouble(),bone_keyframe_rotation[3].GetDouble()); + float keytime = bone_keyframe[KEYTIME].GetFloat(); + Quaternion val = Quaternion(bone_keyframe_rotation[(rapidjson::SizeType)0].GetFloat(),bone_keyframe_rotation[1].GetFloat(),bone_keyframe_rotation[2].GetFloat(),bone_keyframe_rotation[3].GetFloat()); animationdata->_rotationKeys[bone_name].push_back(Animation3DData::QuatKey(keytime,val)); } if ( bone_keyframe.HasMember(SCALE)) { const rapidjson::Value& bone_keyframe_scale = bone_keyframe[SCALE]; - float keytime = bone_keyframe[KEYTIME].GetDouble(); - Vec3 val(bone_keyframe_scale[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_scale[1].GetDouble(), bone_keyframe_scale[2].GetDouble()); + float keytime = bone_keyframe[KEYTIME].GetFloat(); + Vec3 val(bone_keyframe_scale[(rapidjson::SizeType)0].GetFloat(), bone_keyframe_scale[1].GetFloat(), bone_keyframe_scale[2].GetFloat()); animationdata->_scaleKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val)); } } @@ -1701,7 +1701,7 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo for (rapidjson::SizeType j = 0; j < jtransform.Size(); ++j) { - transform.m[j] = jtransform[j].GetDouble(); + transform.m[j] = jtransform[j].GetFloat(); } nodedata->transform = transform; @@ -1753,7 +1753,7 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo for (rapidjson::SizeType k = 0; k < jinvbindpos.Size(); ++k) { - invbindpos.m[k] = jinvbindpos[k].GetDouble(); + invbindpos.m[k] = jinvbindpos[k].GetFloat(); } //invbindpos.inverse(); diff --git a/cocos/3d/CCMotionStreak3D.cpp b/cocos/3d/CCMotionStreak3D.cpp index b95239dbb4..6ba4da32b9 100644 --- a/cocos/3d/CCMotionStreak3D.cpp +++ b/cocos/3d/CCMotionStreak3D.cpp @@ -24,8 +24,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "3d/CCMotionStreak3D.h" +#include // offsetof +#include "base/ccTypes.h" #include "math/CCVertex.h" #include "base/CCDirector.h" #include "base/ccUtils.h" @@ -118,7 +119,8 @@ bool MotionStreak3D::initWithFade(float fade, float minSeg, float stroke, const _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; // shader state - _programState = new backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + _programState = new backend::ProgramState(program); _customCommand.getPipelineDescriptor().programState = _programState; diff --git a/cocos/3d/CCSkybox.cpp b/cocos/3d/CCSkybox.cpp index 019c5105dd..edb9bd2b6b 100644 --- a/cocos/3d/CCSkybox.cpp +++ b/cocos/3d/CCSkybox.cpp @@ -65,8 +65,8 @@ bool Skybox::init() _customCommand.setAfterCallback(CC_CALLBACK_0(Skybox::onAfterDraw, this)); // create and set our custom shader - - _programState = new backend::ProgramState(CC3D_skybox_vert, CC3D_skybox_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKYBOX_3D); + _programState = new backend::ProgramState(program); auto &pipelineDescriptor = _customCommand.getPipelineDescriptor(); auto layout = _programState->getVertexLayout(); diff --git a/cocos/3d/CCSprite3DMaterial.cpp b/cocos/3d/CCSprite3DMaterial.cpp index c07922f258..561ae64e1b 100644 --- a/cocos/3d/CCSprite3DMaterial.cpp +++ b/cocos/3d/CCSprite3DMaterial.cpp @@ -63,80 +63,68 @@ backend::ProgramState* Sprite3DMaterial::_vertexLitMaterialSkinProgState = nullp backend::ProgramState* Sprite3DMaterial::_diffuseMaterialSkinProgState = nullptr; backend::ProgramState* Sprite3DMaterial::_bumpedDiffuseMaterialSkinProgState = nullptr; -namespace -{ - std::string getShaderMacrosForLight() - { - char def[256]; - auto conf = Configuration::getInstance(); - - snprintf(def, sizeof(def)-1, "\n#define MAX_DIRECTIONAL_LIGHT_NUM %d \n" - "\n#define MAX_POINT_LIGHT_NUM %d \n" - "\n#define MAX_SPOT_LIGHT_NUM %d \n", - conf->getMaxSupportDirLightInShader(), - conf->getMaxSupportPointLightInShader(), - conf->getMaxSupportSpotLightInShader()); - - return std::string(def); - } -} void Sprite3DMaterial::createBuiltInMaterial() { - std::string def = getShaderMacrosForLight(); - std::string normalMapDef = "\n#define USE_NORMAL_MAPPING 1 \n"; - - _unLitMaterialSkinProgState = new (std::nothrow) backend::ProgramState(CC3D_skinPositionTexture_vert, CC3D_colorTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_TEXTURE_3D); + _unLitMaterialSkinProgState = new (std::nothrow) backend::ProgramState(program); _unLitMaterialSkin = new (std::nothrow) Sprite3DMaterial(); if (_unLitMaterialSkin && _unLitMaterialSkin->initWithProgramState(_unLitMaterialSkinProgState)) { _unLitMaterialSkin->_type = Sprite3DMaterial::MaterialType::UNLIT; } - _diffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(def + CC3D_skinPositionNormalTexture_vert, def + CC3D_colorNormalTexture_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_NORMAL_TEXTURE_3D); + _diffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(program); _diffuseMaterialSkin = new (std::nothrow) Sprite3DMaterial(); if (_diffuseMaterialSkin && _diffuseMaterialSkin->initWithProgramState(_diffuseMaterialSkinProgState)) { _diffuseMaterialSkin->_type = Sprite3DMaterial::MaterialType::DIFFUSE; } - _diffuseMaterialProgState = new (std::nothrow) backend::ProgramState(def + CC3D_positionNormalTexture_vert, def + CC3D_colorNormalTexture_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_NORMAL_TEXTURE_3D); + _diffuseMaterialProgState = new (std::nothrow) backend::ProgramState(program); _diffuseMaterial = new (std::nothrow) Sprite3DMaterial(); if (_diffuseMaterial && _diffuseMaterial->initWithProgramState(_diffuseMaterialProgState)) { _diffuseMaterial->_type = Sprite3DMaterial::MaterialType::DIFFUSE; } - _unLitMaterialProgState = new (std::nothrow) backend::ProgramState(CC3D_positionTexture_vert, CC3D_colorTexture_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_3D); + _unLitMaterialProgState = new (std::nothrow) backend::ProgramState(program); _unLitMaterial = new (std::nothrow) Sprite3DMaterial(); if (_unLitMaterial && _unLitMaterial->initWithProgramState(_unLitMaterialProgState)) { _unLitMaterial->_type = Sprite3DMaterial::MaterialType::UNLIT; } - _unLitNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(CC3D_positionTexture_vert, CC3D_color_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_3D); + _unLitNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(program); _unLitNoTexMaterial = new (std::nothrow) Sprite3DMaterial(); if (_unLitNoTexMaterial && _unLitNoTexMaterial->initWithProgramState(_unLitNoTexMaterialProgState)) { _unLitNoTexMaterial->_type = Sprite3DMaterial::MaterialType::UNLIT_NOTEX; } - _diffuseNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(def + CC3D_positionNormalTexture_vert, def + CC3D_colorNormal_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_NORMAL_3D); + _diffuseNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(program); _diffuseNoTexMaterial = new (std::nothrow) Sprite3DMaterial(); if (_diffuseNoTexMaterial && _diffuseNoTexMaterial->initWithProgramState(_diffuseNoTexMaterialProgState)) { _diffuseNoTexMaterial->_type = Sprite3DMaterial::MaterialType::DIFFUSE_NOTEX; } - _bumpedDiffuseMaterialProgState = new (std::nothrow) backend::ProgramState(def + normalMapDef + CC3D_positionNormalTexture_vert, def + normalMapDef + CC3D_colorNormalTexture_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_BUMPEDNORMAL_TEXTURE_3D); + _bumpedDiffuseMaterialProgState = new (std::nothrow) backend::ProgramState(program); _bumpedDiffuseMaterial = new (std::nothrow) Sprite3DMaterial(); if (_bumpedDiffuseMaterial && _bumpedDiffuseMaterial->initWithProgramState(_bumpedDiffuseMaterialProgState)) { _bumpedDiffuseMaterial->_type = Sprite3DMaterial::MaterialType::BUMPED_DIFFUSE; } - _bumpedDiffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(def + normalMapDef + CC3D_skinPositionNormalTexture_vert, def + normalMapDef + CC3D_colorNormalTexture_frag); + program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D); + _bumpedDiffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(program); _bumpedDiffuseMaterialSkin = new (std::nothrow) Sprite3DMaterial(); if (_bumpedDiffuseMaterialSkin && _bumpedDiffuseMaterialSkin->initWithProgramState(_bumpedDiffuseMaterialSkinProgState)) { diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 343341267e..c31d486830 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -29,12 +29,14 @@ USING_NS_CC; #include #include #include +#include // offsetof #include "renderer/CCRenderer.h" #include "renderer/ccShaders.h" #include "renderer/backend/Device.h" #include "renderer/backend/Program.h" #include "renderer/backend/Buffer.h" #include "base/CCDirector.h" +#include "base/ccTypes.h" #include "base/CCEventType.h" #include "2d/CCCamera.h" #include "platform/CCImage.h" @@ -115,7 +117,8 @@ void cocos2d::Terrain::setLightDir(const Vec3& lightDir) bool Terrain::initProperties() { - _programState = new backend::ProgramState(CC3D_terrain_vert, CC3D_terrain_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::TERRAIN_3D); + _programState = new backend::ProgramState(program); _stateBlock.depthWrite = true; _stateBlock.depthTest = true; @@ -1402,8 +1405,6 @@ void Terrain::Chunk::updateVerticesForLOD() } } - //TODO coulsonwang -// glBufferData(GL_ARRAY_BUFFER, sizeof(TerrainVertexData)*_currentVertices.size(), &_currentVertices[0], GL_STREAM_DRAW); _oldLod = _currentLod; } diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index c2f0edd638..50349bfbd0 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -152,3 +152,9 @@ if(WINDOWS) # compile c as c++. needed for precompiled header set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX) endif() + +#if(XCODE) +# # Later versions of Xcode clang want to compile C++17 with aligned allocation turned on and this is only supported on iOS 11.0+ +# # TODO: Only turn this off if ${CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET} < 11.0 +# target_compile_options(cocos2d PUBLIC $<$:-fno-aligned-allocation>) +#endif() diff --git a/cocos/audio/AudioEngine.cpp b/cocos/audio/AudioEngine.cpp index 3f192341f0..9035daed66 100644 --- a/cocos/audio/AudioEngine.cpp +++ b/cocos/audio/AudioEngine.cpp @@ -48,7 +48,6 @@ #endif // ERROR using namespace cocos2d; -using namespace cocos2d::experimental; const int AudioEngine::INVALID_AUDIO_ID = -1; const float AudioEngine::TIME_UNKNOWN = -1.0f; diff --git a/cocos/audio/android/AssetFd.cpp b/cocos/audio/android/AssetFd.cpp index fc8303142f..9d6e6a051a 100644 --- a/cocos/audio/android/AssetFd.cpp +++ b/cocos/audio/android/AssetFd.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "audio/android/cutils/log.h" #include "audio/android/AssetFd.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { AssetFd::AssetFd(int assetFd) : _assetFd(assetFd) @@ -45,4 +45,4 @@ AssetFd::~AssetFd() } }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AssetFd.h b/cocos/audio/android/AssetFd.h index aedb8c8ac2..d380f694d0 100644 --- a/cocos/audio/android/AssetFd.h +++ b/cocos/audio/android/AssetFd.h @@ -26,7 +26,7 @@ THE SOFTWARE. #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class AssetFd { @@ -39,5 +39,5 @@ private: int _assetFd; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioBufferProvider.h b/cocos/audio/android/AudioBufferProvider.h index cf9a3c0974..8efeea6da9 100644 --- a/cocos/audio/android/AudioBufferProvider.h +++ b/cocos/audio/android/AudioBufferProvider.h @@ -20,7 +20,7 @@ #include #include "audio/android/utils/Errors.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { // ---------------------------------------------------------------------------- class AudioBufferProvider @@ -77,4 +77,4 @@ public: }; // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioDecoder.cpp b/cocos/audio/android/AudioDecoder.cpp index 5f14e83fd5..78327e490c 100644 --- a/cocos/audio/android/AudioDecoder.cpp +++ b/cocos/audio/android/AudioDecoder.cpp @@ -34,7 +34,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { size_t AudioDecoder::fileRead(void* ptr, size_t size, size_t nmemb, void* datasource) { @@ -291,4 +291,4 @@ bool AudioDecoder::interleave() return false; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioDecoder.h b/cocos/audio/android/AudioDecoder.h index 46ad515b1f..8ad1f2b4cf 100644 --- a/cocos/audio/android/AudioDecoder.h +++ b/cocos/audio/android/AudioDecoder.h @@ -29,7 +29,7 @@ THE SOFTWARE. #include "audio/android/PcmData.h" #include "base/CCData.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoder { @@ -61,4 +61,4 @@ protected: size_t _fileCurrPos; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioDecoderMp3.cpp b/cocos/audio/android/AudioDecoderMp3.cpp index 136c562fa7..a5ea481982 100644 --- a/cocos/audio/android/AudioDecoderMp3.cpp +++ b/cocos/audio/android/AudioDecoderMp3.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "audio/android/mp3reader.h" #include "platform/CCFileUtils.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoderMp3::AudioDecoderMp3() { @@ -80,4 +80,4 @@ bool AudioDecoderMp3::decodeToPcm() return false; } -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderMp3.h b/cocos/audio/android/AudioDecoderMp3.h index 3def5a202d..8531320afe 100644 --- a/cocos/audio/android/AudioDecoderMp3.h +++ b/cocos/audio/android/AudioDecoderMp3.h @@ -27,7 +27,7 @@ THE SOFTWARE. #include "audio/android/AudioDecoder.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoderMp3 : public AudioDecoder { @@ -40,4 +40,4 @@ protected: friend class AudioDecoderProvider; }; -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderOgg.cpp b/cocos/audio/android/AudioDecoderOgg.cpp index 15f033636b..a1efb56f28 100644 --- a/cocos/audio/android/AudioDecoderOgg.cpp +++ b/cocos/audio/android/AudioDecoderOgg.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "audio/android/AudioDecoderOgg.h" #include "platform/CCFileUtils.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoderOgg::AudioDecoderOgg() { @@ -110,4 +110,4 @@ bool AudioDecoderOgg::decodeToPcm() return (curPos > 0); } -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderOgg.h b/cocos/audio/android/AudioDecoderOgg.h index 4ad5166e65..e9eb6dfaee 100644 --- a/cocos/audio/android/AudioDecoderOgg.h +++ b/cocos/audio/android/AudioDecoderOgg.h @@ -29,7 +29,7 @@ THE SOFTWARE. #include "Tremolo/ivorbisfile.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoderOgg : public AudioDecoder { @@ -43,4 +43,4 @@ protected: friend class AudioDecoderProvider; }; -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderProvider.cpp b/cocos/audio/android/AudioDecoderProvider.cpp index cedf52b20e..077d8136bd 100644 --- a/cocos/audio/android/AudioDecoderProvider.cpp +++ b/cocos/audio/android/AudioDecoderProvider.cpp @@ -31,7 +31,7 @@ #include "audio/android/AudioDecoderWav.h" #include "platform/CCFileUtils.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoder* AudioDecoderProvider::createAudioDecoder(SLEngineItf engineItf, const std::string &url, int bufferSizeInFrames, int sampleRate, const FdGetterCallback &fdGetterCallback) { @@ -90,4 +90,4 @@ void AudioDecoderProvider::destroyAudioDecoder(AudioDecoder** decoder) } } -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderProvider.h b/cocos/audio/android/AudioDecoderProvider.h index 9b2e7e1cb4..8070af0e0e 100644 --- a/cocos/audio/android/AudioDecoderProvider.h +++ b/cocos/audio/android/AudioDecoderProvider.h @@ -27,7 +27,7 @@ THE SOFTWARE. #include "audio/android/OpenSLHelper.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoder; @@ -38,4 +38,4 @@ public: static void destroyAudioDecoder(AudioDecoder** decoder); }; -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderSLES.cpp b/cocos/audio/android/AudioDecoderSLES.cpp index bbcc9382b2..837126305b 100644 --- a/cocos/audio/android/AudioDecoderSLES.cpp +++ b/cocos/audio/android/AudioDecoderSLES.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "audio/android/AudioDecoderSLES.h" #include "platform/CCFileUtils.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { /* Explicitly requesting SL_IID_ANDROIDSIMPLEBUFFERQUEUE and SL_IID_PREFETCHSTATUS * on the UrlAudioPlayer object for decoding, SL_IID_METADATAEXTRACTION for retrieving the @@ -643,4 +643,4 @@ void AudioDecoderSLES::decodeToPcmCallback(SLAndroidSimpleBufferQueueItf queueIt queryAudioInfo(); } -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderSLES.h b/cocos/audio/android/AudioDecoderSLES.h index 30795ab736..4055b8e5a1 100644 --- a/cocos/audio/android/AudioDecoderSLES.h +++ b/cocos/audio/android/AudioDecoderSLES.h @@ -29,7 +29,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoderSLES : public AudioDecoder { @@ -94,4 +94,4 @@ private: friend class AudioDecoderProvider; }; -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderWav.cpp b/cocos/audio/android/AudioDecoderWav.cpp index a89526ced1..b55dc0dd8c 100644 --- a/cocos/audio/android/AudioDecoderWav.cpp +++ b/cocos/audio/android/AudioDecoderWav.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "audio/android/tinysndfile.h" #include "platform/CCFileUtils.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoderWav::AudioDecoderWav() { @@ -110,4 +110,4 @@ bool AudioDecoderWav::decodeToPcm() return ret; } -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioDecoderWav.h b/cocos/audio/android/AudioDecoderWav.h index 41d57e6bf0..4234f04c90 100644 --- a/cocos/audio/android/AudioDecoderWav.h +++ b/cocos/audio/android/AudioDecoderWav.h @@ -27,7 +27,7 @@ THE SOFTWARE. #include "audio/android/AudioDecoder.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoderWav : public AudioDecoder { @@ -44,4 +44,4 @@ protected: friend class AudioDecoderProvider; }; -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/AudioEngine-inl.cpp b/cocos/audio/android/AudioEngine-inl.cpp index 81bd20f335..09bcd63f02 100644 --- a/cocos/audio/android/AudioEngine-inl.cpp +++ b/cocos/audio/android/AudioEngine-inl.cpp @@ -55,7 +55,6 @@ #include "audio/android/UrlAudioPlayer.h" using namespace cocos2d; -using namespace cocos2d::experimental; // Audio focus values synchronized with which in cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java static const int AUDIOFOCUS_GAIN = 0; diff --git a/cocos/audio/android/AudioEngine-inl.h b/cocos/audio/android/AudioEngine-inl.h index 9b68d43d25..cef13de5d4 100644 --- a/cocos/audio/android/AudioEngine-inl.h +++ b/cocos/audio/android/AudioEngine-inl.h @@ -43,8 +43,6 @@ NS_CC_BEGIN class EventCustom; class EventListener; -namespace experimental { - class IAudioPlayer; class AudioPlayerProvider; @@ -103,7 +101,7 @@ private: }; #endif // __AUDIO_ENGINE_INL_H_ - } + NS_CC_END #endif diff --git a/cocos/audio/android/AudioMixer.cpp b/cocos/audio/android/AudioMixer.cpp index 2b9e1baacf..cfd665a464 100644 --- a/cocos/audio/android/AudioMixer.cpp +++ b/cocos/audio/android/AudioMixer.cpp @@ -73,7 +73,7 @@ static const bool kUseFloat = false; // Set to default copy buffer size in frames for input processing. static const size_t kCopyBufferFrameCount = 256; -namespace cocos2d { namespace experimental { +namespace cocos2d { // ---------------------------------------------------------------------------- @@ -2098,4 +2098,4 @@ AudioMixer::process_hook_t AudioMixer::getProcessHook(int processType, uint32_t } // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioMixer.h b/cocos/audio/android/AudioMixer.h index dc2080d71f..dd90ab40a1 100644 --- a/cocos/audio/android/AudioMixer.h +++ b/cocos/audio/android/AudioMixer.h @@ -30,7 +30,7 @@ // FIXME This is actually unity gain, which might not be max in future, expressed in U.12 #define MAX_GAIN_INT AudioMixer::UNITY_GAIN_INT -namespace cocos2d { namespace experimental { +namespace cocos2d { // ---------------------------------------------------------------------------- @@ -386,4 +386,4 @@ private: }; // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioMixerController.cpp b/cocos/audio/android/AudioMixerController.cpp index 4ffb323c09..4a92029600 100644 --- a/cocos/audio/android/AudioMixerController.cpp +++ b/cocos/audio/android/AudioMixerController.cpp @@ -33,7 +33,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioMixerController::AudioMixerController(int bufferSizeInFrames, int sampleRate, int channelCount) : _bufferSizeInFrames(bufferSizeInFrames) @@ -348,4 +348,4 @@ bool AudioMixerController::hasPlayingTacks() return false; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioMixerController.h b/cocos/audio/android/AudioMixerController.h index ce2097010f..d8c08f3fbc 100644 --- a/cocos/audio/android/AudioMixerController.h +++ b/cocos/audio/android/AudioMixerController.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class Track; class AudioMixer; @@ -85,4 +85,4 @@ private: std::atomic_bool _isMixingFrame; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioMixerOps.h b/cocos/audio/android/AudioMixerOps.h index 1e74daeb26..4a37aabaaa 100644 --- a/cocos/audio/android/AudioMixerOps.h +++ b/cocos/audio/android/AudioMixerOps.h @@ -18,7 +18,7 @@ #include "audio/android/cutils/log.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { /* Behavior of is_same<>::value is true if the types are identical, * false otherwise. Identical to the STL std::is_same. @@ -446,5 +446,5 @@ inline void volumeMulti(TO* out, size_t frameCount, } } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioPlayerProvider.cpp b/cocos/audio/android/AudioPlayerProvider.cpp index e42506482f..12c55659c7 100644 --- a/cocos/audio/android/AudioPlayerProvider.cpp +++ b/cocos/audio/android/AudioPlayerProvider.cpp @@ -40,7 +40,7 @@ THE SOFTWARE. #include #include // for std::find_if -namespace cocos2d { namespace experimental { +namespace cocos2d { static int getSystemAPILevel() { @@ -516,4 +516,4 @@ void AudioPlayerProvider::resume() } } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioPlayerProvider.h b/cocos/audio/android/AudioPlayerProvider.h index 8b21984c30..3f72a39f1d 100644 --- a/cocos/audio/android/AudioPlayerProvider.h +++ b/cocos/audio/android/AudioPlayerProvider.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { // Manage PcmAudioPlayer& UrlAudioPlayer class PcmAudioPlayer; @@ -124,5 +124,5 @@ private: ThreadPool* _threadPool; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioResampler.cpp b/cocos/audio/android/AudioResampler.cpp index ab12289360..134821b964 100644 --- a/cocos/audio/android/AudioResampler.cpp +++ b/cocos/audio/android/AudioResampler.cpp @@ -39,7 +39,7 @@ -namespace cocos2d { namespace experimental { +namespace cocos2d { // ---------------------------------------------------------------------------- @@ -785,4 +785,4 @@ void AudioResamplerOrder1::AsmStereo16Loop(int16_t *in, int32_t* maxOutPt, int32 // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioResampler.h b/cocos/audio/android/AudioResampler.h index ee9185bb52..1e2a6ab23f 100644 --- a/cocos/audio/android/AudioResampler.h +++ b/cocos/audio/android/AudioResampler.h @@ -31,7 +31,7 @@ #include #include "audio/android/audio.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioResampler { @@ -178,4 +178,4 @@ private: }; // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioResamplerCubic.cpp b/cocos/audio/android/AudioResamplerCubic.cpp index 2b85321245..c2cbf13019 100644 --- a/cocos/audio/android/AudioResamplerCubic.cpp +++ b/cocos/audio/android/AudioResamplerCubic.cpp @@ -24,7 +24,7 @@ #include "audio/android/AudioResampler.h" #include "audio/android/AudioResamplerCubic.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { // ---------------------------------------------------------------------------- void AudioResamplerCubic::init() { @@ -188,4 +188,4 @@ save_state: } // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioResamplerCubic.h b/cocos/audio/android/AudioResamplerCubic.h index ef71b771f3..ab7145f1ff 100644 --- a/cocos/audio/android/AudioResamplerCubic.h +++ b/cocos/audio/android/AudioResamplerCubic.h @@ -22,7 +22,7 @@ #include "audio/android/AudioResampler.h" #include "audio/android/AudioBufferProvider.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { // ---------------------------------------------------------------------------- class AudioResamplerCubic : public AudioResampler { @@ -62,4 +62,4 @@ private: }; // ---------------------------------------------------------------------------- -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/AudioResamplerPublic.h b/cocos/audio/android/AudioResamplerPublic.h index 68f31ba60e..cb6e05bfb2 100644 --- a/cocos/audio/android/AudioResamplerPublic.h +++ b/cocos/audio/android/AudioResamplerPublic.h @@ -19,7 +19,7 @@ #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { // AUDIO_RESAMPLER_DOWN_RATIO_MAX is the maximum ratio between the original // audio sample rate and the target rate when downsampling, @@ -169,6 +169,6 @@ static inline bool isMusicRate(uint32_t sampleRate) { return sampleRate >= AUDIO_PROCESSING_MUSIC_RATE; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { // --------------------------------------------------------------------------- diff --git a/cocos/audio/android/CCThreadPool.cpp b/cocos/audio/android/CCThreadPool.cpp index bc9213dfe9..9cdc6747b1 100644 --- a/cocos/audio/android/CCThreadPool.cpp +++ b/cocos/audio/android/CCThreadPool.cpp @@ -38,7 +38,7 @@ #define LOGD(...) printf(__VA_ARGS__) #endif -namespace cocos2d { namespace experimental { +namespace cocos2d { #define DEFAULT_THREAD_POOL_MIN_NUM (4) #define DEFAULT_THREAD_POOL_MAX_NUM (20) @@ -440,4 +440,4 @@ void ThreadPool::setThread(int tid) new(std::nothrow) std::thread(f)); // compiler may not support std::make_unique() } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/CCThreadPool.h b/cocos/audio/android/CCThreadPool.h index 6f20dc2833..b7783b4eb4 100644 --- a/cocos/audio/android/CCThreadPool.h +++ b/cocos/audio/android/CCThreadPool.h @@ -38,7 +38,7 @@ #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { /** * @addtogroup base @@ -234,4 +234,4 @@ private: // end of base group /// @} -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/IAudioPlayer.h b/cocos/audio/android/IAudioPlayer.h index c1e58c0203..61eefd523f 100644 --- a/cocos/audio/android/IAudioPlayer.h +++ b/cocos/audio/android/IAudioPlayer.h @@ -27,7 +27,7 @@ THE SOFTWARE. #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class IAudioPlayer { @@ -86,4 +86,4 @@ public: virtual void setPlayEventCallback(const PlayEventCallback &playEventCallback) = 0; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/ICallerThreadUtils.h b/cocos/audio/android/ICallerThreadUtils.h index 54ac681799..8363334d49 100644 --- a/cocos/audio/android/ICallerThreadUtils.h +++ b/cocos/audio/android/ICallerThreadUtils.h @@ -27,7 +27,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class ICallerThreadUtils { @@ -39,4 +39,4 @@ public: virtual std::thread::id getCallerThreadId() = 0; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/IVolumeProvider.h b/cocos/audio/android/IVolumeProvider.h index 076ac65b26..5aeb7c26de 100644 --- a/cocos/audio/android/IVolumeProvider.h +++ b/cocos/audio/android/IVolumeProvider.h @@ -26,7 +26,7 @@ THE SOFTWARE. #include "audio/android/audio_utils/include/audio_utils/minifloat.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class IVolumeProvider { @@ -42,4 +42,4 @@ protected: { } }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmAudioPlayer.cpp b/cocos/audio/android/PcmAudioPlayer.cpp index 2fbba41b0d..ab888809c5 100644 --- a/cocos/audio/android/PcmAudioPlayer.cpp +++ b/cocos/audio/android/PcmAudioPlayer.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. #include "audio/android/AudioMixerController.h" #include "audio/android/ICallerThreadUtils.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { PcmAudioPlayer::PcmAudioPlayer(AudioMixerController * controller, ICallerThreadUtils* callerThreadUtils) : _id(-1) @@ -223,4 +223,4 @@ IAudioPlayer::State PcmAudioPlayer::getState() const return state; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmAudioPlayer.h b/cocos/audio/android/PcmAudioPlayer.h index aaacefc5a0..4959877dbc 100644 --- a/cocos/audio/android/PcmAudioPlayer.h +++ b/cocos/audio/android/PcmAudioPlayer.h @@ -29,7 +29,7 @@ THE SOFTWARE. #include "audio/android/PcmData.h" #include "audio/android/Track.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { class ICallerThreadUtils; class AudioMixerController; @@ -95,4 +95,4 @@ private: friend class AudioPlayerProvider; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmAudioService.cpp b/cocos/audio/android/PcmAudioService.cpp index e6aa23c848..70950e4fa8 100644 --- a/cocos/audio/android/PcmAudioService.cpp +++ b/cocos/audio/android/PcmAudioService.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "audio/android/PcmAudioService.h" #include "audio/android/AudioMixerController.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { static std::vector __silenceData; @@ -197,4 +197,4 @@ void PcmAudioService::resume() } } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmAudioService.h b/cocos/audio/android/PcmAudioService.h index 27559f2c7f..cebb82f832 100644 --- a/cocos/audio/android/PcmAudioService.h +++ b/cocos/audio/android/PcmAudioService.h @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioMixerController; @@ -79,4 +79,4 @@ private: friend class AudioPlayerProvider; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmBufferProvider.cpp b/cocos/audio/android/PcmBufferProvider.cpp index 4ed2011c1a..82ca9b6293 100644 --- a/cocos/audio/android/PcmBufferProvider.cpp +++ b/cocos/audio/android/PcmBufferProvider.cpp @@ -35,7 +35,7 @@ THE SOFTWARE. #define ALOGVV(a...) do { } while (0) #endif -namespace cocos2d { namespace experimental { +namespace cocos2d { PcmBufferProvider::PcmBufferProvider() : _addr(nullptr) @@ -99,4 +99,4 @@ void PcmBufferProvider::reset() { _nextFrame = 0; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmBufferProvider.h b/cocos/audio/android/PcmBufferProvider.h index e5f5a2a7d5..253d9e9edb 100644 --- a/cocos/audio/android/PcmBufferProvider.h +++ b/cocos/audio/android/PcmBufferProvider.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class PcmBufferProvider : public AudioBufferProvider { @@ -49,4 +49,4 @@ protected: size_t _unrel; // number of frames not yet released }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmData.cpp b/cocos/audio/android/PcmData.cpp index a3bd8ddaa3..240aae8721 100644 --- a/cocos/audio/android/PcmData.cpp +++ b/cocos/audio/android/PcmData.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "audio/android/OpenSLHelper.h" #include "audio/android/PcmData.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { PcmData::PcmData() { @@ -136,4 +136,4 @@ std::string PcmData::toString() const return ret; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/PcmData.h b/cocos/audio/android/PcmData.h index d0445e0cc0..18cf5cc162 100644 --- a/cocos/audio/android/PcmData.h +++ b/cocos/audio/android/PcmData.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { struct PcmData { @@ -63,4 +63,4 @@ struct PcmData std::string toString() const; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/Track.cpp b/cocos/audio/android/Track.cpp index d2f7c9be4d..f93fcaedbc 100644 --- a/cocos/audio/android/Track.cpp +++ b/cocos/audio/android/Track.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. #include -namespace cocos2d { namespace experimental { +namespace cocos2d { Track::Track(const PcmData &pcmData) : onStateChanged(nullptr) @@ -103,4 +103,4 @@ void Track::setState(State state) } }; -}} // namespace cocos2d { namespace experimental { \ No newline at end of file +} // namespace cocos2d { \ No newline at end of file diff --git a/cocos/audio/android/Track.h b/cocos/audio/android/Track.h index 09b8e2eb2f..cec7588011 100644 --- a/cocos/audio/android/Track.h +++ b/cocos/audio/android/Track.h @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class Track : public PcmBufferProvider, public IVolumeProvider { @@ -104,4 +104,4 @@ private: friend class AudioMixerController; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/UrlAudioPlayer.cpp b/cocos/audio/android/UrlAudioPlayer.cpp index ef073691c5..b05b0f45c4 100644 --- a/cocos/audio/android/UrlAudioPlayer.cpp +++ b/cocos/audio/android/UrlAudioPlayer.cpp @@ -34,12 +34,12 @@ THE SOFTWARE. namespace { std::mutex __playerContainerMutex; -std::vector __playerContainer; +std::vector __playerContainer; std::once_flag __onceFlag; } -namespace cocos2d { namespace experimental { +namespace cocos2d { class SLUrlAudioPlayerCallbackProxy { @@ -421,4 +421,4 @@ void UrlAudioPlayer::destroy() } } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/UrlAudioPlayer.h b/cocos/audio/android/UrlAudioPlayer.h index 16885effa8..22b4f4e28e 100644 --- a/cocos/audio/android/UrlAudioPlayer.h +++ b/cocos/audio/android/UrlAudioPlayer.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { class ICallerThreadUtils; class AssetFd; @@ -132,4 +132,4 @@ private: friend class AudioPlayerProvider; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/android/utils/Errors.h b/cocos/audio/android/utils/Errors.h index a305cf5205..da8c7e6e47 100644 --- a/cocos/audio/android/utils/Errors.h +++ b/cocos/audio/android/utils/Errors.h @@ -20,7 +20,7 @@ #include #include -namespace cocos2d { namespace experimental { +namespace cocos2d { // use this type to return error codes #ifdef _WIN32 @@ -81,7 +81,7 @@ enum { # define NO_ERROR 0L #endif -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { // --------------------------------------------------------------------------- diff --git a/cocos/audio/android/utils/Utils.cpp b/cocos/audio/android/utils/Utils.cpp index bbd60ace04..7a40ae2d4c 100644 --- a/cocos/audio/android/utils/Utils.cpp +++ b/cocos/audio/android/utils/Utils.cpp @@ -25,11 +25,11 @@ THE SOFTWARE. #include "audio/android/utils/Utils.h" #include "platform/android/jni/JniHelper.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { int getSDKVersion() { return JniHelper::callStaticIntMethod("org.cocos2dx.lib.Cocos2dxHelper", "getSDKVersion"); } -}} // end of namespace cocos2d { namespace experimental +} // end of namespace cocos2d diff --git a/cocos/audio/android/utils/Utils.h b/cocos/audio/android/utils/Utils.h index 90ae035a4d..b48558bc1e 100644 --- a/cocos/audio/android/utils/Utils.h +++ b/cocos/audio/android/utils/Utils.h @@ -25,6 +25,6 @@ THE SOFTWARE. #include -namespace cocos2d { namespace experimental { +namespace cocos2d { extern int getSDKVersion(); -}} +} diff --git a/cocos/audio/apple/AudioCache.h b/cocos/audio/apple/AudioCache.h index 6174dcbdef..3052e8ba57 100644 --- a/cocos/audio/apple/AudioCache.h +++ b/cocos/audio/apple/AudioCache.h @@ -25,9 +25,6 @@ #pragma once -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #import #include @@ -38,7 +35,6 @@ #include "audio/apple/AudioMacros.h" NS_CC_BEGIN -namespace experimental{ class AudioEngineImpl; class AudioPlayer; @@ -111,6 +107,3 @@ protected: }; } -NS_CC_END - -#endif diff --git a/cocos/audio/apple/AudioCache.mm b/cocos/audio/apple/AudioCache.mm index 901c9a1b0f..fac5a1b091 100644 --- a/cocos/audio/apple/AudioCache.mm +++ b/cocos/audio/apple/AudioCache.mm @@ -25,9 +25,6 @@ #define LOG_TAG "AudioCache" -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #include "audio/apple/AudioCache.h" #import @@ -89,7 +86,6 @@ unsigned int __idIndex = 0; @end using namespace cocos2d; -using namespace cocos2d::experimental; AudioCache::AudioCache() : _format(-1) @@ -405,5 +401,3 @@ void AudioCache::invokingLoadCallbacks() _loadCallbacks.clear(); }); } - -#endif diff --git a/cocos/audio/apple/AudioDecoder.h b/cocos/audio/apple/AudioDecoder.h index 42fcf5e2ca..1739bbb629 100644 --- a/cocos/audio/apple/AudioDecoder.h +++ b/cocos/audio/apple/AudioDecoder.h @@ -28,7 +28,7 @@ #include #import -namespace cocos2d { namespace experimental { +namespace cocos2d { /** * @brief The class for decoding compressed audio file to PCM buffer. @@ -117,4 +117,4 @@ private: AudioStreamBasicDescription _outputFormat; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/apple/AudioDecoder.mm b/cocos/audio/apple/AudioDecoder.mm index 5fc2bc3438..96e495e935 100644 --- a/cocos/audio/apple/AudioDecoder.mm +++ b/cocos/audio/apple/AudioDecoder.mm @@ -30,7 +30,7 @@ #define LOG_TAG "AudioDecoder" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoder::AudioDecoder() : _isOpened(false) @@ -226,4 +226,4 @@ namespace cocos2d { namespace experimental { return _isOpened; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/apple/AudioEngine-inl.h b/cocos/audio/apple/AudioEngine-inl.h index 4176b6df09..31e5b69cdc 100644 --- a/cocos/audio/apple/AudioEngine-inl.h +++ b/cocos/audio/apple/AudioEngine-inl.h @@ -22,12 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC - -#ifndef __AUDIO_ENGINE_INL_H_ -#define __AUDIO_ENGINE_INL_H_ +#pragma once #include #include @@ -39,7 +34,6 @@ NS_CC_BEGIN class Scheduler; -namespace experimental{ #define MAX_AUDIOINSTANCES 24 class AudioEngineImpl : public cocos2d::Ref @@ -89,7 +83,4 @@ private: int _currentAudioID; Scheduler* _scheduler; }; -} NS_CC_END -#endif // __AUDIO_ENGINE_INL_H_ -#endif diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm index 81b8b86a89..64cf02bb86 100644 --- a/cocos/audio/apple/AudioEngine-inl.mm +++ b/cocos/audio/apple/AudioEngine-inl.mm @@ -25,9 +25,6 @@ #define LOG_TAG "AudioEngine-inl.mm" -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #include "audio/apple/AudioEngine-inl.h" #import @@ -44,7 +41,6 @@ #endif using namespace cocos2d; -using namespace cocos2d::experimental; static ALCdevice* s_ALDevice = nullptr; static ALCcontext* s_ALContext = nullptr; @@ -711,5 +707,3 @@ void AudioEngineImpl::uncacheAll() { _audioCaches.clear(); } - -#endif diff --git a/cocos/audio/apple/AudioPlayer.h b/cocos/audio/apple/AudioPlayer.h index db4c9a08aa..b88cf3fe9b 100644 --- a/cocos/audio/apple/AudioPlayer.h +++ b/cocos/audio/apple/AudioPlayer.h @@ -25,9 +25,6 @@ #pragma once -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #include "platform/CCPlatformMacros.h" #include "audio/apple/AudioMacros.h" @@ -38,7 +35,6 @@ #include NS_CC_BEGIN -namespace experimental{ class AudioCache; class AudioEngineImpl; @@ -91,7 +87,4 @@ protected: friend class AudioEngineImpl; }; -} NS_CC_END - -#endif diff --git a/cocos/audio/apple/AudioPlayer.mm b/cocos/audio/apple/AudioPlayer.mm index 4f5455c554..cd97915a56 100644 --- a/cocos/audio/apple/AudioPlayer.mm +++ b/cocos/audio/apple/AudioPlayer.mm @@ -25,9 +25,6 @@ #define LOG_TAG "AudioPlayer" -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #import #include "audio/apple/AudioPlayer.h" @@ -42,7 +39,6 @@ #endif using namespace cocos2d; -using namespace cocos2d::experimental; namespace { unsigned int __idIndex = 0; @@ -371,5 +367,3 @@ bool AudioPlayer::setTime(float time) } return false; } - -#endif diff --git a/cocos/audio/include/AudioEngine.h b/cocos/audio/include/AudioEngine.h index 090183a257..ce6a4aa9a7 100644 --- a/cocos/audio/include/AudioEngine.h +++ b/cocos/audio/include/AudioEngine.h @@ -43,8 +43,6 @@ */ NS_CC_BEGIN -namespace experimental { - /** * @class AudioProfile * @@ -368,7 +366,6 @@ protected: friend class AudioEngineImpl; }; -} // namespace experimental { NS_CC_END // end group diff --git a/cocos/audio/linux/AudioEngine-linux.cpp b/cocos/audio/linux/AudioEngine-linux.cpp index 0a9e89b860..80b886d894 100644 --- a/cocos/audio/linux/AudioEngine-linux.cpp +++ b/cocos/audio/linux/AudioEngine-linux.cpp @@ -34,7 +34,6 @@ #include "platform/CCFileUtils.h" using namespace cocos2d; -using namespace cocos2d::experimental; AudioEngineImpl * g_AudioEngineImpl = nullptr; diff --git a/cocos/audio/linux/AudioEngine-linux.h b/cocos/audio/linux/AudioEngine-linux.h index d52a152e5b..06c5659826 100644 --- a/cocos/audio/linux/AudioEngine-linux.h +++ b/cocos/audio/linux/AudioEngine-linux.h @@ -39,7 +39,7 @@ #include "base/CCRef.h" NS_CC_BEGIN - namespace experimental{ + #define MAX_AUDIOINSTANCES 32 class CC_DLL AudioEngineImpl : public cocos2d::Ref @@ -102,7 +102,7 @@ private: FMOD::System* pSystem; }; -} + NS_CC_END #endif // __AUDIO_ENGINE_LINUX_H_ #endif diff --git a/cocos/audio/win32/AudioCache.cpp b/cocos/audio/win32/AudioCache.cpp index 34ba49c880..702b6b62de 100644 --- a/cocos/audio/win32/AudioCache.cpp +++ b/cocos/audio/win32/AudioCache.cpp @@ -52,7 +52,6 @@ unsigned int __idIndex = 0; #define PCMDATA_CACHEMAXSIZE 1048576 using namespace cocos2d; -using namespace cocos2d::experimental; AudioCache::AudioCache() : _totalFrames(0) @@ -249,7 +248,7 @@ void AudioCache::readDataTask(unsigned int selfId) } else { - _queBufferFrames = sampleRate * QUEUEBUFFER_TIME_STEP; + _queBufferFrames = static_cast(sampleRate * QUEUEBUFFER_TIME_STEP); BREAK_IF_ERR_LOG(_queBufferFrames == 0, "_queBufferFrames == 0"); const uint32_t queBufferBytes = _queBufferFrames * bytesPerFrame; diff --git a/cocos/audio/win32/AudioCache.h b/cocos/audio/win32/AudioCache.h index b3c58f10ba..cb75fe918c 100644 --- a/cocos/audio/win32/AudioCache.h +++ b/cocos/audio/win32/AudioCache.h @@ -43,7 +43,6 @@ #include "audio/win32/AudioMacros.h" NS_CC_BEGIN -namespace experimental{ class AudioEngineImpl; class AudioPlayer; @@ -115,7 +114,6 @@ protected: friend class AudioPlayer; }; -} NS_CC_END #endif diff --git a/cocos/audio/win32/AudioDecoder.cpp b/cocos/audio/win32/AudioDecoder.cpp index 77d507777d..e05d1f9ec9 100644 --- a/cocos/audio/win32/AudioDecoder.cpp +++ b/cocos/audio/win32/AudioDecoder.cpp @@ -29,7 +29,7 @@ #define LOG_TAG "AudioDecoder" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoder::AudioDecoder() : _isOpened(false) @@ -89,4 +89,4 @@ AudioDecoder::AudioDecoder() return _channelCount; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoder.h b/cocos/audio/win32/AudioDecoder.h index c7f321b8cd..ca466c94ba 100644 --- a/cocos/audio/win32/AudioDecoder.h +++ b/cocos/audio/win32/AudioDecoder.h @@ -29,7 +29,7 @@ #include "vorbis/vorbisfile.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { /** * @brief The class for decoding compressed audio file to PCM buffer. @@ -117,4 +117,4 @@ protected: friend class AudioDecoderManager; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoderManager.cpp b/cocos/audio/win32/AudioDecoderManager.cpp index 28ce2ca1e4..950c305355 100644 --- a/cocos/audio/win32/AudioDecoderManager.cpp +++ b/cocos/audio/win32/AudioDecoderManager.cpp @@ -33,7 +33,7 @@ THE SOFTWARE. #include "base/CCConsole.h" #include "mpg123.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { static bool __mp3Inited = false; @@ -67,5 +67,5 @@ void AudioDecoderManager::destroyDecoder(AudioDecoder* decoder) delete decoder; } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoderManager.h b/cocos/audio/win32/AudioDecoderManager.h index ce80bdf1ff..d5295827a3 100644 --- a/cocos/audio/win32/AudioDecoderManager.h +++ b/cocos/audio/win32/AudioDecoderManager.h @@ -25,7 +25,7 @@ THE SOFTWARE. #pragma once -namespace cocos2d { namespace experimental { +namespace cocos2d { class AudioDecoder; @@ -38,5 +38,5 @@ public: static void destroyDecoder(AudioDecoder* decoder); }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoderMp3.cpp b/cocos/audio/win32/AudioDecoderMp3.cpp index c343f888d1..e6d5b3a94d 100644 --- a/cocos/audio/win32/AudioDecoderMp3.cpp +++ b/cocos/audio/win32/AudioDecoderMp3.cpp @@ -32,7 +32,7 @@ #define LOG_TAG "AudioDecoderMp3" -namespace cocos2d { namespace experimental { +namespace cocos2d { static bool __mp3Inited = false; @@ -181,4 +181,4 @@ namespace cocos2d { namespace experimental { return static_cast(mpg123_tell(_mpg123handle)); } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoderMp3.h b/cocos/audio/win32/AudioDecoderMp3.h index a11db607f3..41b642b7d9 100644 --- a/cocos/audio/win32/AudioDecoderMp3.h +++ b/cocos/audio/win32/AudioDecoderMp3.h @@ -29,7 +29,7 @@ struct mpg123_handle_struct; -namespace cocos2d { namespace experimental { +namespace cocos2d { /** * @brief The class for decoding compressed audio file to PCM buffer. @@ -83,4 +83,4 @@ protected: friend class AudioDecoderManager; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoderOgg.cpp b/cocos/audio/win32/AudioDecoderOgg.cpp index fc20453229..a5c5c7c6ab 100644 --- a/cocos/audio/win32/AudioDecoderOgg.cpp +++ b/cocos/audio/win32/AudioDecoderOgg.cpp @@ -29,7 +29,7 @@ #define LOG_TAG "AudioDecoderOgg" -namespace cocos2d { namespace experimental { +namespace cocos2d { AudioDecoderOgg::AudioDecoderOgg() { @@ -84,4 +84,4 @@ namespace cocos2d { namespace experimental { return static_cast(ov_pcm_tell(const_cast(&_vf))); } -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioDecoderOgg.h b/cocos/audio/win32/AudioDecoderOgg.h index 4c9ce9113c..13150677b1 100644 --- a/cocos/audio/win32/AudioDecoderOgg.h +++ b/cocos/audio/win32/AudioDecoderOgg.h @@ -29,7 +29,7 @@ #include "vorbis/vorbisfile.h" -namespace cocos2d { namespace experimental { +namespace cocos2d { /** * @brief The class for decoding compressed audio file to PCM buffer. @@ -79,4 +79,4 @@ protected: friend class AudioDecoderManager; }; -}} // namespace cocos2d { namespace experimental { +} // namespace cocos2d { diff --git a/cocos/audio/win32/AudioEngine-win32.cpp b/cocos/audio/win32/AudioEngine-win32.cpp index f779f4276e..168e445b1f 100644 --- a/cocos/audio/win32/AudioEngine-win32.cpp +++ b/cocos/audio/win32/AudioEngine-win32.cpp @@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#define LOG_TAG "AudioEngine-Win32" - -#include "platform/CCPlatformConfig.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "audio/win32/AudioEngine-win32.h" #ifdef OPENAL_PLAIN_INCLUDES @@ -45,6 +39,8 @@ #include +#define LOG_TAG "AudioEngine-Win32" + // log, CCLOG aren't threadsafe, since we uses sub threads for parsing pcm data, threadsafe log output // is needed. Define the following macros (ALOGV, ALOGD, ALOGI, ALOGW, ALOGE) for threadsafe log output. @@ -105,7 +101,6 @@ void audioLog(const char * format, ...) } using namespace cocos2d; -using namespace cocos2d::experimental; static ALCdevice *s_ALDevice = nullptr; static ALCcontext *s_ALContext = nullptr; @@ -516,5 +511,3 @@ void AudioEngineImpl::uncacheAll() { _audioCaches.clear(); } - -#endif diff --git a/cocos/audio/win32/AudioEngine-win32.h b/cocos/audio/win32/AudioEngine-win32.h index 132c662662..9cfd0f51b8 100644 --- a/cocos/audio/win32/AudioEngine-win32.h +++ b/cocos/audio/win32/AudioEngine-win32.h @@ -22,12 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "platform/CCPlatformConfig.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - -#ifndef __AUDIO_ENGINE_INL_H_ -#define __AUDIO_ENGINE_INL_H_ +#pragma once #include @@ -39,7 +34,6 @@ NS_CC_BEGIN class Scheduler; -namespace experimental { #define MAX_AUDIOINSTANCES 32 class CC_DLL AudioEngineImpl : public cocos2d::Ref @@ -86,8 +80,5 @@ private: int _currentAudioID; Scheduler* _scheduler; }; -} -NS_CC_END -#endif // __AUDIO_ENGINE_INL_H_ -#endif +NS_CC_END diff --git a/cocos/audio/win32/AudioPlayer.cpp b/cocos/audio/win32/AudioPlayer.cpp index 4c3e512877..370c015982 100644 --- a/cocos/audio/win32/AudioPlayer.cpp +++ b/cocos/audio/win32/AudioPlayer.cpp @@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#define LOG_TAG "AudioPlayer" - -#include "platform/CCPlatformConfig.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "audio/win32/AudioPlayer.h" #include "audio/win32/AudioCache.h" #include "platform/CCFileUtils.h" @@ -41,8 +35,9 @@ #define ALOGVV(...) do{} while(false) #endif +#define LOG_TAG "AudioPlayer" + using namespace cocos2d; -using namespace cocos2d::experimental; namespace { unsigned int __idIndex = 0; @@ -268,7 +263,7 @@ void AudioPlayer::rotateBufferThread(int offsetFrame) bufferProcessed--; if (_timeDirty) { _timeDirty = false; - offsetFrame = _currTime * decoder->getSampleRate(); + offsetFrame = (int)(_currTime * decoder->getSampleRate()); decoder->seek(offsetFrame); } else { @@ -343,5 +338,3 @@ bool AudioPlayer::setTime(float time) } return false; } - -#endif diff --git a/cocos/audio/win32/AudioPlayer.h b/cocos/audio/win32/AudioPlayer.h index a7f8a579ed..362ede8fcf 100644 --- a/cocos/audio/win32/AudioPlayer.h +++ b/cocos/audio/win32/AudioPlayer.h @@ -22,13 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #pragma once -#include "platform/CCPlatformConfig.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include #include #include @@ -42,7 +37,6 @@ #include "platform/CCPlatformMacros.h" NS_CC_BEGIN -namespace experimental{ class AudioCache; class AudioEngineImpl; @@ -93,8 +87,4 @@ protected: friend class AudioEngineImpl; }; -} NS_CC_END - -#endif //CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - diff --git a/cocos/base/CCConfiguration.h b/cocos/base/CCConfiguration.h index bd4405b5a4..5a2282c028 100644 --- a/cocos/base/CCConfiguration.h +++ b/cocos/base/CCConfiguration.h @@ -32,7 +32,6 @@ THE SOFTWARE. #include "base/CCRef.h" #include "base/CCValue.h" -#include "platform/CCGL.h" #include "3d/CCAnimate3D.h" /** diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 970583fe35..b666520ef5 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -1278,8 +1278,8 @@ void Console::commandProjectionSubCommand3d(int /*fd*/, const std::string& /*arg void Console::commandResolution(int /*fd*/, const std::string& args) { - int width, height, policy; - + int policy; + float width, height; std::istringstream stream( args ); stream >> width >> height>> policy; @@ -1346,8 +1346,8 @@ void Console::commandTouchSubCommandTap(int fd, const std::string& args) if((argv.size() == 3 ) && (Console::Utility::isFloat(argv[1]) && Console::Utility::isFloat(argv[2]))) { - float x = utils::atof(argv[1].c_str()); - float y = utils::atof(argv[2].c_str()); + float x = (float)utils::atof(argv[1].c_str()); + float y = (float)utils::atof(argv[2].c_str()); std::srand ((unsigned)time(nullptr)); _touchId = rand(); @@ -1373,10 +1373,10 @@ void Console::commandTouchSubCommandSwipe(int fd, const std::string& args) && (Console::Utility::isFloat(argv[3])) && (Console::Utility::isFloat(argv[4]))) { - float x1 = utils::atof(argv[1].c_str()); - float y1 = utils::atof(argv[2].c_str()); - float x2 = utils::atof(argv[3].c_str()); - float y2 = utils::atof(argv[4].c_str()); + float x1 = (float)utils::atof(argv[1].c_str()); + float y1 = (float)utils::atof(argv[2].c_str()); + float x2 = (float)utils::atof(argv[3].c_str()); + float y2 = (float)utils::atof(argv[4].c_str()); std::srand ((unsigned)time(nullptr)); _touchId = rand(); diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index cced6be39b..5031377c7b 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -203,8 +203,8 @@ void Director::setDefaultValues() Configuration *conf = Configuration::getInstance(); // default FPS - double fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).asDouble(); - _oldAnimationInterval = _animationInterval = 1.0 / fps; + float fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).asFloat(); + _oldAnimationInterval = _animationInterval = 1.0f / fps; // Display FPS _displayStats = conf->getValue("cocos2d.x.display_fps", Value(false)).asBool(); @@ -1292,10 +1292,10 @@ void Director::createStatsLabel() Texture2D::setDefaultAlphaPixelFormat(currentFormat); - const int height_spacing = 22 / CC_CONTENT_SCALE_FACTOR(); - _drawnVerticesLabel->setPosition(Vec2(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION); - _drawnBatchesLabel->setPosition(Vec2(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION); - _FPSLabel->setPosition(Vec2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION); + const int height_spacing = (int)(22 / CC_CONTENT_SCALE_FACTOR()); + _drawnVerticesLabel->setPosition(Vec2(0, height_spacing*2.0f) + CC_DIRECTOR_STATS_POSITION); + _drawnBatchesLabel->setPosition(Vec2(0, height_spacing*1.0f) + CC_DIRECTOR_STATS_POSITION); + _FPSLabel->setPosition(Vec2(0, height_spacing*0.0f)+CC_DIRECTOR_STATS_POSITION); } #endif // #if !CC_STRIP_FPS diff --git a/cocos/base/CCDirector.h b/cocos/base/CCDirector.h index d58e5a4a00..68bfe44c34 100644 --- a/cocos/base/CCDirector.h +++ b/cocos/base/CCDirector.h @@ -36,7 +36,6 @@ THE SOFTWARE. #include "base/CCVector.h" #include "2d/CCScene.h" #include "math/CCMath.h" -#include "platform/CCGL.h" #include "platform/CCGLView.h" NS_CC_BEGIN diff --git a/cocos/base/CCStencilStateManager.cpp b/cocos/base/CCStencilStateManager.cpp index 30e535810a..5b707d7a97 100644 --- a/cocos/base/CCStencilStateManager.cpp +++ b/cocos/base/CCStencilStateManager.cpp @@ -36,7 +36,8 @@ int StencilStateManager::s_layer = -1; StencilStateManager::StencilStateManager() { auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) backend::ProgramState(positionUColor_vert, positionUColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_UCOLOR); + _programState = new (std::nothrow) backend::ProgramState(program); pipelineDescriptor.programState = _programState; auto vertexLayout = _programState->getVertexLayout(); diff --git a/cocos/base/ZipUtils.cpp b/cocos/base/ZipUtils.cpp index 167ec94055..f69c263b7b 100644 --- a/cocos/base/ZipUtils.cpp +++ b/cocos/base/ZipUtils.cpp @@ -31,6 +31,8 @@ #else // from our embedded sources #include "unzip.h" #endif +#include "ioapi_mem.h" +#include #include #include @@ -42,11 +44,9 @@ #include "platform/CCFileUtils.h" #include -// FIXME: Other platforms should use upstream minizip like mingw-w64 -#ifdef MINIZIP_FROM_SYSTEM +// minizip 1.2.0 is same with other platforms #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 @@ -511,6 +511,7 @@ class ZipFilePrivate { public: unzFile zipFile; + std::unique_ptr memfs; // std::unordered_map is faster if available on the platform typedef std::unordered_map FileListContainer; @@ -523,7 +524,7 @@ ZipFile *ZipFile::createWithBuffer(const void* buffer, uLong size) if (zip && zip->initWithBuffer(buffer, size)) { return zip; } else { - if (zip) delete zip; + delete zip; return nullptr; } } @@ -741,10 +742,17 @@ int ZipFile::getCurrentFileInfo(std::string *filename, unz_file_info *info) bool ZipFile::initWithBuffer(const void *buffer, uLong size) { if (!buffer || size == 0) return false; + + zlib_filefunc_def memory_file = { 0 }; - _data->zipFile = unzOpenBuffer(buffer, size); + std::unique_ptr memfs(new(std::nothrow) ourmemory_t{ (char*)const_cast(buffer), static_cast(size), 0, 0, 0 }); + if (!memfs) return false; + fill_memory_filefunc(&memory_file, memfs.get()); + + _data->zipFile = unzOpen2(nullptr, &memory_file); if (!_data->zipFile) return false; - + _data->memfs = std::move(memfs); + setFilter(emptyFilename); return true; } diff --git a/cocos/base/base64.cpp b/cocos/base/base64.cpp index 1e876fde00..633ec3d777 100644 --- a/cocos/base/base64.cpp +++ b/cocos/base/base64.cpp @@ -35,17 +35,18 @@ unsigned char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz int _base64Decode(const unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len ) { static char inalphabet[256], decoder[256]; - int i, bits, c = 0, char_count, errors = 0; + int c = 0, char_count, errors = 0; unsigned int input_idx = 0; unsigned int output_idx = 0; - for (i = (sizeof alphabet) - 1; i >= 0 ; i--) { + auto alphabetSize = sizeof(alphabet); + for (size_t i = 0; i < alphabetSize; i++){ inalphabet[alphabet[i]] = 1; decoder[alphabet[i]] = i; } char_count = 0; - bits = 0; + int bits = 0; for( input_idx=0; input_idx < input_len ; input_idx++ ) { c = input[ input_idx ]; if (c == '=') diff --git a/cocos/base/base64.h b/cocos/base/base64.h index 419b6d47b0..abd3369138 100644 --- a/cocos/base/base64.h +++ b/cocos/base/base64.h @@ -29,10 +29,6 @@ THE SOFTWARE. /// @cond DO_NOT_SHOW #include "platform/CCPlatformMacros.h" - -#ifdef __cplusplus -extern "C" { -#endif namespace cocos2d { @@ -62,9 +58,6 @@ int CC_DLL base64Encode(const unsigned char *in, unsigned int inLength, char **o }//namespace cocos2d -#ifdef __cplusplus -} -#endif /// @endcond #endif // __SUPPORT_BASE64_H__ diff --git a/cocos/base/ccTypes.h b/cocos/base/ccTypes.h index e5a62e68ba..52ed47ab5a 100644 --- a/cocos/base/ccTypes.h +++ b/cocos/base/ccTypes.h @@ -32,7 +32,6 @@ THE SOFTWARE. #include "math/CCGeometry.h" #include "math/CCMath.h" #include "base/CCRef.h" -#include "platform/CCGL.h" #include "base/CCEnumClass.h" #include "renderer/backend/Types.h" diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 2fd0c4830f..1ff9fef9c2 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -32,7 +32,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x-4.0rc0"; + return "cocos2d-x-4.0"; } NS_CC_END diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 0fbe61ea1e..a81ea7e3c5 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -183,7 +183,6 @@ THE SOFTWARE. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "platform/ios/CCApplication-ios.h" #include "platform/ios/CCGLViewImpl-ios.h" - #include "platform/ios/CCGL-ios.h" #include "platform/ios/CCStdC-ios.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS @@ -207,7 +206,6 @@ THE SOFTWARE. #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #include "platform/desktop/CCGLViewImpl-desktop.h" #include "platform/mac/CCApplication-mac.h" - #include "platform/mac/CCGL-mac.h" #include "platform/mac/CCStdC-mac.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp index 8321936462..af9a1b4316 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp @@ -415,7 +415,8 @@ bool BoneNode::init() updateColor(); auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) cocos2d::backend::ProgramState(cocos2d::position_vert, cocos2d::positionColor_frag); + auto* program = cocos2d::backend::Program::getBuiltinProgram(cocos2d::backend::ProgramType::POSITION); + _programState = new (std::nothrow) cocos2d::backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpLocation = _programState->getUniformLocation("u_MVPMatrix"); diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCSkeletonNode.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCSkeletonNode.cpp index 04bc826021..729905eb82 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCSkeletonNode.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCSkeletonNode.cpp @@ -53,7 +53,8 @@ bool SkeletonNode::init() // init _customCommand auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); - _programState = new (std::nothrow) cocos2d::backend::ProgramState(cocos2d::position_vert, cocos2d::positionColor_frag); + auto* program = cocos2d::backend::Program::getBuiltinProgram(cocos2d::backend::ProgramType::POSITION); + _programState = new (std::nothrow) cocos2d::backend::ProgramState(program); pipelineDescriptor.programState = _programState; _mvpLocation = _programState->getUniformLocation("u_MVPMatrix"); diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 0d7c1a5ab2..48f49bc6a9 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -181,9 +181,6 @@ bool Armature::init(const std::string& name) } -//TODO minggo -// setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 46dc347b67..c02b7fb034 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -60,9 +60,6 @@ BatchNode::~BatchNode() bool BatchNode::init() { bool ret = Node::init(); - //TODO minggo -// setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - return ret; } diff --git a/cocos/editor-support/cocostudio/SimpleAudioEngine.cpp b/cocos/editor-support/cocostudio/SimpleAudioEngine.cpp index 4f4f79a656..452429c06b 100644 --- a/cocos/editor-support/cocostudio/SimpleAudioEngine.cpp +++ b/cocos/editor-support/cocostudio/SimpleAudioEngine.cpp @@ -28,7 +28,6 @@ using namespace CocosDenshion; using namespace cocos2d; -using namespace cocos2d::experimental; struct SimpleAudioEngineDelegate { SimpleAudioEngine * engine = nullptr; diff --git a/cocos/editor-support/spine/SkeletonTwoColorBatch.cpp b/cocos/editor-support/spine/SkeletonTwoColorBatch.cpp index fac3fc971a..32a11d3591 100644 --- a/cocos/editor-support/spine/SkeletonTwoColorBatch.cpp +++ b/cocos/editor-support/spine/SkeletonTwoColorBatch.cpp @@ -30,7 +30,8 @@ #include #include #include - +#include // offsetof +#include "base/ccTypes.h" #include "base/ccUtils.h" USING_NS_CC; diff --git a/cocos/math/Quaternion.cpp b/cocos/math/Quaternion.cpp index 4750d6d797..90cd1667c7 100644 --- a/cocos/math/Quaternion.cpp +++ b/cocos/math/Quaternion.cpp @@ -53,15 +53,6 @@ Quaternion::Quaternion(const Vec3& axis, float angle) set(axis, angle); } -Quaternion::Quaternion(const Quaternion& copy) -{ - set(copy); -} - -Quaternion::~Quaternion() -{ -} - const Quaternion& Quaternion::identity() { static Quaternion value(0.0f, 0.0f, 0.0f, 1.0f); diff --git a/cocos/math/Quaternion.h b/cocos/math/Quaternion.h index 2e5b1d46e7..c74521a4a3 100644 --- a/cocos/math/Quaternion.h +++ b/cocos/math/Quaternion.h @@ -125,18 +125,6 @@ public: */ Quaternion(const Vec3& axis, float angle); - /** - * Constructs a new quaternion that is a copy of the specified one. - * - * @param copy The quaternion to copy. - */ - Quaternion(const Quaternion& copy); - - /** - * Destructor. - */ - ~Quaternion(); - /** * Returns the identity quaternion. * diff --git a/cocos/math/TransformUtils.h b/cocos/math/TransformUtils.h index c063a890e2..d22718a0f8 100644 --- a/cocos/math/TransformUtils.h +++ b/cocos/math/TransformUtils.h @@ -28,8 +28,6 @@ THE SOFTWARE. #ifndef __SUPPORT_TRANSFORM_UTILS_H__ #define __SUPPORT_TRANSFORM_UTILS_H__ -// TODO: when in MAC or windows, it includes -#include "platform/CCGL.h" #include "base/ccMacros.h" /** diff --git a/cocos/navmesh/CCNavMeshDebugDraw.cpp b/cocos/navmesh/CCNavMeshDebugDraw.cpp index ece3679233..7a51fdf03b 100644 --- a/cocos/navmesh/CCNavMeshDebugDraw.cpp +++ b/cocos/navmesh/CCNavMeshDebugDraw.cpp @@ -24,20 +24,23 @@ ****************************************************************************/ #include "navmesh/CCNavMeshDebugDraw.h" #if CC_USE_NAVMESH - +#include // offsetof +#include "base/ccTypes.h" #include "renderer/backend/ProgramState.h" +#include "renderer/backend/Device.h" #include "renderer/CCRenderer.h" #include "renderer/CCRenderState.h" +#include "renderer/ccShaders.h" #include "base/CCDirector.h" #include "base/ccMacros.h" -#include "renderer/ccShaders.h" -#include "renderer/backend/Device.h" + NS_CC_BEGIN NavMeshDebugDraw::NavMeshDebugDraw() { - _programState = new backend::ProgramState(positionColor_vert, positionColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR); + _programState = new backend::ProgramState(program); _locMVP = _programState->getUniformLocation("u_MVPMatrix"); auto vertexLayout = _programState->getVertexLayout(); diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index e71a5207f2..76e8925560 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -388,7 +388,7 @@ public: * @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates. * @return An autoreleased PhysicsShapeCircle object pointer. */ - static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2(0, 0)); + static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2(0.0f, 0.0f)); /** * Calculate the area of a circle with specified radius. diff --git a/cocos/physics3d/CCPhysics3DDebugDrawer.cpp b/cocos/physics3d/CCPhysics3DDebugDrawer.cpp index 5d97f096d9..d2e5376dc5 100644 --- a/cocos/physics3d/CCPhysics3DDebugDrawer.cpp +++ b/cocos/physics3d/CCPhysics3DDebugDrawer.cpp @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "physics3d/CCPhysics3D.h" +#include // offsetof +#include "base/ccTypes.h" #include "base/CCConfiguration.h" #include "base/ccMacros.h" #include "base/CCDirector.h" @@ -106,7 +107,7 @@ void Physics3DDebugDrawer::draw( Renderer *renderer) _dirty = false; } - _customCommand.setIndexDrawInfo(0, _buffer.size()); + _customCommand.setVertexDrawInfo(0, _buffer.size()); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _buffer.size()); @@ -127,7 +128,8 @@ Physics3DDebugDrawer::~Physics3DDebugDrawer() void Physics3DDebugDrawer::init() { CC_SAFE_RELEASE_NULL(_programState); - _programState = new backend::ProgramState(positionColor_vert, positionColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR); + _programState = new backend::ProgramState(program); _locMVP = _programState->getUniformLocation("u_MVPMatrix"); auto attributes = _programState->getProgram()->getActiveAttributes(); diff --git a/cocos/physics3d/CCPhysics3DDebugDrawer.h b/cocos/physics3d/CCPhysics3DDebugDrawer.h index e7283b5201..63e76c84dc 100644 --- a/cocos/physics3d/CCPhysics3DDebugDrawer.h +++ b/cocos/physics3d/CCPhysics3DDebugDrawer.h @@ -46,7 +46,6 @@ NS_CC_BEGIN * @{ */ -class GLProgram; class Renderer; /** @brief Physics3DDebugDrawer: debug draw the physics object, used by Physics3DWorld */ diff --git a/cocos/platform/CCCommon.h b/cocos/platform/CCCommon.h index ba6f0aecd9..037eb65fd2 100644 --- a/cocos/platform/CCCommon.h +++ b/cocos/platform/CCCommon.h @@ -45,7 +45,7 @@ void CC_DLL LuaLog(const char * format); /** @brief Pop out a message box */ -void CC_DLL MessageBox(const char * msg, const char * title); +void CC_DLL ccMessageBox(const char * msg, const char * title); /** @brief Enum the language type supported now diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index abe2681fe3..8bb105f63e 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -712,12 +712,9 @@ unsigned char* FileUtils::getFileDataFromZip(const std::string& zipFilePath, con file = unzOpen(FileUtils::getInstance()->getSuitableFOpen(zipFilePath).c_str()); CC_BREAK_IF(!file); - // FIXME: Other platforms should use upstream minizip like mingw-w64 -#ifdef MINIZIP_FROM_SYSTEM - int ret = unzLocateFile(file, filename.c_str(), NULL); -#else - int ret = unzLocateFile(file, filename.c_str(), 1); -#endif + // minizip 1.2.0 is same with other platforms + int ret = unzLocateFile(file, filename.c_str(), nullptr); + CC_BREAK_IF(UNZ_OK != ret); char filePathA[260]; diff --git a/cocos/platform/CCGL.h b/cocos/platform/CCGL.h index cce37da893..ecfb28ede5 100644 --- a/cocos/platform/CCGL.h +++ b/cocos/platform/CCGL.h @@ -30,11 +30,7 @@ THE SOFTWARE. #include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC -#include "platform/mac/CCGL-mac.h" -#elif CC_TARGET_PLATFORM == CC_PLATFORM_IOS -#include "platform/ios/CCGL-ios.h" -#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #include "platform/android/CCGL-android.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "platform/win32/CCGL-win32.h" diff --git a/cocos/platform/CCGLView.cpp b/cocos/platform/CCGLView.cpp index fc3b4dd1e3..280ad88b98 100644 --- a/cocos/platform/CCGLView.cpp +++ b/cocos/platform/CCGLView.cpp @@ -246,10 +246,10 @@ Vec2 GLView::getVisibleOrigin() const void GLView::setViewPortInPoints(float x , float y , float w , float h) { Viewport vp; - vp.x = x * _scaleX + _viewPortRect.origin.x; - vp.y = y * _scaleY + _viewPortRect.origin.y; - vp.w = w * _scaleX; - vp.h = h * _scaleY; + vp.x = (int)(x * _scaleX + _viewPortRect.origin.x); + vp.y = (int)(y * _scaleY + _viewPortRect.origin.y); + vp.w = (unsigned int)(w * _scaleX); + vp.h = (unsigned int)(h * _scaleY); Camera::setDefaultViewport(vp); } @@ -258,8 +258,8 @@ void GLView::setScissorInPoints(float x , float y , float w , float h) auto renderer = Director::getInstance()->getRenderer(); renderer->setScissorRect((int)(x * _scaleX + _viewPortRect.origin.x), (int)(y * _scaleY + _viewPortRect.origin.y), - (int)(w * _scaleX), - (int)(h * _scaleY)); + (unsigned int)(w * _scaleX), + (unsigned int)(h * _scaleY)); } bool GLView::isScissorEnabled() diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index fa35748a28..5fdc3a3dc3 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include "base/CCData.h" #include "base/ccConfig.h" // CC_USE_JPEG, CC_USE_WEBP +#include "platform/CCGL.h" extern "C" { diff --git a/cocos/platform/CCSAXParser.cpp b/cocos/platform/CCSAXParser.cpp index eca50aec1e..cdb83cc498 100644 --- a/cocos/platform/CCSAXParser.cpp +++ b/cocos/platform/CCSAXParser.cpp @@ -28,66 +28,10 @@ #include // because its based on windows 8 build :P #include "platform/CCFileUtils.h" -#include "tinyxml2.h" #include "rapidxml/rapidxml_sax3.hpp" NS_CC_BEGIN -class XmlSaxHander : public tinyxml2::XMLVisitor -{ -public: - XmlSaxHander():_ccsaxParserImp(0){}; - - virtual bool VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute ); - virtual bool VisitExit( const tinyxml2::XMLElement& element ); - virtual bool Visit( const tinyxml2::XMLText& text ); - virtual bool Visit( const tinyxml2::XMLUnknown&){ return true; } - - void setSAXParserImp(SAXParser* parser) - { - _ccsaxParserImp = parser; - } - -private: - SAXParser *_ccsaxParserImp; -}; - - -bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute ) -{ - //log(" VisitEnter %s",element.Value()); - - std::vector attsVector; - for( const tinyxml2::XMLAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - //log("%s", attrib->Name()); - attsVector.push_back(attrib->Name()); - //log("%s",attrib->Value()); - attsVector.push_back(attrib->Value()); - } - - // nullptr is used in c++11 - //attsVector.push_back(nullptr); - attsVector.push_back(nullptr); - - SAXParser::startElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value(), (const CC_XML_CHAR **)(&attsVector[0])); - return true; -} -bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element ) -{ - //log("VisitExit %s",element.Value()); - - SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value()); - return true; -} - -bool XmlSaxHander::Visit( const tinyxml2::XMLText& text ) -{ - //log("Visit %s",text.Value()); - SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), strlen(text.Value())); - return true; -} - /// rapidxml SAX handler class RapidXmlSaxHander : public rapidxml::xml_sax2_handler { @@ -136,12 +80,11 @@ bool SAXParser::init(const char* /*encoding*/) bool SAXParser::parse(const char* xmlData, size_t dataLength) { - tinyxml2::XMLDocument tinyDoc; - tinyDoc.Parse(xmlData, dataLength); - XmlSaxHander printer; - printer.setSAXParserImp(this); - - return tinyDoc.Accept( &printer ); + if(xmlData != nullptr && dataLength > 0) { + std::string mutableData(xmlData, dataLength); + return this->parseIntrusive(&mutableData.front(), dataLength); + } + return false; } bool SAXParser::parse(const std::string& filename) @@ -150,7 +93,7 @@ bool SAXParser::parse(const std::string& filename) Data data = FileUtils::getInstance()->getDataFromFile(filename); if (!data.isNull()) { - ret = parse((const char*)data.getBytes(), data.getSize()); + ret = parseIntrusive((char*)data.getBytes(), data.getSize()); } return ret; diff --git a/cocos/platform/CMakeLists.txt b/cocos/platform/CMakeLists.txt index c5c8ce171c..4700e2519a 100644 --- a/cocos/platform/CMakeLists.txt +++ b/cocos/platform/CMakeLists.txt @@ -57,11 +57,9 @@ elseif(WINDOWS) elseif(APPLE) set(COCOS_PLATFORM_SPECIFIC_HEADER platform/apple/CCFileUtils-apple.h - platform/apple/CCLock-apple.h platform/apple/CCDevice-apple.h ) set(COCOS_PLATFORM_SPECIFIC_SRC - platform/apple/CCLock-apple.cpp platform/apple/CCFileUtils-apple.mm platform/apple/CCDevice-apple.mm ) @@ -72,7 +70,6 @@ elseif(APPLE) platform/mac/CCGLViewImpl-mac.h platform/mac/CCPlatformDefine-mac.h platform/mac/CCApplication-mac.h - platform/mac/CCGL-mac.h # platform/desktop/CCGLViewImpl-desktop.h ) set(COCOS_PLATFORM_SPECIFIC_SRC @@ -89,11 +86,10 @@ elseif(APPLE) platform/ios/CCApplication-ios.h platform/ios/CCDirectorCaller-ios.h platform/ios/CCEAGLView-ios.h - platform/ios/CCGL-ios.h platform/ios/CCGLViewImpl-ios.h platform/ios/CCPlatformDefine-ios.h platform/ios/CCStdC-ios.h - platform/ios/OpenGL_Internal-ios.h + platform/ios/CCInputView-ios.h ) set(COCOS_PLATFORM_SPECIFIC_SRC ${COCOS_PLATFORM_SPECIFIC_SRC} @@ -104,6 +100,7 @@ elseif(APPLE) platform/ios/CCEAGLView-ios.mm platform/ios/CCGLViewImpl-ios.mm platform/ios/CCImage-ios.mm + platform/ios/CCInputView-ios.mm ) endif() @@ -126,7 +123,6 @@ elseif(LINUX) platform/desktop/CCGLViewImpl-desktop.h ) set(COCOS_PLATFORM_SPECIFIC_SRC - platform/linux/CCStdC-linux.cpp platform/linux/CCFileUtils-linux.cpp platform/linux/CCCommon-linux.cpp platform/linux/CCApplication-linux.cpp diff --git a/cocos/platform/android/CCApplication-android.cpp b/cocos/platform/android/CCApplication-android.cpp index da71a1ba54..e2b0b265ae 100644 --- a/cocos/platform/android/CCApplication-android.cpp +++ b/cocos/platform/android/CCApplication-android.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/android/jni/JniHelper.h" #include "platform/CCApplication.h" #include "base/CCDirector.h" @@ -132,5 +128,3 @@ void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID diff --git a/cocos/platform/android/CCApplication-android.h b/cocos/platform/android/CCApplication-android.h index c2278ce958..bc15ada448 100644 --- a/cocos/platform/android/CCApplication-android.h +++ b/cocos/platform/android/CCApplication-android.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_APPLICATION_ANDROID_H__ -#define __CC_APPLICATION_ANDROID_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" @@ -109,7 +104,3 @@ protected: }; NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif // __CC_APPLICATION_ANDROID_H__ diff --git a/cocos/platform/android/CCCommon-android.cpp b/cocos/platform/android/CCCommon-android.cpp index 8f48d988ab..6c388e53d0 100644 --- a/cocos/platform/android/CCCommon-android.cpp +++ b/cocos/platform/android/CCCommon-android.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/CCCommon.h" #include "platform/android/jni/JniHelper.h" #include @@ -37,7 +33,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) -void MessageBox(const char * pszMsg, const char * pszTitle) +void ccMessageBox(const char * pszMsg, const char * pszTitle) { JniHelper::callStaticVoidMethod("org.cocos2dx.lib.Cocos2dxHelper", "showDialog", pszTitle, pszMsg); } @@ -48,6 +44,3 @@ void LuaLog(const char * pszFormat) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - diff --git a/cocos/platform/android/CCDevice-android.cpp b/cocos/platform/android/CCDevice-android.cpp index ab298d83cb..16ee4cba3c 100644 --- a/cocos/platform/android/CCDevice-android.cpp +++ b/cocos/platform/android/CCDevice-android.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/CCDevice.h" #include #include @@ -184,8 +180,6 @@ void Device::vibrate(float duration) NS_CC_END -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - // this method is called by Cocos2dxBitmap extern "C" { diff --git a/cocos/platform/android/CCEnhanceAPI-android.cpp b/cocos/platform/android/CCEnhanceAPI-android.cpp index 0519a06e0b..1db28b1814 100644 --- a/cocos/platform/android/CCEnhanceAPI-android.cpp +++ b/cocos/platform/android/CCEnhanceAPI-android.cpp @@ -12,11 +12,6 @@ * it only in accordance with the terms of the license agreement * you entered into with Samsung ****************************************************************************/ - - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/android/jni/JniHelper.h" #include "platform/android/CCEnhanceAPI-android.h" #include @@ -106,6 +101,3 @@ int EnhanceAPI::setLowPowerMode(bool enable) return ret; } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - diff --git a/cocos/platform/android/CCEnhanceAPI-android.h b/cocos/platform/android/CCEnhanceAPI-android.h index f00248a67e..6421ac1056 100644 --- a/cocos/platform/android/CCEnhanceAPI-android.h +++ b/cocos/platform/android/CCEnhanceAPI-android.h @@ -12,12 +12,7 @@ * it only in accordance with the terms of the license agreement * you entered into with Samsung ****************************************************************************/ - -#ifndef __CC_ENHANCEAPI_ANDROID_H__ -#define __CC_ENHANCEAPI_ANDROID_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" @@ -98,7 +93,3 @@ public: }; NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif // __CC_ENHANCEAPI_ANDROID_H__ diff --git a/cocos/platform/android/CCFileUtils-android.cpp b/cocos/platform/android/CCFileUtils-android.cpp index 3faa14a7f7..ca3803919e 100644 --- a/cocos/platform/android/CCFileUtils-android.cpp +++ b/cocos/platform/android/CCFileUtils-android.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/android/CCFileUtils-android.h" #include "platform/CCCommon.h" #include "platform/android/jni/JniHelper.h" @@ -416,5 +412,3 @@ string FileUtilsAndroid::getWritablePath() const } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID diff --git a/cocos/platform/android/CCFileUtils-android.h b/cocos/platform/android/CCFileUtils-android.h index 2153199b18..2d5fbb8384 100644 --- a/cocos/platform/android/CCFileUtils-android.h +++ b/cocos/platform/android/CCFileUtils-android.h @@ -23,11 +23,7 @@ Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_FILEUTILS_ANDROID_H__ -#define __CC_FILEUTILS_ANDROID_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" @@ -88,7 +84,3 @@ private: /// @} NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif // __CC_FILEUTILS_ANDROID_H__ diff --git a/cocos/platform/android/CCGL-android.h b/cocos/platform/android/CCGL-android.h index 87342e0b38..ba5ca8f947 100644 --- a/cocos/platform/android/CCGL-android.h +++ b/cocos/platform/android/CCGL-android.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CCGL_H__ -#define __CCGL_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #define glClearDepth glClearDepthf #define glDeleteVertexArrays glDeleteVertexArraysOES @@ -65,8 +60,3 @@ extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT; #define glGenVertexArraysOES glGenVertexArraysOESEXT #define glBindVertexArrayOES glBindVertexArrayOESEXT #define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT - - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif // __CCGL_H__ diff --git a/cocos/platform/android/CCGLViewImpl-android.cpp b/cocos/platform/android/CCGLViewImpl-android.cpp index 519584f383..303560203b 100644 --- a/cocos/platform/android/CCGLViewImpl-android.cpp +++ b/cocos/platform/android/CCGLViewImpl-android.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/android/CCGLViewImpl-android.h" #include "base/CCDirector.h" #include "base/ccMacros.h" @@ -217,5 +213,3 @@ Rect GLViewImpl::getSafeAreaRect() const { } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID diff --git a/cocos/platform/android/CCGLViewImpl-android.h b/cocos/platform/android/CCGLViewImpl-android.h index 83cab2d5e6..b3430c428d 100644 --- a/cocos/platform/android/CCGLViewImpl-android.h +++ b/cocos/platform/android/CCGLViewImpl-android.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_EGLVIEWIMPL_ANDROID_H__ -#define __CC_EGLVIEWIMPL_ANDROID_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #include "base/CCRef.h" #include "math/CCGeometry.h" @@ -60,8 +55,3 @@ protected: }; NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif // end of __CC_EGLVIEWIMPL_ANDROID_H__ - diff --git a/cocos/platform/android/CCPlatformDefine-android.h b/cocos/platform/android/CCPlatformDefine-android.h index 49abace9cb..b477755fce 100644 --- a/cocos/platform/android/CCPlatformDefine-android.h +++ b/cocos/platform/android/CCPlatformDefine-android.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CCPLATFORMDEFINE_H__ -#define __CCPLATFORMDEFINE_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #include @@ -62,7 +57,3 @@ THE SOFTWARE. #define NULL ((void *)0) #endif #endif - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif /* __CCPLATFORMDEFINE_H__*/ diff --git a/cocos/platform/android/CCStdC-android.h b/cocos/platform/android/CCStdC-android.h index 430889dd18..5b598fd24a 100644 --- a/cocos/platform/android/CCStdC-android.h +++ b/cocos/platform/android/CCStdC-android.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_STD_C_H__ -#define __CC_STD_C_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +#pragma once #include "platform/CCPlatformMacros.h" #include @@ -49,7 +44,3 @@ THE SOFTWARE. #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - -#endif // __CC_STD_C_H__ diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 5ff21f46d7..22ad92a365 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -300,7 +300,8 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe public Cocos2dxGLSurfaceView onCreateView() { Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); //this line is need on some device if we specify an alpha bits - if(this.mGLContextAttrs[3] > 0) glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); + // FIXME: is it needed? And it will cause afterimage. + // if(this.mGLContextAttrs[3] > 0) glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); // use custom EGLConfigureChooser Cocos2dxEGLConfigChooser chooser = new Cocos2dxEGLConfigChooser(this.mGLContextAttrs); diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebViewHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebViewHelper.java index 0dffbbcfd0..d6ace93469 100755 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebViewHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebViewHelper.java @@ -127,23 +127,15 @@ public class Cocos2dxWebViewHelper { } public static void setBackgroundTransparent(final int index) { - if(android.os.Build.VERSION.SDK_INT >10) { - sCocos2dxActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - Cocos2dxWebView webView = webViews.get(index); - if (webView != null) { - webView.setBackgroundColor(Color.TRANSPARENT); - try { - Method method = webView.getClass().getMethod("setLayerType",int.class,Paint.class); - method.invoke(webView,WebView.LAYER_TYPE_SOFTWARE,null); - } catch (Exception e) { - e.printStackTrace(); - } - } + sCocos2dxActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + Cocos2dxWebView webView = webViews.get(index); + if (webView != null) { + webView.setBackgroundColor(Color.TRANSPARENT); } - }); - } + } + }); } public static void setOpacityWebView(final int index, final float opacity) { diff --git a/cocos/platform/android/javaactivity-android.cpp b/cocos/platform/android/javaactivity-android.cpp index ef47c31878..56096cfaf6 100644 --- a/cocos/platform/android/javaactivity-android.cpp +++ b/cocos/platform/android/javaactivity-android.cpp @@ -22,10 +22,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - #include "platform/android/CCApplication-android.h" #include "platform/android/CCGLViewImpl-android.h" #include "base/CCDirector.h" @@ -131,6 +127,3 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNI } } - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID - diff --git a/cocos/platform/apple/CCLock-apple.h b/cocos/platform/apple/CCLock-apple.h deleted file mode 100644 index 6ad5c571c2..0000000000 --- a/cocos/platform/apple/CCLock-apple.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ -#define __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ - -#include "platform/CCPlatformMacros.h" - -NS_CC_BEGIN - -class Lock -{ -public: - /** - * @js ctor - */ - Lock(); - /** - * @js NA - * @lua NA - */ - ~Lock(); - - void lock(); - void unlock(); -}; - -NS_CC_END - -#endif // __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index e519416b84..b98110e2fb 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -302,8 +302,8 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); #endif - int neededWidth = rect.size.width * _frameZoomFactor; - int neededHeight = rect.size.height * _frameZoomFactor; + int neededWidth = (int)(rect.size.width * _frameZoomFactor); + int neededHeight = (int)(rect.size.height * _frameZoomFactor); _mainWindow = glfwCreateWindow(neededWidth, neededHeight, _viewName.c_str(), _monitor, nullptr); @@ -316,7 +316,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram message.append(_glfwError); } - MessageBox(message.c_str(), "Error launch application"); + ccMessageBox(message.c_str(), "Error launch application"); return false; } @@ -367,7 +367,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram sprintf(strComplain, "OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.", glVersion); - MessageBox(strComplain, "OpenGL version too old"); + ccMessageBox(strComplain, "OpenGL version too old"); return false; } @@ -394,7 +394,7 @@ bool GLViewImpl::initWithFullScreen(const std::string& viewName) return false; const GLFWvidmode* videoMode = glfwGetVideoMode(_monitor); - return initWithRect(viewName, Rect(0, 0, videoMode->width, videoMode->height), 1.0f, false); + return initWithRect(viewName, Rect(0, 0, (float)videoMode->width, (float)videoMode->height), 1.0f, false); } bool GLViewImpl::initWithFullscreen(const std::string &viewname, const GLFWvidmode &videoMode, GLFWmonitor *monitor) @@ -410,7 +410,7 @@ bool GLViewImpl::initWithFullscreen(const std::string &viewname, const GLFWvidmo glfwWindowHint(GLFW_BLUE_BITS, videoMode.blueBits); glfwWindowHint(GLFW_GREEN_BITS, videoMode.greenBits); - return initWithRect(viewname, Rect(0, 0, videoMode.width, videoMode.height), 1.0f, false); + return initWithRect(viewname, Rect(0, 0, (float)videoMode.width, (float)videoMode.height), 1.0f, false); } bool GLViewImpl::isOpenGLReady() @@ -581,13 +581,13 @@ void GLViewImpl::setFullscreen(const GLFWvidmode &videoMode, GLFWmonitor *monito void GLViewImpl::setWindowed(int width, int height) { if (!this->isFullscreen()) { - this->setFrameSize(width, height); + this->setFrameSize((float)width, (float)height); } else { const GLFWvidmode* videoMode = glfwGetVideoMode(_monitor); int xpos = 0, ypos = 0; glfwGetMonitorPos(_monitor, &xpos, &ypos); - xpos += (videoMode->width - width) * 0.5; - ypos += (videoMode->height - height) * 0.5; + xpos += (int)((videoMode->width - width) * 0.5f); + ypos += (int)((videoMode->height - height) * 0.5f); _monitor = nullptr; glfwSetWindowMonitor(_mainWindow, nullptr, xpos, ypos, width, height, GLFW_DONT_CARE); #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) @@ -614,7 +614,7 @@ Size GLViewImpl::getMonitorSize() const { } if (nullptr != monitor) { const GLFWvidmode* videoMode = glfwGetVideoMode(monitor); - Size size = Size(videoMode->width, videoMode->height); + Size size = Size((float)videoMode->width, (float)videoMode->height); return size; } return Size::ZERO; @@ -650,7 +650,7 @@ void GLViewImpl::updateFrameSize() { _retinaFactor = 1; } - glfwSetWindowSize(_mainWindow, _screenSize.width * _retinaFactor * _frameZoomFactor, _screenSize.height *_retinaFactor * _frameZoomFactor); + glfwSetWindowSize(_mainWindow, (int)(_screenSize.width * _retinaFactor * _frameZoomFactor), (int)(_screenSize.height *_retinaFactor * _frameZoomFactor)); _isInRetinaMonitor = false; } @@ -666,10 +666,10 @@ void GLViewImpl::setFrameSize(float width, float height) void GLViewImpl::setViewPortInPoints(float x , float y , float w , float h) { Viewport vp; - vp.x = x * _scaleX * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.x * _retinaFactor * _frameZoomFactor; - vp.y = y * _scaleY * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.y * _retinaFactor * _frameZoomFactor; - vp.w = w * _scaleX * _retinaFactor * _frameZoomFactor; - vp.h = h * _scaleY * _retinaFactor * _frameZoomFactor; + vp.x = (int)(x * _scaleX * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.x * _retinaFactor * _frameZoomFactor); + vp.y = (int)(y * _scaleY * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.y * _retinaFactor * _frameZoomFactor); + vp.w = (unsigned int)(w * _scaleX * _retinaFactor * _frameZoomFactor); + vp.h = (unsigned int)(h * _scaleY * _retinaFactor * _frameZoomFactor); Camera::setDefaultViewport(vp); } @@ -907,8 +907,8 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow* /*window*/, int width, Size baseDesignSize = _designResolutionSize; ResolutionPolicy baseResolutionPolicy = _resolutionPolicy; - int frameWidth = width / _frameZoomFactor; - int frameHeight = height / _frameZoomFactor; + float frameWidth = width / _frameZoomFactor; + float frameHeight = height / _frameZoomFactor; setFrameSize(frameWidth, frameHeight); setDesignResolutionSize(baseDesignSize.width, baseDesignSize.height, baseResolutionPolicy); Director::getInstance()->setViewport(); @@ -1012,7 +1012,7 @@ bool GLViewImpl::initGlew() GLenum GlewInitResult = glewInit(); if (GLEW_OK != GlewInitResult) { - MessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error"); + ccMessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error"); return false; } @@ -1038,7 +1038,7 @@ bool GLViewImpl::initGlew() #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) if(glew_dynamic_binding() == false) { - MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error"); + ccMessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error"); return false; } #endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.h b/cocos/platform/desktop/CCGLViewImpl-desktop.h index 8d5cab5cd4..c51a7f8488 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.h +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.h @@ -26,6 +26,7 @@ THE SOFTWARE. #pragma once +#include "platform/CCGL.h" #include "base/CCRef.h" #include "platform/CCCommon.h" #include "platform/CCGLView.h" diff --git a/cocos/platform/ios/CCApplication-ios.h b/cocos/platform/ios/CCApplication-ios.h index cb2ef487ba..f3e8583887 100644 --- a/cocos/platform/ios/CCApplication-ios.h +++ b/cocos/platform/ios/CCApplication-ios.h @@ -23,20 +23,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_APPLICATION_IOS_H__ -#define __CC_APPLICATION_IOS_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS +#pragma once #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" NS_CC_BEGIN -class Rect; - class CC_DLL Application : public ApplicationProtocol { public: @@ -108,7 +101,3 @@ protected: }; NS_CC_END - -#endif // CC_PLATFORM_IOS - -#endif // end of __CC_APPLICATION_IOS_H__ diff --git a/cocos/platform/ios/CCApplication-ios.mm b/cocos/platform/ios/CCApplication-ios.mm index 47b74c5e5e..eb47ba9a82 100644 --- a/cocos/platform/ios/CCApplication-ios.mm +++ b/cocos/platform/ios/CCApplication-ios.mm @@ -23,11 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #import "CCApplication.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #import #import "math/CCGeometry.h" @@ -106,7 +103,7 @@ LanguageType Application::getCurrentLanguage() Application::Platform Application::getTargetPlatform() { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster. + if ([UIDevice.currentDevice userInterfaceIdiom] == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster. { return Platform::OS_IPAD; } @@ -128,7 +125,16 @@ bool Application::openURL(const std::string &url) { NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding]; NSURL* nsUrl = [NSURL URLWithString:msg]; - return [[UIApplication sharedApplication] openURL:nsUrl]; + + id application = [UIApplication sharedApplication]; + if ([application respondsToSelector:@selector(openURL:options:completionHandler:)] ) + { + [application openURL:nsUrl options:@{} completionHandler:nil]; + } + else + { + return [application openURL:nsUrl]; + } } void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { @@ -136,5 +142,3 @@ void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { } NS_CC_END - -#endif // CC_PLATFORM_IOS diff --git a/cocos/platform/ios/CCCommon-ios.mm b/cocos/platform/ios/CCCommon-ios.mm index d5da2c0944..254978be54 100644 --- a/cocos/platform/ios/CCCommon-ios.mm +++ b/cocos/platform/ios/CCCommon-ios.mm @@ -23,36 +23,37 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #include "platform/CCCommon.h" #include #include -#import +#import +#import #include "base/CCDirector.h" #include "base/CCConsole.h" NS_CC_BEGIN // ios no MessageBox, use log instead -void MessageBox(const char * msg, const char * title) +void ccMessageBox(const char * msg, const char * title) { // only enable it on iOS. // FIXME: Implement it for tvOS #if !defined(CC_TARGET_OS_TVOS) NSString * tmpTitle = (title) ? [NSString stringWithUTF8String : title] : nil; NSString * tmpMsg = (msg) ? [NSString stringWithUTF8String : msg] : nil; - UIAlertView * messageBox = [[UIAlertView alloc] initWithTitle: tmpTitle - message: tmpMsg - delegate: nil - cancelButtonTitle: @"OK" - otherButtonTitles: nil]; - [messageBox autorelease]; - [messageBox show]; + + UIAlertController* alertController = [UIAlertController alertControllerWithTitle:tmpTitle + message:tmpMsg + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [alertController addAction:defaultAction]; + auto rootViewController = [UIApplication sharedApplication].windows[0].rootViewController; + [rootViewController presentViewController:alertController animated:YES completion:nil]; #endif } @@ -63,5 +64,3 @@ void LuaLog(const char * format) } NS_CC_END - -#endif // CC_PLATFORM_IOS diff --git a/cocos/platform/ios/CCDevice-ios.mm b/cocos/platform/ios/CCDevice-ios.mm index 2b7712bc77..11d4b71190 100644 --- a/cocos/platform/ios/CCDevice-ios.mm +++ b/cocos/platform/ios/CCDevice-ios.mm @@ -23,11 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #import #include "platform/CCDevice.h" @@ -175,7 +170,7 @@ static CGSize _calculateShrinkedSizeForString(NSAttributedString **str, #define SENSOR_DELAY_GAME 0.02 #if !defined(CC_TARGET_OS_TVOS) -@interface CCAccelerometerDispatcher : NSObject +@interface CCAccelerometerDispatcher : NSObject { cocos2d::Acceleration *_acceleration; CMMotionManager *_motionManager; @@ -246,24 +241,34 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher; _acceleration->timestamp = accelerometerData.timestamp; double tmp = _acceleration->x; - - switch ([[UIApplication sharedApplication] statusBarOrientation]) + UIInterfaceOrientation orientation; + if (@available(iOS 13.0, *)) + { + orientation = [[[UIApplication sharedApplication].windows[0] windowScene] interfaceOrientation]; + } + else + { + // Fallback on earlier versions + orientation = [[UIApplication sharedApplication] statusBarOrientation]; + } + + switch (orientation) { case UIInterfaceOrientationLandscapeRight: _acceleration->x = -_acceleration->y; _acceleration->y = tmp; break; - + case UIInterfaceOrientationLandscapeLeft: _acceleration->x = _acceleration->y; _acceleration->y = -tmp; break; - + case UIInterfaceOrientationPortraitUpsideDown: _acceleration->x = -_acceleration->y; _acceleration->y = -tmp; break; - + case UIInterfaceOrientationPortrait: break; default: @@ -294,9 +299,10 @@ int Device::getDPI() scale = [[UIScreen mainScreen] scale]; } - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + UIUserInterfaceIdiom userInterfaceIdiom = [UIDevice.currentDevice userInterfaceIdiom]; + if (userInterfaceIdiom == UIUserInterfaceIdiomPad) { dpi = 132 * scale; - } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { + } else if (userInterfaceIdiom == UIUserInterfaceIdiomPhone) { dpi = 163 * scale; } else { dpi = 160 * scale; @@ -619,5 +625,3 @@ void Device::vibrate(float duration) } NS_CC_END - -#endif // CC_PLATFORM_IOS diff --git a/cocos/platform/ios/CCDirectorCaller-ios.h b/cocos/platform/ios/CCDirectorCaller-ios.h index cdc5e254bd..483e7a3a88 100644 --- a/cocos/platform/ios/CCDirectorCaller-ios.h +++ b/cocos/platform/ios/CCDirectorCaller-ios.h @@ -23,10 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #import @interface CCDirectorCaller : NSObject { @@ -44,5 +40,3 @@ +(void) destroy; @end -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS - diff --git a/cocos/platform/ios/CCDirectorCaller-ios.mm b/cocos/platform/ios/CCDirectorCaller-ios.mm index 14d39d9cc9..f6a933ada9 100644 --- a/cocos/platform/ios/CCDirectorCaller-ios.mm +++ b/cocos/platform/ios/CCDirectorCaller-ios.mm @@ -23,10 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #include #import "platform/ios/CCDirectorCaller-ios.h" @@ -136,12 +132,6 @@ static id s_sharedDirectorCaller; { if (isAppActive) { cocos2d::Director* director = cocos2d::Director::getInstance(); - EAGLContext* cocos2dxContext = [(CCEAGLView*)director->getOpenGLView()->getEAGLView() context]; - if (cocos2dxContext != [EAGLContext currentContext]) - glFlush(); - - [EAGLContext setCurrentContext: cocos2dxContext]; - CFTimeInterval dt = ((CADisplayLink*)displayLink).timestamp - lastDisplayTime; lastDisplayTime = ((CADisplayLink*)displayLink).timestamp; director->mainLoop(dt); @@ -159,6 +149,3 @@ static id s_sharedDirectorCaller; } @end - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS - diff --git a/cocos/platform/ios/CCEAGLView-ios.h b/cocos/platform/ios/CCEAGLView-ios.h index c1908e7dd3..ae12b00b2b 100644 --- a/cocos/platform/ios/CCEAGLView-ios.h +++ b/cocos/platform/ios/CCEAGLView-ios.h @@ -60,10 +60,6 @@ APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2008 Apple Inc. All Rights Reserved. */ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #import #import #import @@ -78,42 +74,16 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. * The view content is basically an EAGL surface you render your OpenGL scene into. * Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. */ -@interface CCEAGLView : UIView +@interface CCEAGLView : UIView { -// id renderer_; -// EAGLContext *context_; // weak ref - - NSString *pixelformat_; - GLuint depthFormat_; BOOL preserveBackbuffer_; - - CGSize size_; CGRect safeArea_; BOOL discardFramebufferSupported_; //fsaa addition - BOOL multisampling_; unsigned int requestedSamples_; - BOOL isUseUITextField; -@private - NSString * markedText_; - CGRect caretRect_; - CGRect originalRect_; - NSNotification* keyboardShowNotification_; - BOOL isKeyboardShown_; } -@property(nonatomic, readonly) UITextPosition *beginningOfDocument; -@property(nonatomic, readonly) UITextPosition *endOfDocument; -@property(nonatomic, assign) id inputDelegate; -@property(nonatomic, readonly) UITextRange *markedTextRange; -@property (nonatomic, copy) NSDictionary *markedTextStyle; -@property(readwrite, copy) UITextRange *selectedTextRange; -@property(nonatomic, readonly) id tokenizer; -@property(nonatomic, readonly, getter = isKeyboardShown) BOOL isKeyboardShown; -@property(nonatomic, copy) NSNotification* keyboardShowNotification; -@property(nonatomic) UITextAutocorrectionType autocorrectionType; // default is UITextAutocorrectionTypeDefault - /** creates an initializes an CCEAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */ + (id) viewWithFrame:(CGRect)frame; /** creates an initializes an CCEAGLView with a frame, a color buffer format, and 0-bit depth buffer */ @@ -130,7 +100,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. /** Initializes an CCEAGLView with a frame, a color buffer format, a depth buffer format, a sharegroup and multisampling support */ - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples; -/** pixel format: it could be RGBA8 (32-bit) or RGB565 (16-bit) */ +//// * pixel format: it could be RGBA8 (32-bit) or RGB565 (16-bit) @property(nonatomic,readonly) NSString* pixelFormat; /** depth format of the render buffer: 0, 16 or 24 bits*/ @property(nonatomic,readonly) GLuint depthFormat; @@ -138,10 +108,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. /** returns surface size in pixels */ @property(nonatomic,readonly) CGSize surfaceSize; -/** OpenGL context */ -@property(nonatomic,readonly) EAGLContext *context; - @property(nonatomic,readwrite) BOOL multiSampling; +@property(nonatomic, readonly) BOOL isKeyboardShown; /** CCEAGLView uses double-buffer. This method swaps the buffers */ @@ -155,6 +123,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. -(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis; -(void) doAnimationWhenAnotherEditBeClicked; -@end -#endif // CC_PLATFORM_IOS +-(void) showKeyboard; +-(void) hideKeyboard; +@end diff --git a/cocos/platform/ios/CCEAGLView-ios.mm b/cocos/platform/ios/CCEAGLView-ios.mm index c07666872d..9e4532cab1 100644 --- a/cocos/platform/ios/CCEAGLView-ios.mm +++ b/cocos/platform/ios/CCEAGLView-ios.mm @@ -69,24 +69,28 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. #import "base/CCTouch.h" #import "base/CCIMEDispatcher.h" #import "renderer/backend/metal/DeviceMTL.h" +#import "platform/ios/CCInputView-ios.h" //CLASS IMPLEMENTATIONS: #define IOS_MAX_TOUCHES_COUNT 10 -@interface CCEAGLView (Private) -- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup; -- (unsigned int) convertPixelFormat:(NSString*) pixelFormat; +@interface CCEAGLView () +@property (nonatomic) CCInputView* textInputView; +@property(nonatomic, readwrite, assign) BOOL isKeyboardShown; +@property(nonatomic, copy) NSNotification* keyboardShowNotification; +@property(nonatomic, assign) CGRect originalRect; @end @implementation CCEAGLView @synthesize surfaceSize=size_; @synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_; -@synthesize context=context_; @synthesize multiSampling=multiSampling_; -@synthesize isKeyboardShown=isKeyboardShown_; @synthesize keyboardShowNotification = keyboardShowNotification_; +@synthesize isKeyboardShown; +@synthesize originalRect = originalRect_; + + (Class) layerClass { return [CAMetalLayer class]; @@ -126,13 +130,10 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. { if((self = [super initWithFrame:frame])) { - isUseUITextField = YES; - markedText_ = nil; + self.textInputView = [[CCInputView alloc] initWithFrame:frame]; originalRect_ = self.frame; self.keyboardShowNotification = nil; - self.autocorrectionType = UITextAutocorrectionTypeNo; - if ([self respondsToSelector:@selector(setContentScaleFactor:)]) { self.contentScaleFactor = [[UIScreen mainScreen] scale]; @@ -159,31 +160,12 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. if ( (self = [super initWithCoder:aDecoder]) ) { size_ = [self bounds].size; - markedText_ = nil; + self.textInputView = [[CCInputView alloc] initWithCoder:aDecoder]; } return self; } -- (void)didMoveToWindow -{ -#if !defined(CC_TARGET_OS_TVOS) - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardWillShowNotification object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardDidShowNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardWillHideNotification object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardDidHideNotification object:nil]; -#endif -} -(int) getWidth { @@ -200,7 +182,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; // remove keyboard notification - self.keyboardShowNotification = nullptr; // implicit release + [self.textInputView release]; [super dealloc]; } @@ -250,34 +232,10 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. return ret; } - --(void) handleTouchesAfterKeyboardShow -{ - NSArray *subviews = self.subviews; - - for(UIView* view in subviews) - { - if([view isKindOfClass:NSClassFromString(@"UITextView")] || - [view isKindOfClass:NSClassFromString(@"UITextField")]) - { - if ([view isFirstResponder]) - { - [view resignFirstResponder]; - return; - } - } - } -} - // Pass the touches to the superview #pragma mark CCEAGLView - Touch Delegate - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - if (isKeyboardShown_) - { - [self handleTouchesAfterKeyboardShow]; - } - +{ UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; @@ -377,264 +335,115 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. glview->handleTouchesCancel(i, (intptr_t*)ids, xs, ys); } -#pragma mark - UIView - Responder - -- (BOOL)canBecomeFirstResponder +- (void) showKeyboard { - if (nil != markedText_) { - [markedText_ release]; - } - markedText_ = nil; - if (isUseUITextField) + [self addSubview:self.textInputView]; + [self.textInputView becomeFirstResponder]; +} + +- (void) hideKeyboard +{ + [self.textInputView resignFirstResponder]; + [self.textInputView removeFromSuperview]; +} + +-(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis +{ + [UIView beginAnimations:nil context:nullptr]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDuration:duration]; + [UIView setAnimationBeginsFromCurrentState:YES]; + + //NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::GLView::getInstance()->getScaleY()); + + if (dis < 0.0f) dis = 0.0f; + + auto glview = cocos2d::Director::getInstance()->getOpenGLView(); + dis *= glview->getScaleY(); + + dis /= self.contentScaleFactor; + + #if defined(CC_TARGET_OS_TVOS) + self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); + #else + switch (getFixedOrientation([[UIApplication sharedApplication] statusBarOrientation])) + { + case UIInterfaceOrientationPortrait: + self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); + break; + + case UIInterfaceOrientationPortraitUpsideDown: + self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, originalRect_.size.width, originalRect_.size.height); + break; + + case UIInterfaceOrientationLandscapeLeft: + self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); + break; + + case UIInterfaceOrientationLandscapeRight: + self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); + break; + + default: + break; + } + #endif + + [UIView commitAnimations]; +} + +-(void) doAnimationWhenAnotherEditBeClicked +{ + if (self.keyboardShowNotification != nil) { - return NO; + [[NSNotificationCenter defaultCenter]postNotification:self.keyboardShowNotification]; } - return YES; } -- (BOOL)becomeFirstResponder -{ - isUseUITextField = NO; - return [super becomeFirstResponder]; -} - -- (BOOL)resignFirstResponder -{ - isUseUITextField = YES; - return [super resignFirstResponder]; -} - -#pragma mark - UIKeyInput protocol - - -- (BOOL)hasText -{ - return NO; -} - -- (void)insertText:(NSString *)text -{ - if (nil != markedText_) { - [markedText_ release]; - markedText_ = nil; - } - const char * pszText = [text cStringUsingEncoding:NSUTF8StringEncoding]; - cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); -} - -- (void)deleteBackward -{ - if (nil != markedText_) { - [markedText_ release]; - markedText_ = nil; - } - cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); -} - -#pragma mark - UITextInputTrait protocol - --(UITextAutocapitalizationType) autocapitalizationType -{ - return UITextAutocapitalizationTypeNone; -} - -#pragma mark - UITextInput protocol - -#pragma mark UITextInput - properties - -@synthesize beginningOfDocument; -@synthesize endOfDocument; -@synthesize inputDelegate; -@synthesize markedTextRange; -@synthesize markedTextStyle; -// @synthesize selectedTextRange; // must implement -@synthesize tokenizer; -@synthesize autocorrectionType; - -/* Text may have a selection, either zero-length (a caret) or ranged. Editing operations are - * always performed on the text from this selection. nil corresponds to no selection. */ -- (void)setSelectedTextRange:(UITextRange *)aSelectedTextRange -{ - CCLOG("UITextRange:setSelectedTextRange"); -} -- (UITextRange *)selectedTextRange -{ - return [[[UITextRange alloc] init] autorelease]; -} - -#pragma mark UITextInput - Replacing and Returning Text - -- (NSString *)textInRange:(UITextRange *)range -{ - CCLOG("textInRange"); - return @""; -} -- (void)replaceRange:(UITextRange *)range withText:(NSString *)theText -{ - CCLOG("replaceRange"); -} - -#pragma mark UITextInput - Working with Marked and Selected Text - - - -/* If text can be selected, it can be marked. Marked text represents provisionally - * inserted text that has yet to be confirmed by the user. It requires unique visual - * treatment in its display. If there is any marked text, the selection, whether a - * caret or an extended range, always resides within. - * - * Setting marked text either replaces the existing marked text or, if none is present, - * inserts it from the current selection. */ - -- (void)setMarkedTextRange:(UITextRange *)markedTextRange -{ - CCLOG("setMarkedTextRange"); -} - -- (UITextRange *)markedTextRange -{ - CCLOG("markedTextRange"); - return nil; // Nil if no marked text. -} -- (void)setMarkedTextStyle:(NSDictionary *)markedTextStyle -{ - CCLOG("setMarkedTextStyle"); - -} -- (NSDictionary *)markedTextStyle -{ - CCLOG("markedTextStyle"); - return nil; -} -- (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange -{ - CCLOG("setMarkedText"); - if (markedText == markedText_) { - return; - } - if (nil != markedText_) { - [markedText_ release]; - } - markedText_ = markedText; - [markedText_ retain]; -} -- (void)unmarkText -{ - CCLOG("unmarkText"); - if (nil == markedText_) - { - return; - } - const char * pszText = [markedText_ cStringUsingEncoding:NSUTF8StringEncoding]; - cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); - [markedText_ release]; - markedText_ = nil; -} - -#pragma mark Methods for creating ranges and positions. - -- (UITextRange *)textRangeFromPosition:(UITextPosition *)fromPosition toPosition:(UITextPosition *)toPosition -{ - CCLOG("textRangeFromPosition"); - return nil; -} -- (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset -{ - CCLOG("positionFromPosition"); - return nil; -} -- (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset -{ - CCLOG("positionFromPosition"); - return nil; -} - -/* Simple evaluation of positions */ -- (NSComparisonResult)comparePosition:(UITextPosition *)position toPosition:(UITextPosition *)other -{ - CCLOG("comparePosition"); - return (NSComparisonResult)0; -} -- (NSInteger)offsetFromPosition:(UITextPosition *)from toPosition:(UITextPosition *)toPosition -{ - CCLOG("offsetFromPosition"); - return 0; -} - -- (UITextPosition *)positionWithinRange:(UITextRange *)range farthestInDirection:(UITextLayoutDirection)direction -{ - CCLOG("positionWithinRange"); - return nil; -} -- (UITextRange *)characterRangeByExtendingPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction -{ - CCLOG("characterRangeByExtendingPosition"); - return nil; -} - -#pragma mark Writing direction - -- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction -{ - CCLOG("baseWritingDirectionForPosition"); - return UITextWritingDirectionNatural; -} -- (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection forRange:(UITextRange *)range -{ - CCLOG("setBaseWritingDirection"); -} - -#pragma mark Geometry - -/* Geometry used to provide, for example, a correction rect. */ -- (CGRect)firstRectForRange:(UITextRange *)range -{ - CCLOG("firstRectForRange"); - return CGRectNull; -} -- (CGRect)caretRectForPosition:(UITextPosition *)position -{ - CCLOG("caretRectForPosition"); - return caretRect_; -} - -#pragma mark Hit testing - -/* JS - Find the closest position to a given point */ -- (UITextPosition *)closestPositionToPoint:(CGPoint)point -{ - CCLOG("closestPositionToPoint"); - return nil; -} -- (UITextPosition *)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange *)range -{ - CCLOG("closestPositionToPoint"); - return nil; -} -- (UITextRange *)characterRangeAtPoint:(CGPoint)point -{ - CCLOG("characterRangeAtPoint"); - return nil; -} - -- (NSArray *)selectionRectsForRange:(UITextRange *)range -{ - CCLOG("selectionRectsForRange"); - return nil; -} - -#pragma mark - UIKeyboard notification +#pragma UIKeyboard notification #if !defined(CC_TARGET_OS_TVOS) +namespace { + UIInterfaceOrientation getFixedOrientation(UIInterfaceOrientation statusBarOrientation) + { + if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) + { + statusBarOrientation = UIInterfaceOrientationPortrait; + } + return statusBarOrientation; + } +} +#endif + +- (void)didMoveToWindow +{ +#if !defined(CC_TARGET_OS_TVOS) + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(onUIKeyboardNotification:) + name:UIKeyboardWillShowNotification object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(onUIKeyboardNotification:) + name:UIKeyboardDidShowNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(onUIKeyboardNotification:) + name:UIKeyboardWillHideNotification object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(onUIKeyboardNotification:) + name:UIKeyboardDidHideNotification object:nil]; +#endif +} + - (void)onUIKeyboardNotification:(NSNotification *)notif { NSString * type = notif.name; NSDictionary* info = [notif userInfo]; - CGRect begin = [self convertRect: + CGRect begin = [self convertRect: [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:self]; - CGRect end = [self convertRect: + CGRect end = [self convertRect: [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:self]; double aniDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; @@ -717,21 +526,14 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. notiInfo.duration = (float)aniDuration; cocos2d::IMEDispatcher* dispatcher = cocos2d::IMEDispatcher::sharedDispatcher(); - if (UIKeyboardWillShowNotification == type) + if (UIKeyboardWillShowNotification == type) { - self.keyboardShowNotification = notif; // implicit copy dispatcher->dispatchKeyboardWillShow(notiInfo); } else if (UIKeyboardDidShowNotification == type) { - //CGSize screenSize = self.window.screen.bounds.size; + self.isKeyboardShown = YES; dispatcher->dispatchKeyboardDidShow(notiInfo); - caretRect_ = end; - - int fontSize = [UIFont smallSystemFontSize]; - caretRect_.origin.y = viewSize.height - (caretRect_.origin.y + caretRect_.size.height + fontSize); - caretRect_.size.height = 0; - isKeyboardShown_ = YES; } else if (UIKeyboardWillHideNotification == type) { @@ -739,75 +541,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. } else if (UIKeyboardDidHideNotification == type) { - caretRect_ = CGRectZero; + self.isKeyboardShown = NO; dispatcher->dispatchKeyboardDidHide(notiInfo); - isKeyboardShown_ = NO; - } -} -#endif - -#if !defined(CC_TARGET_OS_TVOS) -UIInterfaceOrientation getFixedOrientation(UIInterfaceOrientation statusBarOrientation) -{ - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) - { - statusBarOrientation = UIInterfaceOrientationPortrait; - } - return statusBarOrientation; -} -#endif - --(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)dis -{ - [UIView beginAnimations:nil context:nullptr]; - [UIView setAnimationDelegate:self]; - [UIView setAnimationDuration:duration]; - [UIView setAnimationBeginsFromCurrentState:YES]; - - //NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::GLView::getInstance()->getScaleY()); - - if (dis < 0.0f) dis = 0.0f; - - auto glview = cocos2d::Director::getInstance()->getOpenGLView(); - dis *= glview->getScaleY(); - - dis /= self.contentScaleFactor; - -#if defined(CC_TARGET_OS_TVOS) - self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); -#else - switch (getFixedOrientation([[UIApplication sharedApplication] statusBarOrientation])) - { - case UIInterfaceOrientationPortrait: - self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); - break; - - case UIInterfaceOrientationPortraitUpsideDown: - self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, originalRect_.size.width, originalRect_.size.height); - break; - - case UIInterfaceOrientationLandscapeLeft: - self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); - break; - - case UIInterfaceOrientationLandscapeRight: - self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); - break; - - default: - break; - } -#endif - - [UIView commitAnimations]; -} - - --(void) doAnimationWhenAnotherEditBeClicked -{ - if (self.keyboardShowNotification != nil) - { - [[NSNotificationCenter defaultCenter]postNotification:self.keyboardShowNotification]; } } diff --git a/cocos/platform/ios/CCGL-ios.h b/cocos/platform/ios/CCGL-ios.h deleted file mode 100644 index 7e7cba2929..0000000000 --- a/cocos/platform/ios/CCGL-ios.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_IOS_CCGL_H__ -#define __PLATFORM_IOS_CCGL_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - -#include -#include - -#endif // CC_PLATFORM_IOS - -#endif // __PLATFORM_IOS_CCGL_H__ - diff --git a/cocos/platform/ios/CCGLViewImpl-ios.h b/cocos/platform/ios/CCGLViewImpl-ios.h index 874fd1d5bf..e1ad641b17 100644 --- a/cocos/platform/ios/CCGLViewImpl-ios.h +++ b/cocos/platform/ios/CCGLViewImpl-ios.h @@ -23,12 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_EGLVIEWIMPL_IPHONE_H__ -#define __CC_EGLVIEWIMPL_IPHONE_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS +#pragma once #include "base/CCRef.h" #include "platform/CCCommon.h" @@ -92,7 +87,3 @@ protected: }; NS_CC_END - -#endif // CC_PLATFORM_IOS - -#endif // end of __CC_EGLViewImpl_IPHONE_H__ diff --git a/cocos/platform/ios/CCGLViewImpl-ios.mm b/cocos/platform/ios/CCGLViewImpl-ios.mm index 476d66377a..26623708ca 100644 --- a/cocos/platform/ios/CCGLViewImpl-ios.mm +++ b/cocos/platform/ios/CCGLViewImpl-ios.mm @@ -23,10 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #import #include "platform/ios/CCEAGLView-ios.h" @@ -224,11 +220,11 @@ void GLViewImpl::setIMEKeyboardState(bool open) if (open) { - [eaglview becomeFirstResponder]; + [eaglview showKeyboard]; } else { - [eaglview resignFirstResponder]; + [eaglview hideKeyboard]; } } @@ -280,5 +276,3 @@ Rect GLViewImpl::getSafeAreaRect() const } NS_CC_END - -#endif // CC_PLATFORM_IOS diff --git a/cocos/platform/ios/CCImage-ios.mm b/cocos/platform/ios/CCImage-ios.mm index f2dd09a247..214fa4332e 100644 --- a/cocos/platform/ios/CCImage-ios.mm +++ b/cocos/platform/ios/CCImage-ios.mm @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #import "platform/CCImage.h" #import "platform/CCCommon.h" #import @@ -136,6 +132,3 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB) } NS_CC_END - -#endif // CC_PLATFORM_IOS - diff --git a/cocos/platform/apple/CCLock-apple.cpp b/cocos/platform/ios/CCInputView-ios.h similarity index 79% rename from cocos/platform/apple/CCLock-apple.cpp rename to cocos/platform/ios/CCInputView-ios.h index 76d67ca8f1..fa55f88546 100644 --- a/cocos/platform/apple/CCLock-apple.cpp +++ b/cocos/platform/ios/CCInputView-ios.h @@ -1,7 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. +Copyright (c) 2019 Xiamen Yaji Software Co., Ltd. http://www.cocos2d-x.org @@ -23,28 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#import -#include "platform/apple/CCLock-apple.h" - -NS_CC_BEGIN - -Lock::Lock() -{ -} - -Lock::~Lock() -{ - -} - -void Lock::lock() -{ - -} - -void Lock::unlock() -{ - -} - -NS_CC_END +@interface CCInputView : UIView +@end diff --git a/cocos/platform/ios/CCInputView-ios.mm b/cocos/platform/ios/CCInputView-ios.mm new file mode 100644 index 0000000000..8b131d54f5 --- /dev/null +++ b/cocos/platform/ios/CCInputView-ios.mm @@ -0,0 +1,227 @@ +/**************************************************************************** +Copyright (c) 2019 Xiamen Yaji Software Co., Ltd. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#import "platform/ios/CCInputView-ios.h" +#import "base/CCIMEDispatcher.h" +#import "base/CCDirector.h" + +@interface CCInputView () + +@property(nonatomic) NSString* myMarkedText; + +@end + +@implementation CCInputView + +@synthesize myMarkedText; +@synthesize hasText; +@synthesize beginningOfDocument; +@synthesize endOfDocument; +@synthesize markedTextStyle; +@synthesize tokenizer; +@synthesize autocorrectionType; + +- (instancetype) initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame] ) { + self.myMarkedText = nil; + self.autocorrectionType = UITextAutocorrectionTypeNo; + } + + return self; +} + +- (void) dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; // remove keyboard notification + [self.myMarkedText release]; + [self removeFromSuperview]; + [super dealloc]; +} + +- (BOOL) canBecomeFirstResponder { + return YES; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + [self resignFirstResponder]; + [self removeFromSuperview]; +} + +#pragma TextInput protocol + +- (id)inputDelegate { + return nil; +} + +- (void)setInputDelegate:(id)inputDelegate { + +} + +- (void)setSelectedTextRange:(UITextRange *)aSelectedTextRange { + CCLOG("UITextRange:setSelectedTextRange"); +} + +- (UITextRange *)selectedTextRange { + return [[[UITextRange alloc] init] autorelease]; +} + +- (void)deleteBackward { + if (nil != self.myMarkedText) { + [self.myMarkedText release]; + self.myMarkedText = nil; + } + cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); +} + +- (void)insertText:(nonnull NSString *)text { + if (nil != self.myMarkedText) { + [self.myMarkedText release]; + self.myMarkedText = nil; + } + const char * pszText = [text cStringUsingEncoding:NSUTF8StringEncoding]; + cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); +} + +- (NSWritingDirection)baseWritingDirectionForPosition:(nonnull UITextPosition *)position inDirection:(UITextStorageDirection)direction { + CCLOG("baseWritingDirectionForPosition"); + return NSWritingDirectionLeftToRight; +} + +- (CGRect)caretRectForPosition:(nonnull UITextPosition *)position { + CCLOG("caretRectForPosition"); + return CGRectZero; +} + +- (nullable UITextRange *)characterRangeAtPoint:(CGPoint)point { + CCLOG("characterRangeAtPoint"); + return nil; +} + +- (nullable UITextRange *)characterRangeByExtendingPosition:(nonnull UITextPosition *)position inDirection:(UITextLayoutDirection)direction { + CCLOG("characterRangeByExtendingPosition"); + return nil; +} + +- (nullable UITextPosition *)closestPositionToPoint:(CGPoint)point { + CCLOG("closestPositionToPoint"); + return nil; +} + +- (nullable UITextPosition *)closestPositionToPoint:(CGPoint)point withinRange:(nonnull UITextRange *)range { + CCLOG("closestPositionToPoint"); + return nil; +} + +- (NSComparisonResult)comparePosition:(nonnull UITextPosition *)position toPosition:(nonnull UITextPosition *)other { + CCLOG("comparePosition"); + return (NSComparisonResult)0; +} + +- (CGRect)firstRectForRange:(nonnull UITextRange *)range { + CCLOG("firstRectForRange"); + return CGRectNull; +} + +- (NSInteger)offsetFromPosition:(nonnull UITextPosition *)from toPosition:(nonnull UITextPosition *)toPosition { + CCLOG("offsetFromPosition"); + return 0; +} + +- (nullable UITextPosition *)positionFromPosition:(nonnull UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset { + CCLOG("positionFromPosition"); + return nil; +} + +- (nullable UITextPosition *)positionFromPosition:(nonnull UITextPosition *)position offset:(NSInteger)offset { + CCLOG("positionFromPosition"); + return nil; +} + +- (nullable UITextPosition *)positionWithinRange:(nonnull UITextRange *)range farthestInDirection:(UITextLayoutDirection)direction { + CCLOG("positionWithinRange"); + return nil; +} + +- (void)replaceRange:(nonnull UITextRange *)range withText:(nonnull NSString *)text { + +} + +- (nonnull NSArray *)selectionRectsForRange:(nonnull UITextRange *)range { + CCLOG("selectionRectsForRange"); + return nil; +} + +- (void)setBaseWritingDirection:(NSWritingDirection)writingDirection forRange:(nonnull UITextRange *)range { + +} + +- (void)setMarkedText:(nullable NSString *)markedText selectedRange:(NSRange)selectedRange { + CCLOG("setMarkedText"); + if (markedText == self.myMarkedText) { + return; + } + if (nil != self.myMarkedText) { + [self.myMarkedText release]; + } + self.myMarkedText = markedText; + [self.myMarkedText retain]; +} + +- (UITextRange *)markedTextRange +{ + CCLOG("markedTextRange"); + if (nil != self.myMarkedText) { + return [[[UITextRange alloc] init] autorelease]; + } + return nil; // Nil if no marked text. +} + +- (nullable NSString *)textInRange:(nonnull UITextRange *)range { + CCLOG("textInRange"); + if (nil != self.myMarkedText) { + return self.myMarkedText; + } + return nil; +} + +- (nullable UITextRange *)textRangeFromPosition:(nonnull UITextPosition *)fromPosition toPosition:(nonnull UITextPosition *)toPosition { + CCLOG("textRangeFromPosition"); + return nil; +} + +- (void)unmarkText { + CCLOG("unmarkText"); + if (nil == self.myMarkedText) + { + return; + } + const char * pszText = [self.myMarkedText cStringUsingEncoding:NSUTF8StringEncoding]; + cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); + [self.myMarkedText release]; + self.myMarkedText = nil; +} + +- (void)encodeWithCoder:(nonnull NSCoder *)coder { +} + +@end diff --git a/cocos/platform/ios/CCPlatformDefine-ios.h b/cocos/platform/ios/CCPlatformDefine-ios.h index 6df88fd9ab..16b8c308d3 100644 --- a/cocos/platform/ios/CCPlatformDefine-ios.h +++ b/cocos/platform/ios/CCPlatformDefine-ios.h @@ -25,9 +25,6 @@ THE SOFTWARE. ****************************************************************************/ #pragma once -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - #include #define CC_DLL @@ -45,5 +42,3 @@ THE SOFTWARE. #define NULL ((void *)0) #endif #endif - -#endif // CC_PLATFORM_IOS diff --git a/cocos/platform/ios/CCStdC-ios.h b/cocos/platform/ios/CCStdC-ios.h index 8b49f9c8e0..774fa33fb7 100644 --- a/cocos/platform/ios/CCStdC-ios.h +++ b/cocos/platform/ios/CCStdC-ios.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_STD_C_H__ -#define __CC_STD_C_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS +#pragma once #include "platform/CCPlatformMacros.h" #include @@ -48,6 +43,3 @@ THE SOFTWARE. #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX - -#endif // CC_PLATFORM_IOS -#endif // __CC_STD_C_H__ diff --git a/cocos/platform/ios/OpenGL_Internal-ios.h b/cocos/platform/ios/OpenGL_Internal-ios.h deleted file mode 100644 index d9d9c2acc3..0000000000 --- a/cocos/platform/ios/OpenGL_Internal-ios.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - -===== IMPORTANT ===== - -This is sample code demonstrating API, technology or techniques in development. -Although this sample code has been reviewed for technical accuracy, it is not -final. Apple is supplying this information to help you plan for the adoption of -the technologies and programming interfaces described herein. This information -is subject to change, and software implemented based on this sample code should -be tested with final operating system software and final documentation. Newer -versions of this sample code may be provided with future seeds of the API or -technology. For information about updates to this and other developer -documentation, view the New & Updated sidebars in subsequent documentation -seeds. - -===================== - -File: OpenGL_Internal.h -Abstract: This file is included for support purposes and isn't necessary for -understanding this sample. - -Version: 1.0 - -Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. -("Apple") in consideration of your agreement to the following terms, and your -use, installation, modification or redistribution of this Apple software -constitutes acceptance of these terms. If you do not agree with these terms, -please do not use, install, modify or redistribute this Apple software. - -In consideration of your agreement to abide by the following terms, and subject -to these terms, Apple grants you a personal, non-exclusive license, under -Apple's copyrights in this original Apple software (the "Apple Software"), to -use, reproduce, modify and redistribute the Apple Software, with or without -modifications, in source and/or binary forms; provided that if you redistribute -the Apple Software in its entirety and without modifications, you must retain -this notice and the following text and disclaimers in all such redistributions -of the Apple Software. -Neither the name, trademarks, service marks or logos of Apple Inc. may be used -to endorse or promote products derived from the Apple Software without specific -prior written permission from Apple. Except as expressly stated in this notice, -no other rights or licenses, express or implied, are granted by Apple herein, -including but not limited to any patent rights that may be infringed by your -derivative works or by other works in which the Apple Software may be -incorporated. - -The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO -WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED -WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN -COMBINATION WITH YOUR PRODUCTS. - -IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR -DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF -CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Copyright (C) 2008 Apple Inc. All Rights Reserved. - -*/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS - -/* Generic error reporting */ -#define REPORT_ERROR(__FORMAT__, ...) printf("%s: %s\n", __FUNCTION__, [[NSString stringWithFormat:__FORMAT__, __VA_ARGS__] UTF8String]) - -/* EAGL and GL functions calling wrappers that log on error */ -#define CALL_EAGL_FUNCTION(__FUNC__, ...) ({ EAGLError __error = __FUNC__( __VA_ARGS__ ); if(__error != kEAGLErrorSuccess) printf("%s() called from %s returned error %i\n", #__FUNC__, __FUNCTION__, __error); (__error ? NO : YES); }) -//#define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s\n", __error, __FUNCTION__); (__error ? NO : YES); }) -#define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s %d\n", __error, __FUNCTION__, __LINE__); }) - - -/* Optional delegate methods support */ -#ifndef __DELEGATE_IVAR__ -#define __DELEGATE_IVAR__ _delegate -#endif -#ifndef __DELEGATE_METHODS_IVAR__ -#define __DELEGATE_METHODS_IVAR__ _delegateMethods -#endif -#define TEST_DELEGATE_METHOD_BIT(__BIT__) (self->__DELEGATE_METHODS_IVAR__ & (1 << __BIT__)) -#define SET_DELEGATE_METHOD_BIT(__BIT__, __NAME__) { if([self->__DELEGATE_IVAR__ respondsToSelector:@selector(__NAME__)]) self->__DELEGATE_METHODS_IVAR__ |= (1 << __BIT__); else self->__DELEGATE_METHODS_IVAR__ &= ~(1 << __BIT__); } - -#endif // CC_PLATFORM_IOS diff --git a/cocos/platform/linux/CCApplication-linux.cpp b/cocos/platform/linux/CCApplication-linux.cpp index d1ed03a8c9..630ecb7928 100644 --- a/cocos/platform/linux/CCApplication-linux.cpp +++ b/cocos/platform/linux/CCApplication-linux.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - #include "platform/linux/CCApplication-linux.h" #include #include @@ -195,6 +191,3 @@ LanguageType Application::getCurrentLanguage() } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - diff --git a/cocos/platform/linux/CCApplication-linux.h b/cocos/platform/linux/CCApplication-linux.h index 875938e4bd..8e47460231 100644 --- a/cocos/platform/linux/CCApplication-linux.h +++ b/cocos/platform/linux/CCApplication-linux.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef CCAPLICATION_H_ -#define CCAPLICATION_H_ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX +#pragma once #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" @@ -116,7 +111,3 @@ protected: }; NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - -#endif /* CCAPLICATION_H_ */ diff --git a/cocos/platform/linux/CCCommon-linux.cpp b/cocos/platform/linux/CCCommon-linux.cpp index 270c281b12..7bee16e171 100644 --- a/cocos/platform/linux/CCCommon-linux.cpp +++ b/cocos/platform/linux/CCCommon-linux.cpp @@ -23,17 +23,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - #include "platform/CCCommon.h" #include "platform/linux/CCStdC-linux.h" #include "base/CCConsole.h" NS_CC_BEGIN -void MessageBox(const char * msg, const char * title) +void ccMessageBox(const char * msg, const char * title) { log("%s: %s", title, msg); } @@ -44,5 +40,3 @@ void LuaLog(const char * format) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/cocos/platform/linux/CCDevice-linux.cpp b/cocos/platform/linux/CCDevice-linux.cpp index 92e4137a73..806f45ed23 100644 --- a/cocos/platform/linux/CCDevice-linux.cpp +++ b/cocos/platform/linux/CCDevice-linux.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - #include "platform/CCDevice.h" #include "platform/CCFileUtils.h" @@ -519,5 +515,3 @@ void Device::vibrate(float /*duration*/) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/cocos/platform/linux/CCFileUtils-linux.cpp b/cocos/platform/linux/CCFileUtils-linux.cpp index 831a77efb8..a8647dceef 100644 --- a/cocos/platform/linux/CCFileUtils-linux.cpp +++ b/cocos/platform/linux/CCFileUtils-linux.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - #include "platform/linux/CCFileUtils-linux.h" #include "platform/linux/CCApplication-linux.h" #include "platform/CCCommon.h" @@ -128,5 +124,3 @@ bool FileUtilsLinux::isFileExistInternal(const std::string& strFilePath) const } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/cocos/platform/linux/CCFileUtils-linux.h b/cocos/platform/linux/CCFileUtils-linux.h index 7c19161779..a4ea4d34cc 100644 --- a/cocos/platform/linux/CCFileUtils-linux.h +++ b/cocos/platform/linux/CCFileUtils-linux.h @@ -23,11 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_FILEUTILS_LINUX_H__ -#define __CC_FILEUTILS_LINUX_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX +#pragma once #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" @@ -62,7 +58,3 @@ private: /// @} NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - -#endif // __CC_FILEUTILS_LINUX_H__ diff --git a/cocos/platform/linux/CCGL-linux.h b/cocos/platform/linux/CCGL-linux.h index 42c860b5f8..6f6a486396 100644 --- a/cocos/platform/linux/CCGL-linux.h +++ b/cocos/platform/linux/CCGL-linux.h @@ -22,17 +22,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CCGL_H__ -#define __CCGL_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX +#pragma once #include "GL/glew.h" #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - -#endif // __CCGL_H__ diff --git a/cocos/platform/linux/CCPlatformDefine-linux.h b/cocos/platform/linux/CCPlatformDefine-linux.h index 97f3d7d54b..19eb054cf3 100644 --- a/cocos/platform/linux/CCPlatformDefine-linux.h +++ b/cocos/platform/linux/CCPlatformDefine-linux.h @@ -23,12 +23,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #pragma once -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - #include #define CC_DLL @@ -45,5 +41,3 @@ THE SOFTWARE. #define NULL ((void *)0) #endif #endif - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/cocos/platform/linux/CCStdC-linux.cpp b/cocos/platform/linux/CCStdC-linux.cpp deleted file mode 100644 index fe5f597c5b..0000000000 --- a/cocos/platform/linux/CCStdC-linux.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#include "platform/linux/CCStdC-linux.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/cocos/platform/linux/CCStdC-linux.h b/cocos/platform/linux/CCStdC-linux.h index f436322118..6bd836bcb5 100644 --- a/cocos/platform/linux/CCStdC-linux.h +++ b/cocos/platform/linux/CCStdC-linux.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_STD_C_H__ -#define __CC_STD_C_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX +#pragma once #include "platform/CCPlatformMacros.h" @@ -50,7 +45,3 @@ THE SOFTWARE. #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - -#endif // __CC_STD_C_H__ diff --git a/cocos/platform/mac/CCApplication-mac.h b/cocos/platform/mac/CCApplication-mac.h index d1ead6e6a2..ac5fe5790f 100644 --- a/cocos/platform/mac/CCApplication-mac.h +++ b/cocos/platform/mac/CCApplication-mac.h @@ -23,9 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_APPLICATION_MAC_H__ -#define __CC_APPLICATION_MAC_H__ +#pragma once #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" @@ -107,5 +105,3 @@ protected: }; NS_CC_END - -#endif // end of __CC_APPLICATION_MAC_H__; diff --git a/cocos/platform/mac/CCCommon-mac.mm b/cocos/platform/mac/CCCommon-mac.mm index 948e5a2015..3ce527eb52 100644 --- a/cocos/platform/mac/CCCommon-mac.mm +++ b/cocos/platform/mac/CCCommon-mac.mm @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #include "platform/CCCommon.h" #include "base/CCDirector.h" @@ -43,7 +39,7 @@ void LuaLog(const char * format) } // ios no MessageBox, use log instead -void MessageBox(const char * msg, const char * title) +void ccMessageBox(const char * msg, const char * title) { NSString * tmpTitle = (title) ? [NSString stringWithUTF8String : title] : nil; NSString * tmpMsg = (msg) ? [NSString stringWithUTF8String : msg] : nil; @@ -60,5 +56,3 @@ void MessageBox(const char * msg, const char * title) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC diff --git a/cocos/platform/mac/CCDevice-mac.mm b/cocos/platform/mac/CCDevice-mac.mm index f0017a97b8..d78ee99c4b 100644 --- a/cocos/platform/mac/CCDevice-mac.mm +++ b/cocos/platform/mac/CCDevice-mac.mm @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC - #include "platform/CCDevice.h" #include #include @@ -368,5 +364,3 @@ void Device::vibrate(float duration) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC diff --git a/cocos/platform/mac/CCGL-mac.h b/cocos/platform/mac/CCGL-mac.h deleted file mode 100644 index 173c8a0640..0000000000 --- a/cocos/platform/mac/CCGL-mac.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_MAC_CCGL_H__ -#define __PLATFORM_MAC_CCGL_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC - -#import -#import -#import - -#endif // __PLATFORM_MAC_CCGL_H__ - -#endif //s CC_TARGET_PLATFORM == CC_PLATFORM_MAC diff --git a/cocos/platform/mac/CCGLViewImpl-mac.h b/cocos/platform/mac/CCGLViewImpl-mac.h index 8b66861d54..fa18d77d85 100644 --- a/cocos/platform/mac/CCGLViewImpl-mac.h +++ b/cocos/platform/mac/CCGLViewImpl-mac.h @@ -23,9 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_EGLViewIMPL_DESKTOP_H__ -#define __CC_EGLViewIMPL_DESKTOP_H__ +#pragma once #include "base/CCRef.h" #include "platform/CCCommon.h" @@ -260,5 +258,3 @@ private: }; NS_CC_END // end of namespace cocos2d - -#endif // end of __CC_EGLViewImpl_DESKTOP_H__ diff --git a/cocos/platform/mac/CCGLViewImpl-mac.mm b/cocos/platform/mac/CCGLViewImpl-mac.mm index e03446dc2f..04d1ee127e 100644 --- a/cocos/platform/mac/CCGLViewImpl-mac.mm +++ b/cocos/platform/mac/CCGLViewImpl-mac.mm @@ -23,7 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "platform/desktop/CCGLViewImpl-desktop.h" #include @@ -45,6 +44,7 @@ THE SOFTWARE. #endif /* CC_ICON_SET_SUPPORT */ #include "renderer/backend/metal/DeviceMTL.h" #include "renderer/CCRenderer.h" +#include "renderer/backend/metal/Utils.h" NS_CC_BEGIN @@ -315,7 +315,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram message.append(_glfwError); } - MessageBox(message.c_str(), "Error launch application"); + ccMessageBox(message.c_str(), "Error launch application"); return false; } @@ -445,19 +445,16 @@ void GLViewImpl::pollEvents() void GLViewImpl::enableRetina(bool enabled) { - //TODO coulsonwang -//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) -// _isRetinaEnabled = enabled; -// if (_isRetinaEnabled) -// { -// _retinaFactor = 1; -// } -// else -// { -// _retinaFactor = 2; -// } -// updateFrameSize(); -//#endif + _isRetinaEnabled = enabled; + if (_isRetinaEnabled) + { + _retinaFactor = 1; + } + else + { + _retinaFactor = 2; + } + updateFrameSize(); } @@ -879,13 +876,10 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow* /*window*/, int width, Director::getInstance()->setViewport(); Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(GLViewImpl::EVENT_WINDOW_RESIZED, nullptr); - //update metal drawable size. + //update metal attachment texture size. int fbWidth, fbHeight; glfwGetFramebufferSize(_mainWindow, &fbWidth, &fbHeight); - CGSize size; - size.width = static_cast(fbWidth); - size.height = static_cast(fbHeight); - [backend::DeviceMTL::getCAMetalLayer() setDrawableSize:size]; + backend::Utils::resizeDefaultAttachmentTexture(fbWidth, fbHeight); } } diff --git a/cocos/platform/mac/CCStdC-mac.h b/cocos/platform/mac/CCStdC-mac.h index 11c4d93504..774fa33fb7 100644 --- a/cocos/platform/mac/CCStdC-mac.h +++ b/cocos/platform/mac/CCStdC-mac.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_STD_C_H__ -#define __CC_STD_C_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC +#pragma once #include "platform/CCPlatformMacros.h" #include @@ -48,7 +43,3 @@ THE SOFTWARE. #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC - -#endif // __CC_STD_C_H__ diff --git a/cocos/platform/win32/CCApplication-win32.cpp b/cocos/platform/win32/CCApplication-win32.cpp index 32129a7efc..7b23dcab32 100644 --- a/cocos/platform/win32/CCApplication-win32.cpp +++ b/cocos/platform/win32/CCApplication-win32.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "platform/CCApplication.h" #include "base/CCDirector.h" #include @@ -119,7 +115,7 @@ int Application::run() // Sleep(3) may make a sleep of 2ms or 4ms. Therefore, we subtract 1ms here to make Sleep time shorter. // If 'waitMS' is equal or less than 1ms, don't sleep and run into next loop to // boost CPU to next frame accurately. - waitMS = (_animationInterval.QuadPart - interval) * 1000LL / freq.QuadPart - 1L; + waitMS = static_cast((_animationInterval.QuadPart - interval) * 1000LL / freq.QuadPart - 1L); if (waitMS > 1L) Sleep(waitMS); } @@ -362,5 +358,3 @@ static void PVRFrameEnableControlWindow(bool bEnable) RegCloseKey(hKey); } - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 diff --git a/cocos/platform/win32/CCApplication-win32.h b/cocos/platform/win32/CCApplication-win32.h index 66f53613dd..d750fe77be 100644 --- a/cocos/platform/win32/CCApplication-win32.h +++ b/cocos/platform/win32/CCApplication-win32.h @@ -24,8 +24,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #pragma once -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "platform/CCStdC.h" #include "platform/CCCommon.h" @@ -34,8 +32,6 @@ THE SOFTWARE. NS_CC_BEGIN -class Rect; - class CC_DLL Application : public ApplicationProtocol { public: @@ -114,5 +110,3 @@ protected: }; NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 diff --git a/cocos/platform/win32/CCCommon-win32.cpp b/cocos/platform/win32/CCCommon-win32.cpp index c3b97c1bdd..2dee5fcc15 100644 --- a/cocos/platform/win32/CCCommon-win32.cpp +++ b/cocos/platform/win32/CCCommon-win32.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "platform/CCCommon.h" #include "platform/CCStdC.h" #include "platform/win32/CCUtils-win32.h" @@ -35,7 +31,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) -void MessageBox(const char * pszMsg, const char * pszTitle) +void ccMessageBox(const char * pszMsg, const char * pszTitle) { std::wstring wsMsg = cocos2d::StringUtf8ToWideChar(pszMsg); std::wstring wsTitle = cocos2d::StringUtf8ToWideChar(pszTitle); @@ -51,5 +47,3 @@ void LuaLog(const char *pszMsg) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 diff --git a/cocos/platform/win32/CCDevice-win32.cpp b/cocos/platform/win32/CCDevice-win32.cpp index 49521e2e31..1a2cb3e42c 100644 --- a/cocos/platform/win32/CCDevice-win32.cpp +++ b/cocos/platform/win32/CCDevice-win32.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "platform/CCDevice.h" #include "platform/CCFileUtils.h" #include "platform/CCStdC.h" @@ -42,7 +38,7 @@ int Device::getDPI() int PixelsX = GetDeviceCaps(hScreenDC, HORZRES); int MMX = GetDeviceCaps(hScreenDC, HORZSIZE); ReleaseDC(nullptr, hScreenDC); - dpi = 254.0f*PixelsX / MMX / 10; + dpi = (int)(254.0f*PixelsX / MMX / 10); } return dpi; } @@ -493,7 +489,7 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text { BitmapDC& dc = sharedBitmapDC(); - if (!dc.setFont(textDefinition._fontName.c_str(), textDefinition._fontSize,false)) + if (!dc.setFont(textDefinition._fontName.c_str(), (int)textDefinition._fontSize,false)) { log("Can't found font(%s), use system default", textDefinition._fontName.c_str()); } @@ -501,7 +497,7 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text // draw text // does changing to SIZE here affects the font size by rounding from float? SIZE size = { (LONG)textDefinition._dimensions.width,(LONG)textDefinition._dimensions.height }; - CC_BREAK_IF(!dc.drawText(text, size, align, textDefinition._fontName.c_str(), textDefinition._fontSize, textDefinition._enableWrap, textDefinition._overflow)); + CC_BREAK_IF(!dc.drawText(text, size, align, textDefinition._fontName.c_str(), (int)textDefinition._fontSize, textDefinition._enableWrap, textDefinition._overflow)); int dataLen = size.cx * size.cy * 4; unsigned char* dataBuf = (unsigned char*)malloc(sizeof(unsigned char) * dataLen); @@ -557,5 +553,3 @@ void Device::vibrate(float duration) } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 \ No newline at end of file diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index d0cc12ebae..d3e599c725 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -23,10 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "platform/win32/CCFileUtils-win32.h" #include "platform/win32/CCUtils-win32.h" #include "platform/CCCommon.h" @@ -535,5 +531,3 @@ bool FileUtilsWin32::removeDirectory(const std::string& dirPath) const } NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 diff --git a/cocos/platform/win32/CCFileUtils-win32.h b/cocos/platform/win32/CCFileUtils-win32.h index d1c2fccbef..b64cab3b2c 100644 --- a/cocos/platform/win32/CCFileUtils-win32.h +++ b/cocos/platform/win32/CCFileUtils-win32.h @@ -23,11 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_FILEUTILS_WIN32_H__ -#define __CC_FILEUTILS_WIN32_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 +#pragma once #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" @@ -157,7 +153,3 @@ protected: /// @} NS_CC_END - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - -#endif // __CC_FILEUTILS_WIN32_H__ diff --git a/cocos/platform/win32/CCGL-win32.h b/cocos/platform/win32/CCGL-win32.h index 7a5fbccb8b..60d5023b6f 100644 --- a/cocos/platform/win32/CCGL-win32.h +++ b/cocos/platform/win32/CCGL-win32.h @@ -23,17 +23,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CCGL_H__ -#define __CCGL_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 +#pragma once #include "GL/glew.h" #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - -#endif // __CCGL_H__ diff --git a/cocos/platform/win32/CCPlatformDefine-win32.h b/cocos/platform/win32/CCPlatformDefine-win32.h index 81f9dc8a0a..12ed25a63b 100644 --- a/cocos/platform/win32/CCPlatformDefine-win32.h +++ b/cocos/platform/win32/CCPlatformDefine-win32.h @@ -25,9 +25,6 @@ THE SOFTWARE. ****************************************************************************/ #pragma once -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #ifdef __MINGW32__ #include #endif @@ -59,6 +56,3 @@ THE SOFTWARE. #define NULL ((void *)0) #endif #endif - -#endif //s CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - diff --git a/cocos/platform/win32/CCStdC-win32.cpp b/cocos/platform/win32/CCStdC-win32.cpp index 431c53d341..68f46b3a05 100644 --- a/cocos/platform/win32/CCStdC-win32.cpp +++ b/cocos/platform/win32/CCStdC-win32.cpp @@ -23,11 +23,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "platform/CCStdC.h" #ifndef __MINGW32__ @@ -50,5 +45,3 @@ int gettimeofday(struct timeval * val, struct timezone *) NS_CC_END #endif // __MINGW32__ - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 diff --git a/cocos/platform/win32/CCStdC-win32.h b/cocos/platform/win32/CCStdC-win32.h index 98ba8641d0..45114e8682 100644 --- a/cocos/platform/win32/CCStdC-win32.h +++ b/cocos/platform/win32/CCStdC-win32.h @@ -23,12 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_STD_C_H__ -#define __CC_STD_C_H__ - -#include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 +#pragma once #include #ifndef __SSIZE_T @@ -97,12 +92,12 @@ typedef SSIZE_T ssize_t; #ifndef NOMINMAX #define NOMINMAX #endif -// Structure timeval has define in winsock.h, include windows.h for it. -#include #ifndef __MINGW32__ #include +// Structure timeval has define in winsock.h, include windows.h for it. +#include NS_CC_BEGIN @@ -120,6 +115,7 @@ NS_CC_END #undef _WINSOCKAPI_ #include +#include // Conflicted with math.h isnan #include @@ -139,11 +135,6 @@ inline errno_t strcpy_s(char *strDestination, size_t numberOfElements, #endif #endif // __MINGW32__ -// Conflicted with cocos2d::MessageBox, so we need to undef it. -#ifdef MessageBox -#undef MessageBox -#endif - // Conflicted with ParticleSystem::PositionType::RELATIVE, so we need to undef it. #ifdef RELATIVE #undef RELATIVE @@ -161,10 +152,3 @@ inline errno_t strcpy_s(char *strDestination, size_t numberOfElements, #undef min #undef max - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - -#endif // __CC_STD_C_H__ - - - diff --git a/cocos/platform/win32/CCUtils-win32.h b/cocos/platform/win32/CCUtils-win32.h index 92795a1ad1..6f5d9a8185 100644 --- a/cocos/platform/win32/CCUtils-win32.h +++ b/cocos/platform/win32/CCUtils-win32.h @@ -23,9 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __CC_UTILS_WIN32_H__ -#define __CC_UTILS_WIN32_H__ +#pragma once #include "platform/CCPlatformMacros.h" @@ -38,5 +36,3 @@ std::string CC_DLL StringWideCharToUtf8(const std::wstring& strWideChar); std::string CC_DLL UTF8StringToMultiByte(const std::string& strUtf8); NS_CC_END - -#endif // __CC_UTILS_WIN32_H__ diff --git a/cocos/renderer/CCCustomCommand.cpp b/cocos/renderer/CCCustomCommand.cpp index c0f04b334e..f1c57d4d1c 100644 --- a/cocos/renderer/CCCustomCommand.cpp +++ b/cocos/renderer/CCCustomCommand.cpp @@ -61,7 +61,7 @@ void CustomCommand::init(float globalZOrder, const BlendFunc& blendFunc) blendDescriptor.destinationRGBBlendFactor = blendDescriptor.destinationAlphaBlendFactor = blendFunc.dst; } -void CustomCommand::createVertexBuffer(unsigned int vertexSize, unsigned int capacity, BufferUsage usage) +void CustomCommand::createVertexBuffer(std::size_t vertexSize, std::size_t capacity, BufferUsage usage) { CC_SAFE_RELEASE(_vertexBuffer); @@ -72,7 +72,7 @@ void CustomCommand::createVertexBuffer(unsigned int vertexSize, unsigned int cap _vertexBuffer = device->newBuffer(vertexSize * capacity, backend::BufferType::VERTEX, usage); } -void CustomCommand::createIndexBuffer(IndexFormat format, unsigned int capacity, BufferUsage usage) +void CustomCommand::createIndexBuffer(IndexFormat format, std::size_t capacity, BufferUsage usage) { CC_SAFE_RELEASE(_indexBuffer); @@ -85,13 +85,13 @@ void CustomCommand::createIndexBuffer(IndexFormat format, unsigned int capacity, _indexBuffer = device->newBuffer(_indexSize * capacity, backend::BufferType::INDEX, usage); } -void CustomCommand::updateVertexBuffer(void* data, unsigned int offset, unsigned int length) +void CustomCommand::updateVertexBuffer(void* data, std::size_t offset, std::size_t length) { assert(_vertexBuffer); _vertexBuffer->updateSubData(data, offset, length); } -void CustomCommand::updateIndexBuffer(void* data, unsigned int offset, unsigned int length) +void CustomCommand::updateIndexBuffer(void* data, std::size_t offset, std::size_t length) { assert(_indexBuffer); _indexBuffer->updateSubData(data, offset, length); @@ -118,24 +118,24 @@ void CustomCommand::setIndexBuffer(backend::Buffer *indexBuffer, IndexFormat for _indexSize = computeIndexSize(); } -void CustomCommand::updateVertexBuffer(void* data, unsigned int length) +void CustomCommand::updateVertexBuffer(void* data, std::size_t length) { assert(_vertexBuffer); _vertexBuffer->updateData(data, length); } -void CustomCommand::updateIndexBuffer(void* data, unsigned int length) +void CustomCommand::updateIndexBuffer(void* data, std::size_t length) { assert(_indexBuffer); _indexBuffer->updateData(data, length); } -unsigned int CustomCommand::computeIndexSize() const +std::size_t CustomCommand::computeIndexSize() const { if (IndexFormat::U_SHORT == _indexFormat) - return (unsigned int)sizeof(unsigned short); + return sizeof(unsigned short); else - return (unsigned int)sizeof(unsigned int); + return sizeof(unsigned int); } NS_CC_END diff --git a/cocos/renderer/CCCustomCommand.h b/cocos/renderer/CCCustomCommand.h index b952be8241..4513afd93d 100644 --- a/cocos/renderer/CCCustomCommand.h +++ b/cocos/renderer/CCCustomCommand.h @@ -102,7 +102,7 @@ public: @param usage the usage of the vertex buffer. Use Static of the vertex data are not updated every frame, otherwise use DYNAMIC. */ - void createVertexBuffer(unsigned int vertexSize, unsigned int capacity, BufferUsage usage); + void createVertexBuffer(std::size_t vertexSize, std::size_t capacity, BufferUsage usage); /** Create an index buffer of the custom command. The buffer size is (indexSize * capacity). Index size is determined by format. If the buffer already exists, then it will delete the @@ -113,43 +113,43 @@ public: @param usage the usage of the vertex buffer. Use Static of the index data are not updated every frame, otherwise use DYNAMIC. */ - void createIndexBuffer(IndexFormat format, unsigned int capacity, BufferUsage usage); + void createIndexBuffer(IndexFormat format, std::size_t capacity, BufferUsage usage); /** Update vertex buffer contents. @param data Specifies a pointer to the new data that will be copied into the data store. @param length Specifies the length in bytes of the data store region being replaced. */ - void updateVertexBuffer(void* data, unsigned int length); + void updateVertexBuffer(void* data, std::size_t length); /** Update index buffer contents. @param data Specifies a pointer to the new data that will be copied into the data store. @param length Specifies the size in bytes of the data store region being replaced. */ - void updateIndexBuffer(void* data, unsigned int length); + void updateIndexBuffer(void* data, std::size_t length); /** Update some or all contents of vertex buffer. @param data Specifies a pointer to the new data that will be copied into the data store. @param offset Specifies the offset into the buffer object's data store where data replacement will begin, measured in bytes. @param length Specifies the size in bytes of the data store region being replaced. */ - void updateVertexBuffer(void* data, unsigned int offset, unsigned int length); + void updateVertexBuffer(void* data, std::size_t offset, std::size_t length); /** Update some or call contents of index buffer @param data Specifies a pointer to the new data that will be copied into the data store. @param offset specifies the offset into the buffer object's data store where data replacement will begin, measured in bytes. @param length Specifies the size in bytes of the data store region being replaced. */ - void updateIndexBuffer(void* data, unsigned int offset, unsigned int length); + void updateIndexBuffer(void* data, std::size_t offset, std::size_t length); /** Get vertex buffer capacity. */ - inline unsigned int getVertexCapacity() const { return _vertexCapacity; } + inline std::size_t getVertexCapacity() const { return _vertexCapacity; } /** Get index buffer capacity. */ - inline unsigned int getIndexCapacity() const { return _indexCapacity; } + inline std::size_t getIndexCapacity() const { return _indexCapacity; } inline void setDrawType(DrawType drawType) { _drawType = drawType; } inline DrawType getDrawType() const { return _drawType; } @@ -174,18 +174,18 @@ public: @start specifices the starting index of vertex buffer @count specifices the number of vertices to be rendered */ - inline void setVertexDrawInfo(unsigned int start, unsigned int count) { _vertexDrawStart = start; _vertexDrawCount = count; } - inline unsigned int getVertexDrawStart() const { return _vertexDrawStart; } - inline unsigned int getVertexDrawCount() const { return _vertexDrawCount;} + inline void setVertexDrawInfo(std::size_t start, std::size_t count) { _vertexDrawStart = start; _vertexDrawCount = count; } + inline std::size_t getVertexDrawStart() const { return _vertexDrawStart; } + inline std::size_t getVertexDrawCount() const { return _vertexDrawCount;} /** Set the drawing information if the drawing type is ELEMENT. @start specifices the starting index of index buffer @count specifices the number of indices to be rendered */ - inline void setIndexDrawInfo(unsigned int start, unsigned int count) { _indexDrawOffset = start * _indexSize; _indexDrawCount = count; } - inline unsigned int getIndexDrawOffset() const { return _indexDrawOffset; } - inline unsigned int getIndexDrawCount() const { return _indexDrawCount; } + inline void setIndexDrawInfo(std::size_t start, std::size_t count) { _indexDrawOffset = start * _indexSize; _indexDrawCount = count; } + inline std::size_t getIndexDrawOffset() const { return _indexDrawOffset; } + inline std::size_t getIndexDrawCount() const { return _indexDrawCount; } inline void setLineWidth(float lineWidth) { _lineWidth = lineWidth; } inline float getLineWidth() const { return _lineWidth; } @@ -211,16 +211,16 @@ public: const CallBackFunc &getAfterCallback() { return _afterCallback; } protected: - unsigned int computeIndexSize() const; + std::size_t computeIndexSize() const; backend::Buffer* _vertexBuffer = nullptr; backend::Buffer* _indexBuffer = nullptr; - unsigned int _vertexDrawStart = 0; - unsigned int _vertexDrawCount = 0; + std::size_t _vertexDrawStart = 0; + std::size_t _vertexDrawCount = 0; - unsigned int _indexDrawOffset = 0; - unsigned int _indexDrawCount = 0; + std::size_t _indexDrawOffset = 0; + std::size_t _indexDrawCount = 0; DrawType _drawType = DrawType::ELEMENT; PrimitiveType _primitiveType = PrimitiveType::TRIANGLE; @@ -228,10 +228,10 @@ protected: float _lineWidth = 0.0; - unsigned int _indexSize = 0; + std::size_t _indexSize = 0; - unsigned int _vertexCapacity = 0; - unsigned int _indexCapacity = 0; + std::size_t _vertexCapacity = 0; + std::size_t _indexCapacity = 0; CallBackFunc _beforeCallback = nullptr; diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index e0360eddb8..1a6ed0562f 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -32,6 +32,7 @@ #include "renderer/CCPass.h" #include "renderer/CCTextureCache.h" #include "renderer/CCTexture2D.h" +#include "renderer/backend/Device.h" #include "base/CCProperties.h" #include "base/CCDirector.h" #include "platform/CCFileUtils.h" @@ -370,10 +371,10 @@ bool Material::parseShader(Pass* pass, Properties* shaderProperties) vertShaderSrc = defs + "\n" + vertShaderSrc; fragShaderSrc = defs + "\n" + fragShaderSrc; - auto programState = new backend::ProgramState(vertShaderSrc, fragShaderSrc); + auto* program = backend::Device::getInstance()->newProgram(vertShaderSrc, fragShaderSrc); + auto programState = new backend::ProgramState(program); pass->setProgramState(programState); - // Parse uniforms only if the GLProgramState was created auto property = shaderProperties->getNextProperty(); while (property) @@ -396,6 +397,8 @@ bool Material::parseShader(Pass* pass, Properties* shaderProperties) } space = shaderProperties->getNextNamespace(); } + CC_SAFE_RELEASE(program); + CC_SAFE_RELEASE(programState); } return true; diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index 58e58fa2f1..7d6699a056 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -34,6 +34,7 @@ THE SOFTWARE. #include "renderer/CCTexture2D.h" #include "platform/CCImage.h" +#include "platform/CCGL.h" #include "base/ccUtils.h" #include "platform/CCDevice.h" #include "base/ccConfig.h" @@ -222,7 +223,7 @@ bool Texture2D::hasPremultipliedAlpha() const return _hasPremultipliedAlpha; } -bool Texture2D::initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& /*contentSize*/) +bool Texture2D::initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& /*contentSize*/, bool preMultipliedAlpha) { CCASSERT(dataLen>0 && pixelsWide>0 && pixelsHigh>0, "Invalid size"); @@ -230,10 +231,10 @@ bool Texture2D::initWithData(const void *data, ssize_t dataLen, backend::PixelFo MipmapInfo mipmap; mipmap.address = (unsigned char*)data; mipmap.len = static_cast(dataLen); - return initWithMipmaps(&mipmap, 1, pixelFormat, renderFormat, pixelsWide, pixelsHigh); + return initWithMipmaps(&mipmap, 1, pixelFormat, renderFormat, pixelsWide, pixelsHigh, preMultipliedAlpha); } -bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh) +bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, bool preMultipliedAlpha) { //the pixelFormat must be a certain value CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!"); @@ -341,7 +342,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::Pi _maxS = 1; _maxT = 1; - _hasPremultipliedAlpha = false; + _hasPremultipliedAlpha = preMultipliedAlpha; _hasMipmaps = mipmapsNum > 1; return true; @@ -406,7 +407,7 @@ bool Texture2D::initWithImage(Image *image, backend::PixelFormat format) //override renderFormat, since some render format is not supported by metal switch (renderFormat) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS && !TARGET_OS_SIMULATOR) //packed 16 bits pixels only available on iOS case PixelFormat::RGB565: renderFormat = PixelFormat::MTL_B5G6R5; @@ -441,11 +442,8 @@ bool Texture2D::initWithImage(Image *image, backend::PixelFormat format) //pixel format of data is not converted, renderFormat can be different from pixelFormat //it will be done later - initWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getPixelFormat(), renderFormat, imageWidth, imageHeight); - - // set the premultiplied tag - _hasPremultipliedAlpha = image->hasPremultipliedAlpha(); - + initWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getPixelFormat(), renderFormat, imageWidth, imageHeight, image->hasPremultipliedAlpha()); + return true; } else if (image->isCompressed()) @@ -455,20 +453,14 @@ bool Texture2D::initWithImage(Image *image, backend::PixelFormat format) CCLOG("cocos2d: WARNING: This image is compressed and we can't convert it for now"); } - initWithData(tempData, tempDataLen, image->getPixelFormat(), imageWidth, imageHeight, imageSize); - - // set the premultiplied tag - _hasPremultipliedAlpha = image->hasPremultipliedAlpha(); + initWithData(tempData, tempDataLen, image->getPixelFormat(), imageWidth, imageHeight, imageSize, image->hasPremultipliedAlpha()); return true; } else { //after conversion, renderFormat == pixelFormat of data - initWithData(tempData, tempDataLen, imagePixelFormat, renderFormat, imageWidth, imageHeight, imageSize); - - // set the premultiplied tag - _hasPremultipliedAlpha = image->hasPremultipliedAlpha(); + initWithData(tempData, tempDataLen, imagePixelFormat, renderFormat, imageWidth, imageHeight, imageSize, image->hasPremultipliedAlpha()); return true; } @@ -570,7 +562,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin return ret; } -bool Texture2D::initWithBackendTexture(backend::TextureBackend *texture) +bool Texture2D::initWithBackendTexture(backend::TextureBackend *texture, bool preMultipliedAlpha) { CC_SAFE_RETAIN(texture); CC_SAFE_RELEASE(_texture); @@ -578,6 +570,8 @@ bool Texture2D::initWithBackendTexture(backend::TextureBackend *texture) CC_ASSERT(_texture); _pixelsWide = _contentSize.width = _texture->getWidth(); _pixelsHigh = _contentSize.height = _texture->getHeight(); + _hasPremultipliedAlpha = preMultipliedAlpha; + return true; } @@ -833,8 +827,8 @@ void Texture2D::initProgram() auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); //create program state - _programState = new (std::nothrow) cocos2d::backend::ProgramState( - positionTexture_vert, positionTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE); + _programState = new (std::nothrow) cocos2d::backend::ProgramState(program); _mvpMatrixLocation = _programState->getUniformLocation("u_MVPMatrix"); _textureLocation = _programState->getUniformLocation("u_texture"); diff --git a/cocos/renderer/CCTexture2D.h b/cocos/renderer/CCTexture2D.h index 3ff5778794..7dc2b81e2c 100644 --- a/cocos/renderer/CCTexture2D.h +++ b/cocos/renderer/CCTexture2D.h @@ -138,10 +138,11 @@ public: @param pixelsWide The image width. @param pixelsHigh The image height. @param contentSize The image content size. + @param preMultipliedAlpha The texture has premultiplied alpha * @js NA * @lua NA */ - bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize) { return initWithData(data, dataLen, pixelFormat, pixelFormat, pixelsWide, pixelsHigh, contentSize);} + bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize, bool preMultipliedAlpha = false) { return initWithData(data, dataLen, pixelFormat, pixelFormat, pixelsWide, pixelsHigh, contentSize, preMultipliedAlpha);} /** Initializes with a texture2d with data. @@ -152,10 +153,11 @@ public: @param pixelsWide The image width. @param pixelsHigh The image height. @param contentSize The image content size. + @param preMultipliedAlpha The texture has premultiplied alpha * @js NA * @lua NA */ - bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& contentSize); + bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& contentSize, bool preMultipliedAlpha = false); /** Initializes with mipmaps. @@ -164,8 +166,9 @@ public: @param pixelFormat The image pixelFormat. @param pixelsWide The image width. @param pixelsHigh The image height. + @param preMultipliedAlpha The texture has premultiplied alpha */ - bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh); + bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, bool preMultipliedAlpha = false); /** Update with texture data. @@ -228,7 +231,7 @@ public: bool initWithString(const char *text, const FontDefinition& textDefinition); //TODO: minggo: is it resaonable? - bool initWithBackendTexture(backend::TextureBackend* texture); + bool initWithBackendTexture(backend::TextureBackend* texture, bool preMultipliedAlpha = false); void setRenderTarget(bool renderTarget); inline bool isRenderTarget() const { return _isRenderTarget; } diff --git a/cocos/renderer/CCTrianglesCommand.cpp b/cocos/renderer/CCTrianglesCommand.cpp index 223cc7af4c..1b389da72b 100644 --- a/cocos/renderer/CCTrianglesCommand.cpp +++ b/cocos/renderer/CCTrianglesCommand.cpp @@ -54,18 +54,29 @@ void TrianglesCommand::init(float globalOrder, Texture2D* texture, const BlendFu { _program = _pipelineDescriptor.programState->getProgram(); _texture = texture->getBackendTexture(); - _blendType = blendType; + + //since it would be too expensive to check the uniforms, simplify enable batching for built-in program. + if(_program->getProgramType() == backend::ProgramType::INVALID_PROGRAM) + setSkipBatching(true); + //TODO: minggo set it in Node? auto& blendDescriptor = _pipelineDescriptor.blendDescriptor; blendDescriptor.blendEnabled = true; blendDescriptor.sourceRGBBlendFactor = blendDescriptor.sourceAlphaBlendFactor = blendType.src; blendDescriptor.destinationRGBBlendFactor = blendDescriptor.destinationAlphaBlendFactor = blendType.dst; - generateMaterialID(); + if(!isSkipBatching()) + generateMaterialID(); } } +void TrianglesCommand::updateMaterialID() +{ + setSkipBatching(false); + generateMaterialID(); +} + TrianglesCommand::~TrianglesCommand() { } diff --git a/cocos/renderer/CCTrianglesCommand.h b/cocos/renderer/CCTrianglesCommand.h index 22228e0933..8cc7fc5e67 100644 --- a/cocos/renderer/CCTrianglesCommand.h +++ b/cocos/renderer/CCTrianglesCommand.h @@ -98,6 +98,9 @@ public: const unsigned short* getIndices() const { return _triangles.indices; } /**Get the model view matrix.*/ const Mat4& getModelView() const { return _mv; } + + /** update material ID */ + void updateMaterialID(); protected: /**Generate the material ID by textureID, glProgramState, and blend function.*/ diff --git a/cocos/renderer/backend/Buffer.h b/cocos/renderer/backend/Buffer.h index 727feafd70..6dfde47e55 100644 --- a/cocos/renderer/backend/Buffer.h +++ b/cocos/renderer/backend/Buffer.h @@ -52,7 +52,7 @@ public: * @param size Specifies the size in bytes of the data store region being replaced. * @see `updateSubData(void* data, unsigned int offset, unsigned int size)` */ - virtual void updateData(void* data, unsigned int size) = 0; + virtual void updateData(void* data, std::size_t size) = 0; /** * @brief Update buffer sub-region data @@ -61,7 +61,7 @@ public: * @param size Specifies the size in bytes of the data store region being replaced. * @see `updateData(void* data, unsigned int size)` */ - virtual void updateSubData(void* data, unsigned int offset, unsigned int size) = 0; + virtual void updateSubData(void* data, std::size_t offset, std::size_t size) = 0; /** * By default, static buffer data will automatically stored when it comes to foreground. @@ -74,7 +74,7 @@ public: * Get buffer size in bytes. * @return The buffer size in bytes. */ - unsigned int getSize() const { return _size; } + std::size_t getSize() const { return _size; } protected: /** @@ -82,7 +82,7 @@ protected: * @param type Specifies the target buffer object. The symbolic constant must be BufferType::VERTEX or BufferType::INDEX. * @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW. */ - Buffer(unsigned int size, BufferType type, BufferUsage usage) + Buffer(std::size_t size, BufferType type, BufferUsage usage) : _usage(usage) , _type(type) , _size(size) @@ -92,7 +92,7 @@ protected: BufferUsage _usage = BufferUsage::DYNAMIC; ///< Buffer usage. BufferType _type = BufferType::VERTEX; ///< Buffer type. - unsigned int _size = 0; ///< buffer size in bytes. + std::size_t _size = 0; ///< buffer size in bytes. }; // end of _backend group diff --git a/cocos/renderer/backend/CommandBuffer.h b/cocos/renderer/backend/CommandBuffer.h index 8cab5760e6..eab781b59b 100644 --- a/cocos/renderer/backend/CommandBuffer.h +++ b/cocos/renderer/backend/CommandBuffer.h @@ -122,7 +122,7 @@ public: * @param count For each instance, the number of indexes to draw * @see `drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)` */ - virtual void drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count) = 0; + virtual void drawArrays(PrimitiveType primitiveType, std::size_t start, std::size_t count) = 0; /** * Draw primitives with an index list. @@ -133,7 +133,7 @@ public: * @see `setIndexBuffer(Buffer* buffer)` * @see `drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)` */ - virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset) = 0; + virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset) = 0; /** * Do some resources release. diff --git a/cocos/renderer/backend/Device.h b/cocos/renderer/backend/Device.h index f43e38ee14..f5f516ef30 100644 --- a/cocos/renderer/backend/Device.h +++ b/cocos/renderer/backend/Device.h @@ -80,7 +80,7 @@ public: * @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be BufferUsage::STATIC, BufferUsage::DYNAMIC. * @return A Buffer object. */ - virtual Buffer* newBuffer(uint32_t size, BufferType type, BufferUsage usage) = 0; + virtual Buffer* newBuffer(size_t size, BufferType type, BufferUsage usage) = 0; /** * New a TextureBackend object, not auto released. @@ -113,11 +113,20 @@ public: */ virtual void setFrameBufferOnly(bool frameBufferOnly) = 0; + /** + * Create an auto released Program. + * @param vertexShader Specifes this is a vertex shader source. + * @param fragmentShader Specifes this is a fragment shader source. + * @return A Program instance. + */ + virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) = 0; + /** * Get a DeviceInfo object. * @return A DeviceInfo object. */ inline DeviceInfo* getDeviceInfo() const { return _deviceInfo; } + protected: /** * New a shaderModule, not auto released. @@ -126,17 +135,9 @@ protected: * @return A ShaderModule object. */ virtual ShaderModule* newShaderModule(ShaderStage stage, const std::string& source) = 0; - - /** - * New a Program, not auto released. - * @param vertexShader Specifes this is a vertex shader source. - * @param fragmentShader Specifes this is a fragment shader source. - * @return A Program object. - */ - virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) = 0; - + DeviceInfo* _deviceInfo = nullptr; ///< Device information. - + private: static Device* _instance; }; diff --git a/cocos/renderer/backend/Program.cpp b/cocos/renderer/backend/Program.cpp index 22cd793826..48dcb73bc3 100644 --- a/cocos/renderer/backend/Program.cpp +++ b/cocos/renderer/backend/Program.cpp @@ -23,6 +23,7 @@ ****************************************************************************/ #include "Program.h" +#include "ProgramCache.h" CC_BACKEND_BEGIN @@ -37,4 +38,9 @@ void Program::setProgramType(ProgramType type) _programType = type; } +Program* Program::getBuiltinProgram(ProgramType type) +{ + return ProgramCache::getInstance()->getBuiltinProgram(type); +} + CC_BACKEND_END diff --git a/cocos/renderer/backend/Program.h b/cocos/renderer/backend/Program.h index b2852688ae..5d58233524 100644 --- a/cocos/renderer/backend/Program.h +++ b/cocos/renderer/backend/Program.h @@ -50,6 +50,12 @@ class ShaderModule; class Program : public Ref { public: + /** + * Get engine built-in program. + * @param type Specifies the built-in program type. + */ + static Program* getBuiltinProgram(ProgramType type); + /** * Get uniform location by name. * @param uniform Specifies the uniform name. @@ -178,7 +184,7 @@ protected: std::string _vertexShader; ///< Vertex shader. std::string _fragmentShader; ///< Fragment shader. - ProgramType _programType; ///< built-in program type. + ProgramType _programType = ProgramType::INVALID_PROGRAM; ///< built-in program type. }; //end of _backend group diff --git a/cocos/renderer/backend/ProgramCache.cpp b/cocos/renderer/backend/ProgramCache.cpp index 49909e1fe1..0166a3724d 100644 --- a/cocos/renderer/backend/ProgramCache.cpp +++ b/cocos/renderer/backend/ProgramCache.cpp @@ -27,37 +27,43 @@ #include "ShaderModule.h" #include "renderer/ccShaders.h" #include "base/ccMacros.h" +#include "base/CCConfiguration.h" -namespace { - struct Shader +namespace std +{ + template <> + struct hash { - std::string vert; - std::string frag; - - Shader(const std::string& _vert, const std::string& _frag) - :vert(_vert), - frag(_frag) - {} - }; -} - -namespace std { - template<> struct hash - { - typedef Shader argument_type; + typedef cocos2d::backend::ProgramType argument_type; typedef std::size_t result_type; - result_type operator()(argument_type const& s) const noexcept + result_type operator()(argument_type const& v) const { - result_type const h1(std::hash < std::string>{}(s.vert)); - result_type const h2(std::hash{}(s.frag)); - return h1 ^ (h2 << 1); + return hash()(static_cast(v)); } }; } CC_BACKEND_BEGIN -std::unordered_map ProgramCache::_cachedPrograms; +namespace +{ + std::string getShaderMacrosForLight() + { + char def[256]; + auto conf = Configuration::getInstance(); + + snprintf(def, sizeof(def) - 1, "\n#define MAX_DIRECTIONAL_LIGHT_NUM %d \n" + "\n#define MAX_POINT_LIGHT_NUM %d \n" + "\n#define MAX_SPOT_LIGHT_NUM %d \n", + conf->getMaxSupportDirLightInShader(), + conf->getMaxSupportPointLightInShader(), + conf->getMaxSupportSpotLightInShader()); + + return std::string(def); + } +} + +std::unordered_map ProgramCache::_cachedPrograms; ProgramCache* ProgramCache::_sharedProgramCache = nullptr; ProgramCache* ProgramCache::getInstance() @@ -99,6 +105,7 @@ bool ProgramCache::init() addProgram(ProgramType::POSITION_COLOR_LENGTH_TEXTURE); addProgram(ProgramType::POSITION_COLOR_TEXTURE_AS_POINTSIZE); addProgram(ProgramType::POSITION_COLOR); + addProgram(ProgramType::POSITION); addProgram(ProgramType::LAYER_RADIA_GRADIENT); addProgram(ProgramType::POSITION_TEXTURE); addProgram(ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST); @@ -106,6 +113,19 @@ bool ProgramCache::init() addProgram(ProgramType::ETC1_GRAY); addProgram(ProgramType::GRAY_SCALE); addProgram(ProgramType::LINE_COLOR_3D); + addProgram(ProgramType::CAMERA_CLEAR); + addProgram(ProgramType::SKYBOX_3D); + addProgram(ProgramType::SKINPOSITION_TEXTURE_3D); + addProgram(ProgramType::SKINPOSITION_NORMAL_TEXTURE_3D); + addProgram(ProgramType::POSITION_NORMAL_TEXTURE_3D); + addProgram(ProgramType::POSITION_TEXTURE_3D); + addProgram(ProgramType::POSITION_3D); + addProgram(ProgramType::POSITION_NORMAL_3D); + addProgram(ProgramType::POSITION_BUMPEDNORMAL_TEXTURE_3D); + addProgram(ProgramType::SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D); + addProgram(ProgramType::TERRAIN_3D); + addProgram(ProgramType::PARTICLE_TEXTURE_3D); + addProgram(ProgramType::PARTICLE_COLOR_3D); return true; } @@ -140,6 +160,9 @@ void ProgramCache::addProgram(ProgramType type) case ProgramType::POSITION_COLOR: program = backend::Device::getInstance()->newProgram(positionColor_vert, positionColor_frag); break; + case ProgramType::POSITION: + program = backend::Device::getInstance()->newProgram(position_vert, positionColor_frag); + break; case ProgramType::LAYER_RADIA_GRADIENT: program = backend::Device::getInstance()->newProgram(position_vert, layer_radialGradient_frag); break; @@ -161,6 +184,62 @@ void ProgramCache::addProgram(ProgramType type) case ProgramType::LINE_COLOR_3D: program = backend::Device::getInstance()->newProgram(lineColor3D_vert, lineColor3D_frag); break; + case ProgramType::CAMERA_CLEAR: + program = backend::Device::getInstance()->newProgram(cameraClear_vert, cameraClear_frag); + break; + case ProgramType::SKYBOX_3D: + program = backend::Device::getInstance()->newProgram(CC3D_skybox_vert, CC3D_skybox_frag); + break; + case ProgramType::SKINPOSITION_TEXTURE_3D: + program = backend::Device::getInstance()->newProgram(CC3D_skinPositionTexture_vert, CC3D_colorTexture_frag); + break; + case ProgramType::SKINPOSITION_NORMAL_TEXTURE_3D: + { + std::string def = getShaderMacrosForLight(); + program = backend::Device::getInstance()->newProgram(def + CC3D_skinPositionNormalTexture_vert, def + CC3D_colorNormalTexture_frag); + } + break; + case ProgramType::POSITION_NORMAL_TEXTURE_3D: + { + std::string def = getShaderMacrosForLight(); + program = backend::Device::getInstance()->newProgram(def + CC3D_positionNormalTexture_vert, def + CC3D_colorNormalTexture_frag); + } + break; + case ProgramType::POSITION_TEXTURE_3D: + program = backend::Device::getInstance()->newProgram(CC3D_positionTexture_vert, CC3D_colorTexture_frag); + break; + case ProgramType::POSITION_3D: + program = backend::Device::getInstance()->newProgram(CC3D_positionTexture_vert, CC3D_color_frag); + break; + case ProgramType::POSITION_NORMAL_3D: + { + std::string def = getShaderMacrosForLight(); + program = backend::Device::getInstance()->newProgram(def + CC3D_positionNormalTexture_vert, def + CC3D_colorNormal_frag); + } + break; + case ProgramType::POSITION_BUMPEDNORMAL_TEXTURE_3D: + { + std::string def = getShaderMacrosForLight(); + std::string normalMapDef = "\n#define USE_NORMAL_MAPPING 1 \n"; + program = backend::Device::getInstance()->newProgram(def + normalMapDef + CC3D_positionNormalTexture_vert, def + normalMapDef + CC3D_colorNormalTexture_frag); + } + break; + case ProgramType::SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D: + { + std::string def = getShaderMacrosForLight(); + std::string normalMapDef = "\n#define USE_NORMAL_MAPPING 1 \n"; + program = backend::Device::getInstance()->newProgram(def + normalMapDef + CC3D_skinPositionNormalTexture_vert, def + normalMapDef + CC3D_colorNormalTexture_frag); + } + break; + case ProgramType::TERRAIN_3D: + program = backend::Device::getInstance()->newProgram(CC3D_terrain_vert, CC3D_terrain_frag); + break; + case ProgramType::PARTICLE_TEXTURE_3D: + program = backend::Device::getInstance()->newProgram(CC3D_particle_vert, CC3D_particleTexture_frag); + break; + case ProgramType::PARTICLE_COLOR_3D: + program = backend::Device::getInstance()->newProgram(CC3D_particle_vert, CC3D_particleColor_frag); + break; default: CCASSERT(false, "Not built-in program type."); break; @@ -169,35 +248,14 @@ void ProgramCache::addProgram(ProgramType type) ProgramCache::_cachedPrograms.emplace(type, program); } -void ProgramCache::addProgram(const std::string& vertexShader, const std::string& fragmentShader) -{ - auto key = std::hash{}(Shader(vertexShader, fragmentShader)); - auto program = backend::Device::getInstance()->newProgram(vertexShader, fragmentShader); - ProgramCache::_cachedPrograms.emplace(key, program); -} - -backend::Program* ProgramCache::newBuiltinProgram(ProgramType type) +backend::Program* ProgramCache::getBuiltinProgram(ProgramType type) const { const auto& iter = ProgramCache::_cachedPrograms.find(type); - if (ProgramCache::_cachedPrograms.end() != iter) - return iter->second; - return nullptr; -} - -backend::Program* ProgramCache::newProgram(const std::string& vertexShader, const std::string& fragmentShader) -{ - auto key = std::hash{}(Shader(vertexShader, fragmentShader)); - const auto& iter = ProgramCache::_cachedPrograms.find(key); if (ProgramCache::_cachedPrograms.end() != iter) { - CC_SAFE_RETAIN(iter->second); return iter->second; } - - auto program = backend::Device::getInstance()->newProgram(vertexShader, fragmentShader); - ProgramCache::_cachedPrograms.emplace(key, program); - - return program; + return nullptr; } void ProgramCache::removeProgram(backend::Program* program) diff --git a/cocos/renderer/backend/ProgramCache.h b/cocos/renderer/backend/ProgramCache.h index 3a0a3613f4..71a3d0e4a0 100644 --- a/cocos/renderer/backend/ProgramCache.h +++ b/cocos/renderer/backend/ProgramCache.h @@ -49,15 +49,9 @@ public: /** purges the cache. It releases the retained instance. */ static void destroyInstance(); - - /** - * @param vertexShader Specifes the vertex shader source. - * @param fragmentShader Specifes the fragment shader source. - */ - backend::Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader); /// get built-in program - backend::Program* newBuiltinProgram(ProgramType type); + backend::Program* getBuiltinProgram(ProgramType type) const; /** * Remove a program object from cache. @@ -84,16 +78,10 @@ protected: */ bool init(); - /** - * @param vertexShader Specifes the vertex shader source. - * @param fragmentShader Specifes the fragment shader source. - */ - void addProgram(const std::string& vertexShader, const std::string& fragmentShader); - /// Add built-in program void addProgram(ProgramType type); - static std::unordered_map _cachedPrograms; ///< The cached program object. + static std::unordered_map _cachedPrograms; ///< The cached program object. static ProgramCache *_sharedProgramCache; ///< A shared instance of the program cache. }; diff --git a/cocos/renderer/backend/ProgramState.cpp b/cocos/renderer/backend/ProgramState.cpp index 3094e354ac..878d8c5b6d 100644 --- a/cocos/renderer/backend/ProgramState.cpp +++ b/cocos/renderer/backend/ProgramState.cpp @@ -155,25 +155,15 @@ TextureInfo& TextureInfo::operator=(const TextureInfo& rhs) return *this; } -ProgramState::ProgramState(ProgramType type) +ProgramState::ProgramState(Program* program) { - _program = backend::ProgramCache::getInstance()->newBuiltinProgram(type); - CCASSERT(_program, "Not built-in program type, please use ProgramState(const std::string& vertexShader, const std::string& fragmentShader) instead."); - CC_SAFE_RETAIN(_program); - - init(); + init(program); } -ProgramState::ProgramState(const std::string& vertexShader, const std::string& fragmentShader) -{ - _program = backend::ProgramCache::getInstance()->newProgram(vertexShader, fragmentShader); - CC_SAFE_RETAIN(_program); - - init(); -} - -void ProgramState::init() +bool ProgramState::init(Program* program) { + CC_SAFE_RETAIN(program); + _program = program; _vertexUniformBufferSize = _program->getUniformBufferSize(ShaderStage::VERTEX); _vertexUniformBuffer = new char[_vertexUniformBufferSize]; memset(_vertexUniformBuffer, 0, _vertexUniformBufferSize); @@ -189,6 +179,7 @@ void ProgramState::init() }); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1); #endif + return true; } void ProgramState::resetUniforms() @@ -262,7 +253,7 @@ void ProgramState::setCallbackUniform(const backend::UniformLocation& uniformLoc _callbackUniforms[uniformLocation] = callback; } -void ProgramState::setUniform(const backend::UniformLocation& uniformLocation, const void* data, uint32_t size) +void ProgramState::setUniform(const backend::UniformLocation& uniformLocation, const void* data, std::size_t size) { switch (uniformLocation.shaderStage) { @@ -282,7 +273,7 @@ void ProgramState::setUniform(const backend::UniformLocation& uniformLocation, c } #ifdef CC_USE_METAL -void ProgramState::convertAndCopyUniformData(const backend::UniformInfo& uniformInfo, const void* srcData, uint32_t srcSize, void* buffer) +void ProgramState::convertAndCopyUniformData(const backend::UniformInfo& uniformInfo, const void* srcData, std::size_t srcSize, void* buffer) { auto basicType = static_cast(uniformInfo.type); char* convertedData = new char[uniformInfo.size]; @@ -350,7 +341,7 @@ void ProgramState::convertAndCopyUniformData(const backend::UniformInfo& uniform } #endif -void ProgramState::setVertexUniform(int location, const void* data, uint32_t size, uint32_t offset) +void ProgramState::setVertexUniform(int location, const void* data, std::size_t size, std::size_t offset) { if(location < 0) return; @@ -371,7 +362,7 @@ void ProgramState::setVertexUniform(int location, const void* data, uint32_t siz #endif } -void ProgramState::setFragmentUniform(int location, const void* data, uint32_t size) +void ProgramState::setFragmentUniform(int location, const void* data, std::size_t size) { if(location < 0) return; @@ -433,6 +424,7 @@ void ProgramState::setTexture(int location, uint32_t slot, backend::TextureBacke if(location < 0) return; TextureInfo& info = textureInfo[location]; + info.releaseTextures(); info.slot = {slot}; info.textures = {texture}; info.retainTextures(); @@ -445,6 +437,7 @@ void ProgramState::setTextureArray(int location, const std::vector& sl { assert(slots.size() == textures.size()); TextureInfo& info = textureInfo[location]; + info.releaseTextures(); info.slot = slots; info.textures = textures; info.retainTextures(); diff --git a/cocos/renderer/backend/ProgramState.h b/cocos/renderer/backend/ProgramState.h index f8226f50c4..ff45a25dab 100644 --- a/cocos/renderer/backend/ProgramState.h +++ b/cocos/renderer/backend/ProgramState.h @@ -78,19 +78,10 @@ public: using UniformCallback = std::function; /** - * @param vertexShader Specifies the vertex shader. - * @param fragmentShader Specifies the fragment shader. - * @see `ProgramState(ProgramType type)` + * @param program Specifies the program. */ - ProgramState(const std::string& vertexShader, const std::string& fragmentShader); + ProgramState(Program* program); - /** - * Create an program state object more efficient by engine built-in program type. - * @param type Specifies the built-in program type. - * @see `ProgramState(const std::string& vertexShader, const std::string& fragmentShader)` - */ - ProgramState(ProgramType type); - ///destructor virtual ~ProgramState(); @@ -110,7 +101,7 @@ public: * @param data Specifies the new values to be used for the specified uniform variable. * @param size Specifies the uniform data size. */ - void setUniform(const backend::UniformLocation& uniformLocation, const void* data, uint32_t size); + void setUniform(const backend::UniformLocation& uniformLocation, const void* data, std::size_t size); /** * Get uniform location in given uniform name. @@ -272,7 +263,7 @@ protected: * @param data Specifies the new values to be used for the specified uniform variable. * @param size Specifies the uniform data size. */ - void setVertexUniform(int location, const void* data, uint32_t size, uint32_t offset); + void setVertexUniform(int location, const void* data, std::size_t size, std::size_t offset); /** * Set the fargment uniform data. @@ -280,7 +271,7 @@ protected: * @param data Specifies the new values to be used for the specified uniform variable. * @param size Specifies the uniform data size. */ - void setFragmentUniform(int location, const void* data, uint32_t size); + void setFragmentUniform(int location, const void* data, std::size_t size); /** * Set texture. @@ -306,7 +297,7 @@ protected: void resetUniforms(); ///Initialize. - void init(); + bool init(Program* program); #ifdef CC_USE_METAL /** @@ -316,7 +307,7 @@ protected: * @param srcSize Specifies the uniform data size. * @param uniformBuffer Specifies the uniform buffer to update. */ - void convertAndCopyUniformData(const backend::UniformInfo& uniformInfo, const void* srcData, uint32_t srcSize, void* buffer); + void convertAndCopyUniformData(const backend::UniformInfo& uniformInfo, const void* srcData, std::size_t srcSize, void* buffer); #endif /** * Applies the specified custom auto-binding. diff --git a/cocos/renderer/backend/Texture.h b/cocos/renderer/backend/Texture.h index a20754eec9..bd8435cafc 100644 --- a/cocos/renderer/backend/Texture.h +++ b/cocos/renderer/backend/Texture.h @@ -69,7 +69,7 @@ public: * @param flipImage Specifies if needs to flip the image. * @param callback Specifies a call back function to deal with the image. */ - virtual void getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) = 0; + virtual void getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) = 0; /// Generate mipmaps. virtual void generateMipmaps() = 0; @@ -136,7 +136,7 @@ public: * @param height Specifies the height of the texture image. * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. */ - virtual void updateData(uint8_t* data, uint32_t width , uint32_t height, uint32_t level) = 0; + virtual void updateData(uint8_t* data, std::size_t width , std::size_t height, std::size_t level) = 0; /** * Update a two-dimensional texture image in a compressed format @@ -146,7 +146,7 @@ public: * @param dataLen Specifies the totoal size of compressed image in bytes. * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. */ - virtual void updateCompressedData(uint8_t* data, uint32_t width , uint32_t height, uint32_t dataLen, uint32_t level) = 0; + virtual void updateCompressedData(uint8_t* data, std::size_t width , std::size_t height, std::size_t dataLen, std::size_t level) = 0; /** * Update a two-dimensional texture subimage @@ -157,7 +157,7 @@ public: * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. * @param data Specifies a pointer to the image data in memory. */ - virtual void updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t level, uint8_t* data) = 0; + virtual void updateSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t level, uint8_t* data) = 0; /** * Update a two-dimensional texture subimage in a compressed format @@ -169,19 +169,19 @@ public: * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. * @param data Specifies a pointer to the compressed image data in memory. */ - virtual void updateCompressedSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t dataLen, uint32_t level, uint8_t* data) = 0; + virtual void updateCompressedSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t dataLen, std::size_t level, uint8_t* data) = 0; /** * Get texture width. * @return Texture width. */ - inline uint32_t getWidth() const { return _width; } + inline std::size_t getWidth() const { return _width; } /** * Get texture height. * @return Texture height. */ - inline uint32_t getHeight() const { return _height; } + inline std::size_t getHeight() const { return _height; } protected: /** diff --git a/cocos/renderer/backend/Types.h b/cocos/renderer/backend/Types.h index 99ceba4cb9..e70ac8c956 100644 --- a/cocos/renderer/backend/Types.h +++ b/cocos/renderer/backend/Types.h @@ -326,26 +326,42 @@ enum class TextureCubeFace : uint32_t NEGATIVE_Z = 5 }; -enum ProgramType +enum class ProgramType : int { - POSITION_COLOR_LENGTH_TEXTURE, - POSITION_COLOR_TEXTURE_AS_POINTSIZE, - POSITION_COLOR, - POSITION_UCOLOR, - POSITION_TEXTURE, - POSITION_TEXTURE_COLOR, - POSITION_TEXTURE_COLOR_ALPHA_TEST, - LABEL_NORMAL, - LABLE_OUTLINE, - LABLE_DISTANCEFIELD_GLOW, - LABEL_DISTANCE_NORMAL, + INVALID_PROGRAM = -1, + POSITION_COLOR_LENGTH_TEXTURE, //positionColorLengthTexture_vert, positionColorLengthTexture_frag + POSITION_COLOR_TEXTURE_AS_POINTSIZE, //positionColorTextureAsPointsize_vert, positionColor_frag + POSITION_COLOR, //positionColor_vert, positionColor_frag + POSITION, //position_vert, positionColor_frag + POSITION_UCOLOR, //positionUColor_vert, positionUColor_frag + POSITION_TEXTURE, //positionTexture_vert, positionTexture_frag + POSITION_TEXTURE_COLOR, //positionTextureColor_vert, positionTextureColor_frag + POSITION_TEXTURE_COLOR_ALPHA_TEST, //positionTextureColor_vert, positionTextureColorAlphaTest_frag + LABEL_NORMAL, //positionTextureColor_vert, label_normal_frag + LABLE_OUTLINE, //positionTextureColor_vert, labelOutline_frag + LABLE_DISTANCEFIELD_GLOW, //positionTextureColor_vert, labelDistanceFieldGlow_frag + LABEL_DISTANCE_NORMAL, //positionTextureColor_vert, label_distanceNormal_frag - LAYER_RADIA_GRADIENT, + LAYER_RADIA_GRADIENT, //position_vert, layer_radialGradient_frag - ETC1, - ETC1_GRAY, - GRAY_SCALE, - LINE_COLOR_3D, + ETC1, //positionTextureColor_vert, etc1_frag + ETC1_GRAY, //positionTextureColor_vert, etc1Gray_frag + GRAY_SCALE, //positionTextureColor_vert, grayScale_frag + CAMERA_CLEAR, //cameraClear_vert, cameraClear_frag + + TERRAIN_3D, //CC3D_terrain_vert, CC3D_terrain_frag + LINE_COLOR_3D, //lineColor3D_vert, lineColor3D_frag + SKYBOX_3D, //CC3D_skybox_vert, CC3D_skybox_frag + SKINPOSITION_TEXTURE_3D, //CC3D_skinPositionTexture_vert, CC3D_colorTexture_frag + SKINPOSITION_NORMAL_TEXTURE_3D, //CC3D_skinPositionNormalTexture_vert, CC3D_colorNormalTexture_frag + POSITION_NORMAL_TEXTURE_3D, //CC3D_positionNormalTexture_vert, CC3D_colorNormalTexture_frag + POSITION_NORMAL_3D, //CC3D_positionNormalTexture_vert, CC3D_colorNormal_frag + POSITION_TEXTURE_3D, //CC3D_positionTexture_vert, CC3D_colorTexture_frag + POSITION_3D, //CC3D_positionTexture_vert, CC3D_color_frag + POSITION_BUMPEDNORMAL_TEXTURE_3D, //CC3D_positionNormalTexture_vert, CC3D_colorNormalTexture_frag + SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D, //CC3D_skinPositionNormalTexture_vert, CC3D_colorNormalTexture_frag + PARTICLE_TEXTURE_3D, //CC3D_particle_vert, CC3D_particleTexture_frag + PARTICLE_COLOR_3D, //CC3D_particle_vert, CC3D_particleColor_frag }; ///built-in uniform name diff --git a/cocos/renderer/backend/VertexLayout.cpp b/cocos/renderer/backend/VertexLayout.cpp index 99559ec8d4..a2bedb9d9a 100644 --- a/cocos/renderer/backend/VertexLayout.cpp +++ b/cocos/renderer/backend/VertexLayout.cpp @@ -28,7 +28,7 @@ CC_BACKEND_BEGIN -void VertexLayout::setAttribute(const std::string &name, unsigned int index, VertexFormat format, unsigned int offset, bool needToBeNormallized) +void VertexLayout::setAttribute(const std::string &name, std::size_t index, VertexFormat format, std::size_t offset, bool needToBeNormallized) { if(index == -1) return; @@ -36,7 +36,7 @@ void VertexLayout::setAttribute(const std::string &name, unsigned int index, Ver _attributes[name] = { name, index, format, offset, needToBeNormallized }; } -void VertexLayout::setLayout(unsigned int stride) +void VertexLayout::setLayout(std::size_t stride) { _stride = stride; } diff --git a/cocos/renderer/backend/VertexLayout.h b/cocos/renderer/backend/VertexLayout.h index c8cdbb64bb..c158165d42 100644 --- a/cocos/renderer/backend/VertexLayout.h +++ b/cocos/renderer/backend/VertexLayout.h @@ -48,7 +48,7 @@ public: struct Attribute { Attribute() = default; - Attribute(const std::string& _name, unsigned int _index, VertexFormat _format, unsigned int _offset, bool needToBeNormallized) + Attribute(const std::string& _name, std::size_t _index, VertexFormat _format, std::size_t _offset, bool needToBeNormallized) : name(_name) , format(_format) , offset(_offset) @@ -58,8 +58,8 @@ public: std::string name; ///< name is used in opengl VertexFormat format = VertexFormat::INT3; - unsigned int offset = 0; - unsigned int index = 0; ///< index is used in metal + std::size_t offset = 0; + std::size_t index = 0; ///< index is used in metal bool needToBeNormallized = false; }; @@ -73,19 +73,19 @@ public: * @param offset Specifies the byte offset to the first component of the first generic vertex attribute. * @param needToBeNormallized Specifies whether fixed-point data values should be normalized (true) or converted directly as fixed-point values (false) when they are accessed. */ - void setAttribute(const std::string& name, unsigned int index, VertexFormat format, unsigned int offset, bool needToBeNormallized); + void setAttribute(const std::string& name, std::size_t index, VertexFormat format, std::size_t offset, bool needToBeNormallized); /** * Set stride of vertices. * @param stride Specifies the distance between the data of two vertices, in bytes. */ - void setLayout(unsigned int stride); + void setLayout(std::size_t stride); /** * Get the distance between the data of two vertices, in bytes. * @return The distance between the data of two vertices, in bytes. */ - inline unsigned int getStride() const { return _stride; } + inline std::size_t getStride() const { return _stride; } /** * Get vertex step function. Default value is VERTEX. @@ -107,7 +107,7 @@ public: private: std::unordered_map _attributes; - unsigned int _stride = 0; + std::size_t _stride = 0; VertexStepMode _stepMode = VertexStepMode::VERTEX; }; diff --git a/cocos/renderer/backend/metal/BufferMTL.h b/cocos/renderer/backend/metal/BufferMTL.h index 961be773ca..4ce742ae99 100644 --- a/cocos/renderer/backend/metal/BufferMTL.h +++ b/cocos/renderer/backend/metal/BufferMTL.h @@ -50,7 +50,7 @@ public: * @param type Specifies the target buffer object. The symbolic constant must be BufferType::VERTEX or BufferType::INDEX. * @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be BufferUsage::STATIC, BufferUsage::DYNAMIC. */ - BufferMTL(id mtlDevice, unsigned int size, BufferType type, BufferUsage usage); + BufferMTL(id mtlDevice, std::size_t size, BufferType type, BufferUsage usage); ~BufferMTL(); /// @name Update Buffer @@ -60,7 +60,7 @@ public: * @param size Specifies the size in bytes of the data store region being replaced. * @see `updateSubData(void* data, unsigned int offset, unsigned int size)` */ - virtual void updateData(void* data, unsigned int size) override; + virtual void updateData(void* data, std::size_t size) override; /** * @brief Update buffer sub-region data @@ -69,7 +69,7 @@ public: * @param size Specifies the size in bytes of the data store region being replaced. * @see `updateData(void* data, unsigned int size)` */ - virtual void updateSubData(void* data, unsigned int offset, unsigned int size) override; + virtual void updateSubData(void* data, std::size_t offset, std::size_t size) override; /** * Emply implementation. Mainly used in EGL context lost. diff --git a/cocos/renderer/backend/metal/BufferMTL.mm b/cocos/renderer/backend/metal/BufferMTL.mm index 2f0b1142b2..9abe3d62a4 100644 --- a/cocos/renderer/backend/metal/BufferMTL.mm +++ b/cocos/renderer/backend/metal/BufferMTL.mm @@ -28,7 +28,7 @@ CC_BACKEND_BEGIN -BufferMTL::BufferMTL(id mtlDevice, unsigned int size, BufferType type, BufferUsage usage) +BufferMTL::BufferMTL(id mtlDevice, std::size_t size, BufferType type, BufferUsage usage) : Buffer(size, type, usage) { if (BufferUsage::DYNAMIC == usage) @@ -68,14 +68,14 @@ BufferMTL::~BufferMTL() } } -void BufferMTL::updateData(void* data, unsigned int size) +void BufferMTL::updateData(void* data, std::size_t size) { assert(size <= _size); updateIndex(); memcpy((uint8_t*)_mtlBuffer.contents, data, size); } -void BufferMTL::updateSubData(void* data, unsigned int offset, unsigned int size) +void BufferMTL::updateSubData(void* data, std::size_t offset, std::size_t size) { assert(offset + size <= _size); updateIndex(); diff --git a/cocos/renderer/backend/metal/CommandBufferMTL.h b/cocos/renderer/backend/metal/CommandBufferMTL.h index 7e3874a721..edc44d154c 100644 --- a/cocos/renderer/backend/metal/CommandBufferMTL.h +++ b/cocos/renderer/backend/metal/CommandBufferMTL.h @@ -42,7 +42,7 @@ class RenderPipelineMTL; * @brief Store encoded commands for the GPU to execute. * A command buffer stores encoded commands until the buffer is committed for execution by the GPU */ -class CommandBufferMTL final : public CommandBuffer +class CommandBufferMTL : public CommandBuffer { public: /// @name Constructor, Destructor and Initializers @@ -122,7 +122,7 @@ public: * @param count For each instance, the number of indexes to draw * @see `drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)` */ - virtual void drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count) override; + virtual void drawArrays(PrimitiveType primitiveType, std::size_t start, std::size_t count) override; /** * Draw primitives with an index list. @@ -133,7 +133,7 @@ public: * @see `setIndexBuffer(Buffer* buffer)` * @see `drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)` */ - virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset) override; + virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset) override; /** * Do some resources release. diff --git a/cocos/renderer/backend/metal/CommandBufferMTL.mm b/cocos/renderer/backend/metal/CommandBufferMTL.mm index 6081d7b969..6bbe598265 100644 --- a/cocos/renderer/backend/metal/CommandBufferMTL.mm +++ b/cocos/renderer/backend/metal/CommandBufferMTL.mm @@ -318,7 +318,7 @@ void CommandBufferMTL::setIndexBuffer(Buffer* buffer) [_mtlIndexBuffer retain]; } -void CommandBufferMTL::drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count) +void CommandBufferMTL::drawArrays(PrimitiveType primitiveType, std::size_t start, std::size_t count) { prepareDrawing(); [_mtlRenderEncoder drawPrimitives:toMTLPrimitive(primitiveType) @@ -326,7 +326,7 @@ void CommandBufferMTL::drawArrays(PrimitiveType primitiveType, unsigned int star vertexCount:count]; } -void CommandBufferMTL::drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset) +void CommandBufferMTL::drawElements(PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset) { prepareDrawing(); [_mtlRenderEncoder drawIndexedPrimitives:toMTLPrimitive(primitiveType) diff --git a/cocos/renderer/backend/metal/DeviceMTL.h b/cocos/renderer/backend/metal/DeviceMTL.h index 39805f2c96..89622fd7b7 100644 --- a/cocos/renderer/backend/metal/DeviceMTL.h +++ b/cocos/renderer/backend/metal/DeviceMTL.h @@ -87,7 +87,7 @@ public: * @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be BufferUsage::STATIC, BufferUsage::DYNAMIC. * @return A Buffer object. */ - virtual Buffer* newBuffer(unsigned int size, BufferType type, BufferUsage usage) override; + virtual Buffer* newBuffer(std::size_t size, BufferType type, BufferUsage usage) override; /** * New a TextureBackend object. @@ -119,6 +119,14 @@ public: */ virtual void setFrameBufferOnly(bool frameBufferOnly) override; + /** + * New a Program, not auto release. + * @param vertexShader Specifes this is a vertex shader source. + * @param fragmentShader Specifes this is a fragment shader source. + * @return A Program instance. + */ + virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) override; + /** * Get a MTLDevice object. * @return A MTLDevice object. @@ -140,14 +148,6 @@ protected: */ virtual ShaderModule* newShaderModule(ShaderStage stage, const std::string& source) override; - /** - * New a Program. - * @param vertexShader Specifes this is a vertex shader source. - * @param fragmentShader Specifes this is a fragment shader source. - * @return A Program object. - */ - virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) override; - private: static CAMetalLayer* _metalLayer; static id _currentDrawable; diff --git a/cocos/renderer/backend/metal/DeviceMTL.mm b/cocos/renderer/backend/metal/DeviceMTL.mm index 55a01b9b58..feccd94991 100644 --- a/cocos/renderer/backend/metal/DeviceMTL.mm +++ b/cocos/renderer/backend/metal/DeviceMTL.mm @@ -90,7 +90,7 @@ CommandBuffer* DeviceMTL::newCommandBuffer() return new (std::nothrow) CommandBufferMTL(this); } -Buffer* DeviceMTL::newBuffer(unsigned int size, BufferType type, BufferUsage usage) +Buffer* DeviceMTL::newBuffer(std::size_t size, BufferType type, BufferUsage usage) { return new (std::nothrow) BufferMTL(_mtlDevice, size, type, usage); } diff --git a/cocos/renderer/backend/metal/RenderPipelineMTL.mm b/cocos/renderer/backend/metal/RenderPipelineMTL.mm index 32168c8897..5306de5be0 100644 --- a/cocos/renderer/backend/metal/RenderPipelineMTL.mm +++ b/cocos/renderer/backend/metal/RenderPipelineMTL.mm @@ -135,6 +135,8 @@ namespace return MTLBlendFactorSourceAlphaSaturated; case BlendFactor::BLEND_CLOLOR: return MTLBlendFactorBlendColor; + default: + return MTLBlendFactorZero; } } @@ -147,6 +149,8 @@ namespace return MTLBlendOperationSubtract; case BlendOperation::RESERVE_SUBTRACT: return MTLBlendOperationReverseSubtract; + default: + return MTLBlendOperationAdd; } } } diff --git a/cocos/renderer/backend/metal/ShaderModuleMTL.mm b/cocos/renderer/backend/metal/ShaderModuleMTL.mm index 3537cc0b54..d0f8291a41 100644 --- a/cocos/renderer/backend/metal/ShaderModuleMTL.mm +++ b/cocos/renderer/backend/metal/ShaderModuleMTL.mm @@ -133,7 +133,7 @@ void ShaderModuleMTL::parseUniform(id mtlDevice, glslopt_shader* shad } else { - nextLocation = _uniformBufferSize; + nextLocation = static_cast(_uniformBufferSize); } glslopt_shader_get_uniform_desc(shader, i, &parName, &parType, &parPrec, &parVecSize, &parMatSize, &parArrSize, &location); diff --git a/cocos/renderer/backend/metal/TextureMTL.h b/cocos/renderer/backend/metal/TextureMTL.h index 1ed4184bf6..efadd6982b 100644 --- a/cocos/renderer/backend/metal/TextureMTL.h +++ b/cocos/renderer/backend/metal/TextureMTL.h @@ -54,7 +54,7 @@ public: * @param height Specifies the height of the texture image. * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. */ - virtual void updateData(uint8_t* data, uint32_t width , uint32_t height, uint32_t level) override; + virtual void updateData(uint8_t* data, std::size_t width , std::size_t height, std::size_t level) override; /** * Update a two-dimensional texture image in a compressed format @@ -64,7 +64,7 @@ public: * @param dataLen Specifies the totoal size of compressed image in bytes. * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. */ - virtual void updateCompressedData(uint8_t* data, uint32_t width , uint32_t height, uint32_t dataLen, uint32_t level) override; + virtual void updateCompressedData(uint8_t* data, std::size_t width , std::size_t height, std::size_t dataLen, std::size_t level) override; /** * Update a two-dimensional texture subimage @@ -75,7 +75,7 @@ public: * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. * @param data Specifies a pointer to the image data in memory. */ - virtual void updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t level, uint8_t* data) override; + virtual void updateSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t level, uint8_t* data) override; /** * Update a two-dimensional texture subimage in a compressed format @@ -87,7 +87,7 @@ public: * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. * @param data Specifies a pointer to the compressed image data in memory. */ - virtual void updateCompressedSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t dataLen, uint32_t level, uint8_t* data) override; + virtual void updateCompressedSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t dataLen, std::size_t level, uint8_t* data) override; /** * Update sampler @@ -102,7 +102,7 @@ public: * @param flipImage Specifies if needs to flip the image. * @param callback Specifies a call back function to deal with the image. */ - virtual void getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) override; + virtual void getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) override; /** * Generate mipmaps. @@ -176,7 +176,7 @@ public: * @param flipImage Specifies if needs to flip the image. * @param callback */ - virtual void getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) override; + virtual void getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) override; /** * Generate mipmaps. @@ -215,8 +215,8 @@ private: id _mtlTexture = nil; id _mtlSamplerState = nil; MTLRegion _region; - unsigned int _bytesPerImage = 0; - unsigned int _bytesPerRow = 0; + std::size_t _bytesPerImage = 0; + std::size_t _bytesPerRow = 0; }; // end of _metal group diff --git a/cocos/renderer/backend/metal/TextureMTL.mm b/cocos/renderer/backend/metal/TextureMTL.mm index 1499e3b727..e230c05f80 100644 --- a/cocos/renderer/backend/metal/TextureMTL.mm +++ b/cocos/renderer/backend/metal/TextureMTL.mm @@ -24,6 +24,7 @@ #include "TextureMTL.h" #include "Utils.h" +#include "base/ccMacros.h" CC_BACKEND_BEGIN @@ -43,7 +44,7 @@ namespace ret = MTLSamplerAddressModeClampToEdge; break; default: - assert(false); + CCASSERT(false, "Not supported sampler address mode!"); break; } return ret; @@ -65,9 +66,9 @@ namespace } } - void convertRGB2RGBA(uint8_t* src, uint8_t* dst, uint32_t length) + void convertRGB2RGBA(uint8_t* src, uint8_t* dst, std::size_t length) { - for (uint32_t i = 0; i < length; ++i) + for (std::size_t i = 0; i < length; ++i) { *dst++ = *src++; *dst++ = *src++; @@ -77,7 +78,7 @@ namespace } - bool convertData(uint8_t* src, unsigned int length, PixelFormat format, uint8_t** out) + bool convertData(uint8_t* src, std::size_t length, PixelFormat format, uint8_t** out) { *out = src; bool converted = false; @@ -114,9 +115,9 @@ namespace } } - uint32_t getBytesPerRowETC(MTLPixelFormat pixleFormat, uint32_t width) + std::size_t getBytesPerRowETC(MTLPixelFormat pixleFormat, std::size_t width) { - uint32_t bytesPerRow = 0; + std::size_t bytesPerRow = 0; #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) uint32_t bytesPerBlock = 0, blockWidth = 4; switch (pixleFormat) { @@ -130,7 +131,7 @@ namespace bytesPerBlock = 16; break; default: - assert(false); //TODO coulsonwang + CCASSERT(false, "Not supported ETC format!"); break; } auto blocksPerRow = (width + (blockWidth - 1)) / blockWidth; @@ -139,9 +140,9 @@ namespace return bytesPerRow; } - uint32_t getBytesPerRowS3TC(MTLPixelFormat pixleFormat, uint32_t width) + std::size_t getBytesPerRowS3TC(MTLPixelFormat pixleFormat, std::size_t width) { - uint32_t bytesPerRow = 0; + std::size_t bytesPerRow = 0; #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) uint32_t bytesPerBlock = 0, blockWidth = 4; switch (pixleFormat) { @@ -161,10 +162,10 @@ namespace return bytesPerRow; } - uint32_t getBytesPerRow(PixelFormat textureFormat, uint32_t width, uint32_t bitsPerElement) + std::size_t getBytesPerRow(PixelFormat textureFormat, std::size_t width, std::size_t bitsPerElement) { MTLPixelFormat pixelFormat = Utils::toMTLPixelFormat(textureFormat); - uint32_t bytesPerRow = 0; + std::size_t bytesPerRow = 0; if(textureFormat >= PixelFormat::PVRTC4 && textureFormat <= PixelFormat::PVRTC2A) @@ -219,12 +220,12 @@ void TextureMTL::updateTextureDescriptor(const cocos2d::backend::TextureDescript _bytesPerRow = descriptor.width * _bitsPerElement / 8 ; } -void TextureMTL::updateData(uint8_t* data, uint32_t width , uint32_t height, uint32_t level) +void TextureMTL::updateData(uint8_t* data, std::size_t width , std::size_t height, std::size_t level) { updateSubData(0, 0, width, height, level, data); } -void TextureMTL::updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t level, uint8_t* data) +void TextureMTL::updateSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t level, uint8_t* data) { MTLRegion region = { @@ -234,10 +235,10 @@ void TextureMTL::updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t widt uint8_t* convertedData = nullptr; bool converted = convertData(data, - (uint32_t)(width * height), + width * height, _textureFormat, &convertedData); - int bytesPerRow = getBytesPerRow(_textureFormat, width, _bitsPerElement); + std::size_t bytesPerRow = getBytesPerRow(_textureFormat, width, _bitsPerElement); [_mtlTexture replaceRegion:region mipmapLevel:level @@ -251,12 +252,12 @@ void TextureMTL::updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t widt _hasMipmaps = true; } -void TextureMTL::updateCompressedData(uint8_t *data, uint32_t width, uint32_t height, uint32_t dataLen, uint32_t level) +void TextureMTL::updateCompressedData(uint8_t *data, std::size_t width, std::size_t height, std::size_t dataLen, std::size_t level) { updateCompressedSubData(0, 0, width, height, dataLen, level, data); } -void TextureMTL::updateCompressedSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t dataLen, uint32_t level, uint8_t *data) +void TextureMTL::updateCompressedSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t dataLen, std::size_t level, uint8_t *data) { updateSubData(xoffset, yoffset, width, height, level, data); } @@ -312,7 +313,7 @@ void TextureMTL::createSampler(id mtlDevice, const SamplerDescriptor [mtlDescriptor release]; } -void TextureMTL::getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) +void TextureMTL::getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) { CC_ASSERT(width <= _width && height <= _height); @@ -446,7 +447,7 @@ void TextureCubeMTL::updateFaceData(TextureCubeFace side, void *data) bytesPerImage:_bytesPerImage]; } -void TextureCubeMTL::getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) +void TextureCubeMTL::getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) { CC_ASSERT(width <= _mtlTexture.width && height <= _mtlTexture.height); diff --git a/cocos/renderer/backend/metal/Utils.h b/cocos/renderer/backend/metal/Utils.h index 9cefc1b0f6..e4c3745943 100644 --- a/cocos/renderer/backend/metal/Utils.h +++ b/cocos/renderer/backend/metal/Utils.h @@ -49,6 +49,7 @@ public: * @param texture Specifies the texture to be setted to the color attachemnt. */ static void updateDefaultColorAttachmentTexture(id texture); + static void resizeDefaultAttachmentTexture(std::size_t width, std::size_t height); /** * Get the default combined depth and stencil attachment pixel format. @@ -88,7 +89,7 @@ public: * @param texture Specifies the texture to get the image. * @param callback Specifies a call back function to deal with the image. */ - static void getTextureBytes(int origX, int origY, int rectWidth, int rectHeight, id texture, std::function callback); + static void getTextureBytes(std::size_t origX, std::size_t origY, std::size_t rectWidth, std::size_t rectHeight, id texture, std::function callback); /** * Swizzle the iamge form the given format to MTLPixelFormatRGBA8Unorm. @@ -97,7 +98,7 @@ public: * @param heigth Specifies the height of the image. * @param format Specifies the format of the image. */ - static void swizzleImage(unsigned char* image, int width, int height, MTLPixelFormat format); + static void swizzleImage(unsigned char* image, std::size_t width, std::size_t height, MTLPixelFormat format); private: static id createDepthStencilAttachmentTexture(); diff --git a/cocos/renderer/backend/metal/Utils.mm b/cocos/renderer/backend/metal/Utils.mm index a35b9191ea..0974d4f330 100644 --- a/cocos/renderer/backend/metal/Utils.mm +++ b/cocos/renderer/backend/metal/Utils.mm @@ -152,6 +152,13 @@ MTLPixelFormat Utils::toMTLPixelFormat(PixelFormat textureFormat) } } +void Utils::resizeDefaultAttachmentTexture(std::size_t width, std::size_t height) +{ + [backend::DeviceMTL::getCAMetalLayer() setDrawableSize:CGSizeMake(width, height)]; + [_defaultDepthStencilAttachmentTexture release]; + _defaultDepthStencilAttachmentTexture = Utils::createDepthStencilAttachmentTexture(); +} + id Utils::createDepthStencilAttachmentTexture() { auto CAMetalLayer = DeviceMTL::getCAMetalLayer(); @@ -177,7 +184,7 @@ void Utils::generateMipmaps(id texture) [commandBuffer commit]; } -void Utils::swizzleImage(unsigned char *image, int width, int height, MTLPixelFormat format) +void Utils::swizzleImage(unsigned char *image, std::size_t width, std::size_t height, MTLPixelFormat format) { if(!image) return; @@ -199,7 +206,7 @@ void Utils::swizzleImage(unsigned char *image, int width, int height, MTLPixelFo } } -void Utils::getTextureBytes(int origX, int origY, int rectWidth, int rectHeight, id texture, std::function callback) +void Utils::getTextureBytes(std::size_t origX, std::size_t origY, std::size_t rectWidth, std::size_t rectHeight, id texture, std::function callback) { NSUInteger texWidth = texture.width; NSUInteger texHeight = texture.height; diff --git a/cocos/renderer/backend/opengl/BufferGL.cpp b/cocos/renderer/backend/opengl/BufferGL.cpp index 74a88f74ca..31f9242a64 100644 --- a/cocos/renderer/backend/opengl/BufferGL.cpp +++ b/cocos/renderer/backend/opengl/BufferGL.cpp @@ -46,7 +46,7 @@ namespace { } } -BufferGL::BufferGL(unsigned int size, BufferType type, BufferUsage usage) +BufferGL::BufferGL(std::size_t size, BufferType type, BufferUsage usage) : Buffer(size, type, usage) { glGenBuffers(1, &_buffer); @@ -89,7 +89,7 @@ void BufferGL::reloadBuffer() updateData(_data, _bufferAllocated); } -void BufferGL::fillBuffer(void* data, unsigned int offset, unsigned int size) +void BufferGL::fillBuffer(void* data, std::size_t offset, std::size_t size) { if(_bufferAlreadyFilled || !_needDefaultStoredData || BufferUsage::STATIC != _usage) return; @@ -104,7 +104,7 @@ void BufferGL::fillBuffer(void* data, unsigned int offset, unsigned int size) } #endif -void BufferGL::updateData(void* data, unsigned int size) +void BufferGL::updateData(void* data, std::size_t size) { assert(size && size <= _size); @@ -129,7 +129,7 @@ void BufferGL::updateData(void* data, unsigned int size) } } -void BufferGL::updateSubData(void* data, unsigned int offset, unsigned int size) +void BufferGL::updateSubData(void* data, std::size_t offset, std::size_t size) { CCASSERT(_bufferAllocated != 0, "updateData should be invoke before updateSubData"); diff --git a/cocos/renderer/backend/opengl/BufferGL.h b/cocos/renderer/backend/opengl/BufferGL.h index 16f1e0721f..d094dc6f18 100644 --- a/cocos/renderer/backend/opengl/BufferGL.h +++ b/cocos/renderer/backend/opengl/BufferGL.h @@ -47,7 +47,7 @@ public: * @param type Specifies the target buffer object. The symbolic constant must be BufferType::VERTEX or BufferType::INDEX. * @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be BufferUsage::STATIC, BufferUsage::DYNAMIC. */ - BufferGL(unsigned int size, BufferType type, BufferUsage usage); + BufferGL(std::size_t size, BufferType type, BufferUsage usage); ~BufferGL(); /** @@ -56,7 +56,7 @@ public: * @param size Specifies the size in bytes of the data store region being replaced. * @see `updateSubData(void* data, unsigned int offset, unsigned int size)` */ - virtual void updateData(void* data, unsigned int size) override; + virtual void updateData(void* data, std::size_t size) override; /** * @brief Update buffer sub-region data @@ -65,7 +65,7 @@ public: * @param size Specifies the size in bytes of the data store region being replaced. * @see `updateData(void* data, unsigned int size)` */ - virtual void updateSubData(void* data, unsigned int offset, unsigned int size) override; + virtual void updateSubData(void* data, std::size_t offset, std::size_t size) override; /** * Static buffer data will automatically stored when it comes to foreground. @@ -83,14 +83,14 @@ public: private: #if CC_ENABLE_CACHE_TEXTURE_DATA void reloadBuffer(); - void fillBuffer(void* data, unsigned int offset, unsigned int size); + void fillBuffer(void* data, std::size_t offset, std::size_t size); bool _bufferAlreadyFilled = false; EventListenerCustom* _backToForegroundListener = nullptr; #endif GLuint _buffer = 0; - unsigned int _bufferAllocated = 0; + std::size_t _bufferAllocated = 0; char* _data = nullptr; bool _needDefaultStoredData = true; }; diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index fb34916c90..721a653272 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -337,7 +337,7 @@ void CommandBufferGL::setProgramState(ProgramState* programState) _programState = programState; } -void CommandBufferGL::drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count) +void CommandBufferGL::drawArrays(PrimitiveType primitiveType, std::size_t start, std::size_t count) { prepareDrawing(); glDrawArrays(UtilsGL::toGLPrimitiveType(primitiveType), start, count); @@ -345,7 +345,7 @@ void CommandBufferGL::drawArrays(PrimitiveType primitiveType, unsigned int start cleanResources(); } -void CommandBufferGL::drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset) +void CommandBufferGL::drawElements(PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset) { prepareDrawing(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer->getHandler()); diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.h b/cocos/renderer/backend/opengl/CommandBufferGL.h index fc6bcadb12..eb7dff7e70 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.h +++ b/cocos/renderer/backend/opengl/CommandBufferGL.h @@ -120,7 +120,7 @@ public: * @param count For each instance, the number of indexes to draw * @see `drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)` */ - virtual void drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count) override; + virtual void drawArrays(PrimitiveType primitiveType, std::size_t start, std::size_t count) override; /** * Draw primitives with an index list. @@ -131,7 +131,7 @@ public: * @see `setIndexBuffer(Buffer* buffer)` * @see `drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)` */ - virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset) override; + virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset) override; /** * Do some resources release. diff --git a/cocos/renderer/backend/opengl/DeviceGL.cpp b/cocos/renderer/backend/opengl/DeviceGL.cpp index 5fa719ea19..f4f2ede1e7 100644 --- a/cocos/renderer/backend/opengl/DeviceGL.cpp +++ b/cocos/renderer/backend/opengl/DeviceGL.cpp @@ -64,7 +64,7 @@ CommandBuffer* DeviceGL::newCommandBuffer() return new (std::nothrow) CommandBufferGL(); } -Buffer* DeviceGL::newBuffer(unsigned int size, BufferType type, BufferUsage usage) +Buffer* DeviceGL::newBuffer(std::size_t size, BufferType type, BufferUsage usage) { return new (std::nothrow) BufferGL(size, type, usage); } diff --git a/cocos/renderer/backend/opengl/DeviceGL.h b/cocos/renderer/backend/opengl/DeviceGL.h index be752ac40b..4ab0409577 100644 --- a/cocos/renderer/backend/opengl/DeviceGL.h +++ b/cocos/renderer/backend/opengl/DeviceGL.h @@ -52,7 +52,7 @@ public: * @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be BufferUsage::STATIC, BufferUsage::DYNAMIC. * @return A Buffer object. */ - virtual Buffer* newBuffer(unsigned int size, BufferType type, BufferUsage usage) override; + virtual Buffer* newBuffer(std::size_t size, BufferType type, BufferUsage usage) override; /** * New a TextureBackend object, not auto released. @@ -80,6 +80,14 @@ public: */ virtual void setFrameBufferOnly(bool frameBufferOnly) override {} + /** + * New a Program, not auto released. + * @param vertexShader Specifes this is a vertex shader source. + * @param fragmentShader Specifes this is a fragment shader source. + * @return A Program instance. + */ + virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) override; + protected: /** * New a shaderModule, not auto released. @@ -89,14 +97,6 @@ protected: */ virtual ShaderModule* newShaderModule(ShaderStage stage, const std::string& source) override; - /** - * New a Program, not auto released. - * @param vertexShader Specifes this is a vertex shader source. - * @param fragmentShader Specifes this is a fragment shader source. - * @return A Program object. - */ - virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) override; - }; //end of _opengl group /// @} diff --git a/cocos/renderer/backend/opengl/TextureGL.cpp b/cocos/renderer/backend/opengl/TextureGL.cpp index adafbc0f4f..0aef8a4808 100644 --- a/cocos/renderer/backend/opengl/TextureGL.cpp +++ b/cocos/renderer/backend/opengl/TextureGL.cpp @@ -157,7 +157,7 @@ void Texture2DGL::updateSamplerDescriptor(const SamplerDescriptor &sampler) { } } -void Texture2DGL::updateData(uint8_t* data, uint32_t width , uint32_t height, uint32_t level) +void Texture2DGL::updateData(uint8_t* data, std::size_t width , std::size_t height, std::size_t level) { //Set the row align only when mipmapsNum == 1 and the data is uncompressed auto mipmapEnalbed = isMipmapEnabled(_textureInfo.minFilterGL) || isMipmapEnabled(_textureInfo.magFilterGL); @@ -210,8 +210,8 @@ void Texture2DGL::updateData(uint8_t* data, uint32_t width , uint32_t height, ui _hasMipmaps = true; } -void Texture2DGL::updateCompressedData(uint8_t *data, uint32_t width, uint32_t height, - uint32_t dataLen, uint32_t level) +void Texture2DGL::updateCompressedData(uint8_t *data, std::size_t width, std::size_t height, + std::size_t dataLen, std::size_t level) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -237,7 +237,7 @@ void Texture2DGL::updateCompressedData(uint8_t *data, uint32_t width, uint32_t h _hasMipmaps = true; } -void Texture2DGL::updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t level, uint8_t* data) +void Texture2DGL::updateSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t level, uint8_t* data) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, _textureInfo.texture); @@ -257,8 +257,8 @@ void Texture2DGL::updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t wid _hasMipmaps = true; } -void Texture2DGL::updateCompressedSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, - uint32_t height, uint32_t dataLen, uint32_t level, +void Texture2DGL::updateCompressedSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, + std::size_t height, std::size_t dataLen, std::size_t level, uint8_t *data) { glActiveTexture(GL_TEXTURE0); @@ -298,7 +298,7 @@ void Texture2DGL::generateMipmaps() } } -void Texture2DGL::getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) +void Texture2DGL::getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) { GLint defaultFBO = 0; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); @@ -418,7 +418,7 @@ void TextureCubeGL::updateFaceData(TextureCubeFace side, void *data) glBindTexture(GL_TEXTURE_CUBE_MAP, 0); } -void TextureCubeGL::getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) +void TextureCubeGL::getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) { GLint defaultFBO = 0; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); diff --git a/cocos/renderer/backend/opengl/TextureGL.h b/cocos/renderer/backend/opengl/TextureGL.h index b5fd2e8753..98fc93a0ac 100644 --- a/cocos/renderer/backend/opengl/TextureGL.h +++ b/cocos/renderer/backend/opengl/TextureGL.h @@ -74,7 +74,7 @@ public: * @param height Specifies the height of the texture image. * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. */ - virtual void updateData(uint8_t* data, uint32_t width , uint32_t height, uint32_t level) override; + virtual void updateData(uint8_t* data, std::size_t width , std::size_t height, std::size_t level) override; /** * Update a two-dimensional texture image in a compressed format @@ -84,7 +84,7 @@ public: * @param dataLen Specifies the totoal size of compressed image in bytes. * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. */ - virtual void updateCompressedData(uint8_t* data, uint32_t width , uint32_t height, uint32_t dataLen, uint32_t level) override; + virtual void updateCompressedData(uint8_t* data, std::size_t width , std::size_t height, std::size_t dataLen, std::size_t level) override; /** * Update a two-dimensional texture subimage @@ -95,7 +95,7 @@ public: * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. * @param data Specifies a pointer to the image data in memory. */ - virtual void updateSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t level, uint8_t* data) override; + virtual void updateSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t level, uint8_t* data) override; /** * Update a two-dimensional texture subimage in a compressed format @@ -107,7 +107,7 @@ public: * @param level Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. * @param data Specifies a pointer to the compressed image data in memory. */ - virtual void updateCompressedSubData(uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, uint32_t dataLen, uint32_t level, uint8_t* data) override; + virtual void updateCompressedSubData(std::size_t xoffset, std::size_t yoffset, std::size_t width, std::size_t height, std::size_t dataLen, std::size_t level, uint8_t* data) override; /** * Update sampler @@ -122,7 +122,7 @@ public: * @param flipImage Specifies if needs to flip the image. * @param callback Specifies a call back function to deal with the image. */ - virtual void getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) override; + virtual void getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) override; /** * Generate mipmaps. @@ -150,7 +150,6 @@ public: private: void initWithZeros(); - SamplerDescriptor _samplerDescriptor; TextureInfoGL _textureInfo; EventListener* _backToForegroundListener = nullptr; }; @@ -187,7 +186,7 @@ public: * @param flipImage Specifies if needs to flip the image. * @param callback */ - virtual void getBytes(int x, int y, int width, int height, bool flipImage, std::function callback) override; + virtual void getBytes(std::size_t x, std::size_t y, std::size_t width, std::size_t height, bool flipImage, std::function callback) override; /// Generate mipmaps. virtual void generateMipmaps() override; diff --git a/cocos/renderer/shaders/3D_positionTexture.vert b/cocos/renderer/shaders/3D_positionTexture.vert index 3fccd38e17..15c5fb569c 100644 --- a/cocos/renderer/shaders/3D_positionTexture.vert +++ b/cocos/renderer/shaders/3D_positionTexture.vert @@ -48,10 +48,9 @@ attribute vec4 a_blendIndex; attribute vec2 a_texCoord; -// TODO minggo: currently can not declare variable outside function. -//const int SKINNING_JOINT_COUNT = 60; +const int SKINNING_JOINT_COUNT = 60; // Uniforms -uniform vec4 u_matrixPalette[60 * 3]; +uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3]; uniform mat4 u_MVPMatrix; // Varyings diff --git a/cocos/scripting/deprecated/CCDeprecated.h b/cocos/scripting/deprecated/CCDeprecated.h index 8d9a982030..b7bc73cd01 100644 --- a/cocos/scripting/deprecated/CCDeprecated.h +++ b/cocos/scripting/deprecated/CCDeprecated.h @@ -467,7 +467,7 @@ CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGRAY; CC_DEPRECATED_ATTRIBUTE extern const BlendFunc kCCBlendFuncDisable; -CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b) +CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(uint8_t r, uint8_t g, uint8_t b) { return Color3B(r, g, b); } @@ -478,7 +478,7 @@ CC_DEPRECATED_ATTRIBUTE static inline bool ccc3BEqual(const Color3B &col1, const } CC_DEPRECATED_ATTRIBUTE static inline Color4B -ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o) +ccc4(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t o) { return Color4B(r, g, b, o); } @@ -489,7 +489,7 @@ CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4FFromccc3B(Color3B c) } CC_DEPRECATED_ATTRIBUTE static inline Color4F -ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a) +ccc4f(const float r, const float g, const float b, const float a) { return Color4F(r, g, b, a); } @@ -501,7 +501,7 @@ CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4FFromccc4B(Color4B c) CC_DEPRECATED_ATTRIBUTE static inline Color4B ccc4BFromccc4F(Color4F c) { - return Color4B((GLubyte)(c.r*255), (GLubyte)(c.g*255), (GLubyte)(c.b*255), (GLubyte)(c.a*255)); + return Color4B((uint8_t)(c.r*255), (uint8_t)(c.g*255), (uint8_t)(c.b*255), (uint8_t)(c.a*255)); } CC_DEPRECATED_ATTRIBUTE static inline bool ccc4FEqual(Color4F a, Color4F b) @@ -1003,9 +1003,9 @@ CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawQuadBezier(const Vec2& origin, const V CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); -CC_DEPRECATED_ATTRIBUTE void CC_DLL ccPointSize( GLfloat pointSize ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4B( uint8_t r, uint8_t g, uint8_t b, uint8_t a ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4F( float r, float g, float b, float a ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccPointSize( float pointSize ); CC_DEPRECATED_ATTRIBUTE typedef Data CCData; CC_DEPRECATED_ATTRIBUTE typedef __Set CCSet; diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index 61100d6db0..ff22348108 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -30,7 +30,6 @@ set(lua_bindings_manual_headers manual/cocostudio/lua-cocos-studio-conversions.h manual/cocostudio/CustomGUIReader.h manual/ui/lua_cocos2dx_ui_manual.hpp - manual/ui/lua_cocos2dx_experimental_video_manual.hpp manual/controller/lua_cocos2dx_controller_manual.hpp ) @@ -46,7 +45,6 @@ set(lua_bindings_manual_files manual/CCComponentLua.cpp manual/cocos2d/LuaScriptHandlerMgr.cpp manual/cocos2d/lua_cocos2dx_deprecated.cpp - manual/cocos2d/lua_cocos2dx_experimental_manual.cpp manual/cocos2d/lua_cocos2dx_manual.cpp manual/cocos2d/lua_cocos2dx_physics_manual.cpp manual/3d/lua_cocos2dx_3d_manual.cpp @@ -63,7 +61,6 @@ set(lua_bindings_manual_files manual/network/lua_downloader.cpp #manual/spine/lua_cocos2dx_spine_manual.cpp manual/spine/LuaSkeletonAnimation.cpp - manual/ui/lua_cocos2dx_experimental_video_manual.cpp manual/ui/lua_cocos2dx_ui_manual.cpp manual/audioengine/lua_cocos2dx_audioengine_manual.cpp manual/physics3d/lua_cocos2dx_physics3d_manual.cpp @@ -76,13 +73,10 @@ set(lua_bindings_auto_headers auto/lua_cocos2dx_3d_auto.hpp auto/lua_cocos2dx_controller_auto.hpp auto/lua_cocos2dx_spine_auto.hpp - auto/lua_cocos2dx_experimental_webview_auto.hpp auto/lua_cocos2dx_studio_auto.hpp auto/lua_cocos2dx_auto.hpp - auto/lua_cocos2dx_experimental_video_auto.hpp auto/lua_cocos2dx_navmesh_auto.hpp auto/lua_cocos2dx_csloader_auto.hpp - auto/lua_cocos2dx_experimental_auto.hpp auto/lua_cocos2dx_physics3d_auto.hpp auto/lua_cocos2dx_ui_auto.hpp auto/lua_cocos2dx_physics_auto.hpp @@ -94,8 +88,6 @@ set(lua_bindings_auto_files auto/lua_cocos2dx_3d_auto.cpp auto/lua_cocos2dx_auto.cpp auto/lua_cocos2dx_controller_auto.cpp - auto/lua_cocos2dx_experimental_auto.cpp - auto/lua_cocos2dx_experimental_video_auto.cpp auto/lua_cocos2dx_extension_auto.cpp auto/lua_cocos2dx_physics_auto.cpp #auto/lua_cocos2dx_spine_auto.cpp @@ -121,25 +113,33 @@ if(APPLE) if(IOS) set(lua_bindings_manual_headers ${lua_bindings_manual_headers} - auto/lua_cocos2dx_experimental_webview_auto.hpp - manual/ui/lua_cocos2dx_experimental_webview_manual.hpp + manual/ui/lua_cocos2dx_webview_manual.hpp + auto/lua_cocos2dx_webview_auto.hpp + auto/lua_cocos2dx_video_auto.hpp + manual/ui/lua_cocos2dx_video_manual.hpp ) set(lua_bindings_manual_files ${lua_bindings_manual_files} - auto/lua_cocos2dx_experimental_webview_auto.cpp - manual/ui/lua_cocos2dx_experimental_webview_manual.cpp + manual/ui/lua_cocos2dx_webview_manual.cpp + auto/lua_cocos2dx_webview_auto.cpp + manual/ui/lua_cocos2dx_video_manual.cpp + auto/lua_cocos2dx_video_auto.cpp ) endif() elseif(ANDROID) set(lua_bindings_manual_headers ${lua_bindings_manual_headers} - auto/lua_cocos2dx_experimental_webview_auto.hpp - manual/ui/lua_cocos2dx_experimental_webview_manual.hpp + manual/ui/lua_cocos2dx_webview_manual.hpp + auto/lua_cocos2dx_webview_auto.hpp + auto/lua_cocos2dx_video_auto.hpp + manual/ui/lua_cocos2dx_video_manual.hpp ) set(lua_bindings_manual_files ${lua_bindings_manual_files} - auto/lua_cocos2dx_experimental_webview_auto.cpp - manual/ui/lua_cocos2dx_experimental_webview_manual.cpp + manual/ui/lua_cocos2dx_webview_manual.cpp + auto/lua_cocos2dx_webview_auto.cpp + manual/ui/lua_cocos2dx_video_manual.cpp + auto/lua_cocos2dx_video_auto.cpp ) endif() diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.cpp index da3260f4f6..5e68b6204f 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.cpp @@ -7,7 +7,7 @@ int lua_cocos2dx_audioengine_AudioProfile_constructor(lua_State* tolua_S) { int argc = 0; - cocos2d::experimental::AudioProfile* cobj = nullptr; + cocos2d::AudioProfile* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -24,12 +24,12 @@ int lua_cocos2dx_audioengine_AudioProfile_constructor(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioProfile_constructor'", nullptr); return 0; } - cobj = new cocos2d::experimental::AudioProfile(); - tolua_pushusertype(tolua_S,(void*)cobj,"ccexp.AudioProfile"); + cobj = new cocos2d::AudioProfile(); + tolua_pushusertype(tolua_S,(void*)cobj,"cc.AudioProfile"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.AudioProfile:AudioProfile",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AudioProfile:AudioProfile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -47,15 +47,15 @@ static int lua_cocos2dx_audioengine_AudioProfile_finalize(lua_State* tolua_S) int lua_register_cocos2dx_audioengine_AudioProfile(lua_State* tolua_S) { - tolua_usertype(tolua_S,"ccexp.AudioProfile"); - tolua_cclass(tolua_S,"AudioProfile","ccexp.AudioProfile","",nullptr); + tolua_usertype(tolua_S,"cc.AudioProfile"); + tolua_cclass(tolua_S,"AudioProfile","cc.AudioProfile","",nullptr); tolua_beginmodule(tolua_S,"AudioProfile"); tolua_function(tolua_S,"new",lua_cocos2dx_audioengine_AudioProfile_constructor); tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::AudioProfile).name(); - g_luaType[typeName] = "ccexp.AudioProfile"; - g_typeCast["AudioProfile"] = "ccexp.AudioProfile"; + std::string typeName = typeid(cocos2d::AudioProfile).name(); + g_luaType[typeName] = "cc.AudioProfile"; + g_typeCast["AudioProfile"] = "cc.AudioProfile"; return 1; } @@ -69,7 +69,7 @@ int lua_cocos2dx_audioengine_AudioEngine_lazyInit(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -81,11 +81,11 @@ int lua_cocos2dx_audioengine_AudioEngine_lazyInit(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_lazyInit'", nullptr); return 0; } - bool ret = cocos2d::experimental::AudioEngine::lazyInit(); + bool ret = cocos2d::AudioEngine::lazyInit(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:lazyInit",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:lazyInit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -103,7 +103,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setCurrentTime(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -112,18 +112,18 @@ int lua_cocos2dx_audioengine_AudioEngine_setCurrentTime(lua_State* tolua_S) { int arg0; double arg1; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:setCurrentTime"); - ok &= luaval_to_number(tolua_S, 3,&arg1, "ccexp.AudioEngine:setCurrentTime"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:setCurrentTime"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.AudioEngine:setCurrentTime"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_setCurrentTime'", nullptr); return 0; } - bool ret = cocos2d::experimental::AudioEngine::setCurrentTime(arg0, arg1); + bool ret = cocos2d::AudioEngine::setCurrentTime(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:setCurrentTime",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setCurrentTime",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -141,7 +141,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getVolume(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -149,17 +149,17 @@ int lua_cocos2dx_audioengine_AudioEngine_getVolume(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:getVolume"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:getVolume"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getVolume'", nullptr); return 0; } - double ret = cocos2d::experimental::AudioEngine::getVolume(arg0); + double ret = cocos2d::AudioEngine::getVolume(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getVolume",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getVolume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -177,7 +177,7 @@ int lua_cocos2dx_audioengine_AudioEngine_uncache(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -185,17 +185,17 @@ int lua_cocos2dx_audioengine_AudioEngine_uncache(lua_State* tolua_S) if (argc == 1) { std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:uncache"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:uncache"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_uncache'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::uncache(arg0); + cocos2d::AudioEngine::uncache(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:uncache",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:uncache",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -213,7 +213,7 @@ int lua_cocos2dx_audioengine_AudioEngine_resumeAll(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -225,11 +225,11 @@ int lua_cocos2dx_audioengine_AudioEngine_resumeAll(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_resumeAll'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::resumeAll(); + cocos2d::AudioEngine::resumeAll(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:resumeAll",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:resumeAll",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -247,7 +247,7 @@ int lua_cocos2dx_audioengine_AudioEngine_stopAll(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -259,11 +259,11 @@ int lua_cocos2dx_audioengine_AudioEngine_stopAll(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_stopAll'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::stopAll(); + cocos2d::AudioEngine::stopAll(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:stopAll",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:stopAll",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -281,7 +281,7 @@ int lua_cocos2dx_audioengine_AudioEngine_pause(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -289,17 +289,17 @@ int lua_cocos2dx_audioengine_AudioEngine_pause(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:pause"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:pause"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_pause'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::pause(arg0); + cocos2d::AudioEngine::pause(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:pause",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:pause",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -317,7 +317,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getMaxAudioInstance(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -329,11 +329,11 @@ int lua_cocos2dx_audioengine_AudioEngine_getMaxAudioInstance(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getMaxAudioInstance'", nullptr); return 0; } - int ret = cocos2d::experimental::AudioEngine::getMaxAudioInstance(); + int ret = cocos2d::AudioEngine::getMaxAudioInstance(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getMaxAudioInstance",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getMaxAudioInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -351,7 +351,7 @@ int lua_cocos2dx_audioengine_AudioEngine_isEnabled(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -363,11 +363,11 @@ int lua_cocos2dx_audioengine_AudioEngine_isEnabled(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_isEnabled'", nullptr); return 0; } - bool ret = cocos2d::experimental::AudioEngine::isEnabled(); + bool ret = cocos2d::AudioEngine::isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:isEnabled",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -385,7 +385,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getCurrentTime(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -393,17 +393,17 @@ int lua_cocos2dx_audioengine_AudioEngine_getCurrentTime(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:getCurrentTime"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:getCurrentTime"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getCurrentTime'", nullptr); return 0; } - double ret = cocos2d::experimental::AudioEngine::getCurrentTime(arg0); + double ret = cocos2d::AudioEngine::getCurrentTime(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getCurrentTime",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getCurrentTime",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -421,7 +421,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setMaxAudioInstance(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -429,17 +429,17 @@ int lua_cocos2dx_audioengine_AudioEngine_setMaxAudioInstance(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:setMaxAudioInstance"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:setMaxAudioInstance"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_setMaxAudioInstance'", nullptr); return 0; } - bool ret = cocos2d::experimental::AudioEngine::setMaxAudioInstance(arg0); + bool ret = cocos2d::AudioEngine::setMaxAudioInstance(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:setMaxAudioInstance",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setMaxAudioInstance",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -457,7 +457,7 @@ int lua_cocos2dx_audioengine_AudioEngine_isLoop(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -465,17 +465,17 @@ int lua_cocos2dx_audioengine_AudioEngine_isLoop(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:isLoop"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:isLoop"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_isLoop'", nullptr); return 0; } - bool ret = cocos2d::experimental::AudioEngine::isLoop(arg0); + bool ret = cocos2d::AudioEngine::isLoop(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:isLoop",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:isLoop",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -493,7 +493,7 @@ int lua_cocos2dx_audioengine_AudioEngine_pauseAll(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -505,11 +505,11 @@ int lua_cocos2dx_audioengine_AudioEngine_pauseAll(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_pauseAll'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::pauseAll(); + cocos2d::AudioEngine::pauseAll(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:pauseAll",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:pauseAll",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -527,7 +527,7 @@ int lua_cocos2dx_audioengine_AudioEngine_uncacheAll(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -539,11 +539,11 @@ int lua_cocos2dx_audioengine_AudioEngine_uncacheAll(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_uncacheAll'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::uncacheAll(); + cocos2d::AudioEngine::uncacheAll(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:uncacheAll",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:uncacheAll",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -561,7 +561,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setVolume(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -570,18 +570,18 @@ int lua_cocos2dx_audioengine_AudioEngine_setVolume(lua_State* tolua_S) { int arg0; double arg1; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:setVolume"); - ok &= luaval_to_number(tolua_S, 3,&arg1, "ccexp.AudioEngine:setVolume"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:setVolume"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.AudioEngine:setVolume"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_setVolume'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::setVolume(arg0, arg1); + cocos2d::AudioEngine::setVolume(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:setVolume",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setVolume",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -598,7 +598,7 @@ int lua_cocos2dx_audioengine_AudioEngine_preload(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; @@ -608,7 +608,7 @@ int lua_cocos2dx_audioengine_AudioEngine_preload(lua_State* tolua_S) if (argc == 2) { std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:preload"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:preload"); if (!ok) { break; } std::function arg1; do { @@ -617,7 +617,7 @@ int lua_cocos2dx_audioengine_AudioEngine_preload(lua_State* tolua_S) } while(0) ; if (!ok) { break; } - cocos2d::experimental::AudioEngine::preload(arg0, arg1); + cocos2d::AudioEngine::preload(arg0, arg1); lua_settop(tolua_S, 1); return 1; } @@ -628,15 +628,15 @@ int lua_cocos2dx_audioengine_AudioEngine_preload(lua_State* tolua_S) if (argc == 1) { std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:preload"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:preload"); if (!ok) { break; } - cocos2d::experimental::AudioEngine::preload(arg0); + cocos2d::AudioEngine::preload(arg0); lua_settop(tolua_S, 1); return 1; } } while (0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "ccexp.AudioEngine:preload",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.AudioEngine:preload",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -654,7 +654,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setEnabled(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -662,17 +662,17 @@ int lua_cocos2dx_audioengine_AudioEngine_setEnabled(lua_State* tolua_S) if (argc == 1) { bool arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.AudioEngine:setEnabled"); + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.AudioEngine:setEnabled"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_setEnabled'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::setEnabled(arg0); + cocos2d::AudioEngine::setEnabled(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:setEnabled",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -690,7 +690,7 @@ int lua_cocos2dx_audioengine_AudioEngine_play2d(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -698,13 +698,13 @@ int lua_cocos2dx_audioengine_AudioEngine_play2d(lua_State* tolua_S) if (argc == 1) { std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:play2d"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:play2d"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_play2d'", nullptr); return 0; } - int ret = cocos2d::experimental::AudioEngine::play2d(arg0); + int ret = cocos2d::AudioEngine::play2d(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } @@ -712,14 +712,14 @@ int lua_cocos2dx_audioengine_AudioEngine_play2d(lua_State* tolua_S) { std::string arg0; bool arg1; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:play2d"); - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "ccexp.AudioEngine:play2d"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:play2d"); + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.AudioEngine:play2d"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_play2d'", nullptr); return 0; } - int ret = cocos2d::experimental::AudioEngine::play2d(arg0, arg1); + int ret = cocos2d::AudioEngine::play2d(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } @@ -728,15 +728,15 @@ int lua_cocos2dx_audioengine_AudioEngine_play2d(lua_State* tolua_S) std::string arg0; bool arg1; double arg2; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:play2d"); - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "ccexp.AudioEngine:play2d"); - ok &= luaval_to_number(tolua_S, 4,&arg2, "ccexp.AudioEngine:play2d"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:play2d"); + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.AudioEngine:play2d"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.AudioEngine:play2d"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_play2d'", nullptr); return 0; } - int ret = cocos2d::experimental::AudioEngine::play2d(arg0, arg1, arg2); + int ret = cocos2d::AudioEngine::play2d(arg0, arg1, arg2); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } @@ -745,21 +745,21 @@ int lua_cocos2dx_audioengine_AudioEngine_play2d(lua_State* tolua_S) std::string arg0; bool arg1; double arg2; - const cocos2d::experimental::AudioProfile* arg3; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:play2d"); - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "ccexp.AudioEngine:play2d"); - ok &= luaval_to_number(tolua_S, 4,&arg2, "ccexp.AudioEngine:play2d"); - ok &= luaval_to_object(tolua_S, 5, "ccexp.AudioProfile",&arg3, "ccexp.AudioEngine:play2d"); + const cocos2d::AudioProfile* arg3; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:play2d"); + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.AudioEngine:play2d"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.AudioEngine:play2d"); + ok &= luaval_to_object(tolua_S, 5, "cc.AudioProfile",&arg3, "cc.AudioEngine:play2d"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_play2d'", nullptr); return 0; } - int ret = cocos2d::experimental::AudioEngine::play2d(arg0, arg1, arg2, arg3); + int ret = cocos2d::AudioEngine::play2d(arg0, arg1, arg2, arg3); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:play2d",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:play2d",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -777,7 +777,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getState(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -785,17 +785,17 @@ int lua_cocos2dx_audioengine_AudioEngine_getState(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:getState"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:getState"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getState'", nullptr); return 0; } - int ret = (int)cocos2d::experimental::AudioEngine::getState(arg0); + int ret = (int)cocos2d::AudioEngine::getState(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getState",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -813,7 +813,7 @@ int lua_cocos2dx_audioengine_AudioEngine_resume(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -821,17 +821,17 @@ int lua_cocos2dx_audioengine_AudioEngine_resume(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:resume"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:resume"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_resume'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::resume(arg0); + cocos2d::AudioEngine::resume(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:resume",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:resume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -849,7 +849,7 @@ int lua_cocos2dx_audioengine_AudioEngine_stop(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -857,17 +857,17 @@ int lua_cocos2dx_audioengine_AudioEngine_stop(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:stop"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:stop"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_stop'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::stop(arg0); + cocos2d::AudioEngine::stop(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:stop",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:stop",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -885,7 +885,7 @@ int lua_cocos2dx_audioengine_AudioEngine_end(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -897,11 +897,11 @@ int lua_cocos2dx_audioengine_AudioEngine_end(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_end'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::end(); + cocos2d::AudioEngine::end(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:end",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -919,7 +919,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getDuration(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -927,17 +927,17 @@ int lua_cocos2dx_audioengine_AudioEngine_getDuration(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:getDuration"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:getDuration"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getDuration'", nullptr); return 0; } - double ret = cocos2d::experimental::AudioEngine::getDuration(arg0); + double ret = cocos2d::AudioEngine::getDuration(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getDuration",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getDuration",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -955,7 +955,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setLoop(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -964,18 +964,18 @@ int lua_cocos2dx_audioengine_AudioEngine_setLoop(lua_State* tolua_S) { int arg0; bool arg1; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:setLoop"); - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "ccexp.AudioEngine:setLoop"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:setLoop"); + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.AudioEngine:setLoop"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_setLoop'", nullptr); return 0; } - cocos2d::experimental::AudioEngine::setLoop(arg0, arg1); + cocos2d::AudioEngine::setLoop(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:setLoop",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setLoop",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -993,7 +993,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getDefaultProfile(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -1005,11 +1005,11 @@ int lua_cocos2dx_audioengine_AudioEngine_getDefaultProfile(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getDefaultProfile'", nullptr); return 0; } - cocos2d::experimental::AudioProfile* ret = cocos2d::experimental::AudioEngine::getDefaultProfile(); - object_to_luaval(tolua_S, "ccexp.AudioProfile",(cocos2d::experimental::AudioProfile*)ret); + cocos2d::AudioProfile* ret = cocos2d::AudioEngine::getDefaultProfile(); + object_to_luaval(tolua_S, "cc.AudioProfile",(cocos2d::AudioProfile*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getDefaultProfile",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getDefaultProfile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -1026,7 +1026,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getProfile(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; @@ -1036,10 +1036,10 @@ int lua_cocos2dx_audioengine_AudioEngine_getProfile(lua_State* tolua_S) if (argc == 1) { std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.AudioEngine:getProfile"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AudioEngine:getProfile"); if (!ok) { break; } - cocos2d::experimental::AudioProfile* ret = cocos2d::experimental::AudioEngine::getProfile(arg0); - object_to_luaval(tolua_S, "ccexp.AudioProfile",(cocos2d::experimental::AudioProfile*)ret); + cocos2d::AudioProfile* ret = cocos2d::AudioEngine::getProfile(arg0); + object_to_luaval(tolua_S, "cc.AudioProfile",(cocos2d::AudioProfile*)ret); return 1; } } while (0); @@ -1049,15 +1049,15 @@ int lua_cocos2dx_audioengine_AudioEngine_getProfile(lua_State* tolua_S) if (argc == 1) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:getProfile"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:getProfile"); if (!ok) { break; } - cocos2d::experimental::AudioProfile* ret = cocos2d::experimental::AudioEngine::getProfile(arg0); - object_to_luaval(tolua_S, "ccexp.AudioProfile",(cocos2d::experimental::AudioProfile*)ret); + cocos2d::AudioProfile* ret = cocos2d::AudioEngine::getProfile(arg0); + object_to_luaval(tolua_S, "cc.AudioProfile",(cocos2d::AudioProfile*)ret); return 1; } } while (0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "ccexp.AudioEngine:getProfile",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.AudioEngine:getProfile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -1075,7 +1075,7 @@ int lua_cocos2dx_audioengine_AudioEngine_getPlayingAudioCount(lua_State* tolua_S #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -1087,11 +1087,11 @@ int lua_cocos2dx_audioengine_AudioEngine_getPlayingAudioCount(lua_State* tolua_S tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_audioengine_AudioEngine_getPlayingAudioCount'", nullptr); return 0; } - int ret = cocos2d::experimental::AudioEngine::getPlayingAudioCount(); + int ret = cocos2d::AudioEngine::getPlayingAudioCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:getPlayingAudioCount",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:getPlayingAudioCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -1107,8 +1107,8 @@ static int lua_cocos2dx_audioengine_AudioEngine_finalize(lua_State* tolua_S) int lua_register_cocos2dx_audioengine_AudioEngine(lua_State* tolua_S) { - tolua_usertype(tolua_S,"ccexp.AudioEngine"); - tolua_cclass(tolua_S,"AudioEngine","ccexp.AudioEngine","",nullptr); + tolua_usertype(tolua_S,"cc.AudioEngine"); + tolua_cclass(tolua_S,"AudioEngine","cc.AudioEngine","",nullptr); tolua_beginmodule(tolua_S,"AudioEngine"); tolua_function(tolua_S,"lazyInit", lua_cocos2dx_audioengine_AudioEngine_lazyInit); @@ -1139,17 +1139,17 @@ int lua_register_cocos2dx_audioengine_AudioEngine(lua_State* tolua_S) tolua_function(tolua_S,"getProfile", lua_cocos2dx_audioengine_AudioEngine_getProfile); tolua_function(tolua_S,"getPlayingAudioCount", lua_cocos2dx_audioengine_AudioEngine_getPlayingAudioCount); tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::AudioEngine).name(); - g_luaType[typeName] = "ccexp.AudioEngine"; - g_typeCast["AudioEngine"] = "ccexp.AudioEngine"; + std::string typeName = typeid(cocos2d::AudioEngine).name(); + g_luaType[typeName] = "cc.AudioEngine"; + g_typeCast["AudioEngine"] = "cc.AudioEngine"; return 1; } TOLUA_API int register_all_cocos2dx_audioengine(lua_State* tolua_S) { tolua_open(tolua_S); - tolua_module(tolua_S,"ccexp",0); - tolua_beginmodule(tolua_S,"ccexp"); + tolua_module(tolua_S,"cc",0); + tolua_beginmodule(tolua_S,"cc"); lua_register_cocos2dx_audioengine_AudioProfile(tolua_S); lua_register_cocos2dx_audioengine_AudioEngine(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 6a05ff6ea6..8d9d9e4457 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -2603,6 +2603,23 @@ int lua_cocos2dx_Texture2D_initWithBackendTexture(lua_State* tolua_S) tolua_pushboolean(tolua_S,(bool)ret); return 1; } + if (argc == 2) + { + cocos2d::backend::TextureBackend* arg0; + bool arg1; + + ok &= luaval_to_object(tolua_S, 2, "ccb.TextureBackend",&arg0, "cc.Texture2D:initWithBackendTexture"); + + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Texture2D:initWithBackendTexture"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Texture2D_initWithBackendTexture'", nullptr); + return 0; + } + bool ret = cobj->initWithBackendTexture(arg0, arg1); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Texture2D:initWithBackendTexture",argc, 1); return 0; @@ -103064,6 +103081,1869 @@ int lua_register_cocos2dx_TileMapAtlas(lua_State* tolua_S) return 1; } +int lua_cocos2dx_FastTMXLayer_getPositionAt(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getPositionAt'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "cc.FastTMXLayer:getPositionAt"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getPositionAt'", nullptr); + return 0; + } + cocos2d::Vec2 ret = cobj->getPositionAt(arg0); + vec2_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getPositionAt",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getPositionAt'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setLayerOrientation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setLayerOrientation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.FastTMXLayer:setLayerOrientation"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setLayerOrientation'", nullptr); + return 0; + } + cobj->setLayerOrientation(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setLayerOrientation",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setLayerOrientation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getLayerSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getLayerSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getLayerSize'", nullptr); + return 0; + } + const cocos2d::Size& ret = cobj->getLayerSize(); + size_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getLayerSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getLayerSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setMapTileSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setMapTileSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Size arg0; + + ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.FastTMXLayer:setMapTileSize"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setMapTileSize'", nullptr); + return 0; + } + cobj->setMapTileSize(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setMapTileSize",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setMapTileSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getLayerOrientation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getLayerOrientation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getLayerOrientation'", nullptr); + return 0; + } + int ret = cobj->getLayerOrientation(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getLayerOrientation",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getLayerOrientation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setProperties(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setProperties'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ValueMap arg0; + + ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "cc.FastTMXLayer:setProperties"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setProperties'", nullptr); + return 0; + } + cobj->setProperties(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setProperties",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setProperties'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setLayerName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setLayerName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXLayer:setLayerName"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setLayerName'", nullptr); + return 0; + } + cobj->setLayerName(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setLayerName",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setLayerName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_removeTileAt(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_removeTileAt'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "cc.FastTMXLayer:removeTileAt"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_removeTileAt'", nullptr); + return 0; + } + cobj->removeTileAt(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:removeTileAt",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_removeTileAt'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getProperties(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getProperties'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getProperties(); + ccvaluemap_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + const cocos2d::ValueMap& ret = cobj->getProperties(); + ccvaluemap_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getProperties",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getProperties'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setupTiles(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setupTiles'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setupTiles'", nullptr); + return 0; + } + cobj->setupTiles(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setupTiles",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setupTiles'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setupTileSprite(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setupTileSprite'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + cocos2d::Sprite* arg0; + cocos2d::Vec2 arg1; + unsigned int arg2; + + ok &= luaval_to_object(tolua_S, 2, "cc.Sprite",&arg0, "cc.FastTMXLayer:setupTileSprite"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.FastTMXLayer:setupTileSprite"); + + ok &= luaval_to_uint32(tolua_S, 4,&arg2, "cc.FastTMXLayer:setupTileSprite"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setupTileSprite'", nullptr); + return 0; + } + cobj->setupTileSprite(arg0, arg1, arg2); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setupTileSprite",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setupTileSprite'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setTileGID(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setTileGID'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 3) { + int arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.FastTMXLayer:setTileGID"); + + if (!ok) { break; } + cocos2d::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.FastTMXLayer:setTileGID"); + + if (!ok) { break; } + cocos2d::TMXTileFlags_ arg2; + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "cc.FastTMXLayer:setTileGID"); + + if (!ok) { break; } + cobj->setTileGID(arg0, arg1, arg2); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 2) { + int arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.FastTMXLayer:setTileGID"); + + if (!ok) { break; } + cocos2d::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.FastTMXLayer:setTileGID"); + + if (!ok) { break; } + cobj->setTileGID(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setTileGID",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setTileGID'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getMapTileSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getMapTileSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getMapTileSize'", nullptr); + return 0; + } + const cocos2d::Size& ret = cobj->getMapTileSize(); + size_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getMapTileSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getMapTileSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getProperty(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getProperty'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXLayer:getProperty"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getProperty'", nullptr); + return 0; + } + cocos2d::Value ret = cobj->getProperty(arg0); + ccvalue_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getProperty",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getProperty'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setLayerSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setLayerSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Size arg0; + + ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.FastTMXLayer:setLayerSize"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setLayerSize'", nullptr); + return 0; + } + cobj->setLayerSize(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setLayerSize",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setLayerSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getLayerName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getLayerName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getLayerName'", nullptr); + return 0; + } + const std::string& ret = cobj->getLayerName(); + lua_pushlstring(tolua_S,ret.c_str(),ret.length()); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getLayerName",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getLayerName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_setTileSet(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_setTileSet'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::TMXTilesetInfo* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.TMXTilesetInfo",&arg0, "cc.FastTMXLayer:setTileSet"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_setTileSet'", nullptr); + return 0; + } + cobj->setTileSet(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:setTileSet",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_setTileSet'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getTileSet(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getTileSet'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getTileSet'", nullptr); + return 0; + } + cocos2d::TMXTilesetInfo* ret = cobj->getTileSet(); + object_to_luaval(tolua_S, "cc.TMXTilesetInfo",(cocos2d::TMXTilesetInfo*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getTileSet",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getTileSet'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_getTileAt(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getTileAt'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "cc.FastTMXLayer:getTileAt"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_getTileAt'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getTileAt(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getTileAt",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getTileAt'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXLayer_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 3) + { + cocos2d::TMXTilesetInfo* arg0; + cocos2d::TMXLayerInfo* arg1; + cocos2d::TMXMapInfo* arg2; + ok &= luaval_to_object(tolua_S, 2, "cc.TMXTilesetInfo",&arg0, "cc.FastTMXLayer:create"); + ok &= luaval_to_object(tolua_S, 3, "cc.TMXLayerInfo",&arg1, "cc.FastTMXLayer:create"); + ok &= luaval_to_object(tolua_S, 4, "cc.TMXMapInfo",&arg2, "cc.FastTMXLayer:create"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_create'", nullptr); + return 0; + } + cocos2d::FastTMXLayer* ret = cocos2d::FastTMXLayer::create(arg0, arg1, arg2); + object_to_luaval(tolua_S, "cc.FastTMXLayer",(cocos2d::FastTMXLayer*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.FastTMXLayer:create",argc, 3); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_FastTMXLayer_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXLayer_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::FastTMXLayer(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.FastTMXLayer"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:FastTMXLayer",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_FastTMXLayer_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (FastTMXLayer)"); + return 0; +} + +int lua_register_cocos2dx_FastTMXLayer(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.FastTMXLayer"); + tolua_cclass(tolua_S,"FastTMXLayer","cc.FastTMXLayer","cc.Node",nullptr); + + tolua_beginmodule(tolua_S,"FastTMXLayer"); + tolua_function(tolua_S,"new",lua_cocos2dx_FastTMXLayer_constructor); + tolua_function(tolua_S,"getPositionAt",lua_cocos2dx_FastTMXLayer_getPositionAt); + tolua_function(tolua_S,"setLayerOrientation",lua_cocos2dx_FastTMXLayer_setLayerOrientation); + tolua_function(tolua_S,"getLayerSize",lua_cocos2dx_FastTMXLayer_getLayerSize); + tolua_function(tolua_S,"setMapTileSize",lua_cocos2dx_FastTMXLayer_setMapTileSize); + tolua_function(tolua_S,"getLayerOrientation",lua_cocos2dx_FastTMXLayer_getLayerOrientation); + tolua_function(tolua_S,"setProperties",lua_cocos2dx_FastTMXLayer_setProperties); + tolua_function(tolua_S,"setLayerName",lua_cocos2dx_FastTMXLayer_setLayerName); + tolua_function(tolua_S,"removeTileAt",lua_cocos2dx_FastTMXLayer_removeTileAt); + tolua_function(tolua_S,"getProperties",lua_cocos2dx_FastTMXLayer_getProperties); + tolua_function(tolua_S,"setupTiles",lua_cocos2dx_FastTMXLayer_setupTiles); + tolua_function(tolua_S,"setupTileSprite",lua_cocos2dx_FastTMXLayer_setupTileSprite); + tolua_function(tolua_S,"setTileGID",lua_cocos2dx_FastTMXLayer_setTileGID); + tolua_function(tolua_S,"getMapTileSize",lua_cocos2dx_FastTMXLayer_getMapTileSize); + tolua_function(tolua_S,"getProperty",lua_cocos2dx_FastTMXLayer_getProperty); + tolua_function(tolua_S,"setLayerSize",lua_cocos2dx_FastTMXLayer_setLayerSize); + tolua_function(tolua_S,"getLayerName",lua_cocos2dx_FastTMXLayer_getLayerName); + tolua_function(tolua_S,"setTileSet",lua_cocos2dx_FastTMXLayer_setTileSet); + tolua_function(tolua_S,"getTileSet",lua_cocos2dx_FastTMXLayer_getTileSet); + tolua_function(tolua_S,"getTileAt",lua_cocos2dx_FastTMXLayer_getTileAt); + tolua_function(tolua_S,"create", lua_cocos2dx_FastTMXLayer_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::FastTMXLayer).name(); + g_luaType[typeName] = "cc.FastTMXLayer"; + g_typeCast["FastTMXLayer"] = "cc.FastTMXLayer"; + return 1; +} + +int lua_cocos2dx_FastTMXTiledMap_setObjectGroups(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_setObjectGroups'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vector arg0; + + ok &= luaval_to_ccvector(tolua_S, 2, &arg0, "cc.FastTMXTiledMap:setObjectGroups"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_setObjectGroups'", nullptr); + return 0; + } + cobj->setObjectGroups(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:setObjectGroups",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_setObjectGroups'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getProperty(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getProperty'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXTiledMap:getProperty"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getProperty'", nullptr); + return 0; + } + cocos2d::Value ret = cobj->getProperty(arg0); + ccvalue_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getProperty",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getProperty'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_setMapSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_setMapSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Size arg0; + + ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.FastTMXTiledMap:setMapSize"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_setMapSize'", nullptr); + return 0; + } + cobj->setMapSize(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:setMapSize",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_setMapSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getObjectGroup(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getObjectGroup'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXTiledMap:getObjectGroup"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getObjectGroup'", nullptr); + return 0; + } + cocos2d::TMXObjectGroup* ret = cobj->getObjectGroup(arg0); + object_to_luaval(tolua_S, "cc.TMXObjectGroup",(cocos2d::TMXObjectGroup*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getObjectGroup",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getObjectGroup'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getObjectGroups(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getObjectGroups'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 0) { + cocos2d::Vector& ret = cobj->getObjectGroups(); + ccvector_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getObjectGroups(); + ccvector_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getObjectGroups",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getObjectGroups'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getTileSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getTileSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getTileSize'", nullptr); + return 0; + } + const cocos2d::Size& ret = cobj->getTileSize(); + size_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getTileSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getTileSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getMapSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getMapSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getMapSize'", nullptr); + return 0; + } + const cocos2d::Size& ret = cobj->getMapSize(); + size_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getMapSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getMapSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getProperties(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getProperties'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getProperties'", nullptr); + return 0; + } + const cocos2d::ValueMap& ret = cobj->getProperties(); + ccvaluemap_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getProperties",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getProperties'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getPropertiesForGID(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getPropertiesForGID'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.FastTMXTiledMap:getPropertiesForGID"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getPropertiesForGID'", nullptr); + return 0; + } + cocos2d::Value ret = cobj->getPropertiesForGID(arg0); + ccvalue_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getPropertiesForGID",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getPropertiesForGID'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_setTileSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_setTileSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Size arg0; + + ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.FastTMXTiledMap:setTileSize"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_setTileSize'", nullptr); + return 0; + } + cobj->setTileSize(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:setTileSize",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_setTileSize'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_setProperties(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_setProperties'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ValueMap arg0; + + ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "cc.FastTMXTiledMap:setProperties"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_setProperties'", nullptr); + return 0; + } + cobj->setProperties(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:setProperties",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_setProperties'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getLayer(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getLayer'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXTiledMap:getLayer"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getLayer'", nullptr); + return 0; + } + cocos2d::FastTMXLayer* ret = cobj->getLayer(arg0); + object_to_luaval(tolua_S, "cc.FastTMXLayer",(cocos2d::FastTMXLayer*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getLayer",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getLayer'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_getMapOrientation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_getMapOrientation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_getMapOrientation'", nullptr); + return 0; + } + int ret = cobj->getMapOrientation(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:getMapOrientation",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_getMapOrientation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_setMapOrientation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXTiledMap* 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.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXTiledMap*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXTiledMap_setMapOrientation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.FastTMXTiledMap:setMapOrientation"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_setMapOrientation'", nullptr); + return 0; + } + cobj->setMapOrientation(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXTiledMap:setMapOrientation",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_setMapOrientation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXTiledMap:create"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_create'", nullptr); + return 0; + } + cocos2d::FastTMXTiledMap* ret = cocos2d::FastTMXTiledMap::create(arg0); + object_to_luaval(tolua_S, "cc.FastTMXTiledMap",(cocos2d::FastTMXTiledMap*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.FastTMXTiledMap:create",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_FastTMXTiledMap_createWithXML(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.FastTMXTiledMap",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + std::string arg0; + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.FastTMXTiledMap:createWithXML"); + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.FastTMXTiledMap:createWithXML"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_FastTMXTiledMap_createWithXML'", nullptr); + return 0; + } + cocos2d::FastTMXTiledMap* ret = cocos2d::FastTMXTiledMap::createWithXML(arg0, arg1); + object_to_luaval(tolua_S, "cc.FastTMXTiledMap",(cocos2d::FastTMXTiledMap*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.FastTMXTiledMap:createWithXML",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXTiledMap_createWithXML'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_FastTMXTiledMap_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (FastTMXTiledMap)"); + return 0; +} + +int lua_register_cocos2dx_FastTMXTiledMap(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.FastTMXTiledMap"); + tolua_cclass(tolua_S,"FastTMXTiledMap","cc.FastTMXTiledMap","cc.Node",nullptr); + + tolua_beginmodule(tolua_S,"FastTMXTiledMap"); + tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_FastTMXTiledMap_setObjectGroups); + tolua_function(tolua_S,"getProperty",lua_cocos2dx_FastTMXTiledMap_getProperty); + tolua_function(tolua_S,"setMapSize",lua_cocos2dx_FastTMXTiledMap_setMapSize); + tolua_function(tolua_S,"getObjectGroup",lua_cocos2dx_FastTMXTiledMap_getObjectGroup); + tolua_function(tolua_S,"getObjectGroups",lua_cocos2dx_FastTMXTiledMap_getObjectGroups); + tolua_function(tolua_S,"getTileSize",lua_cocos2dx_FastTMXTiledMap_getTileSize); + tolua_function(tolua_S,"getMapSize",lua_cocos2dx_FastTMXTiledMap_getMapSize); + tolua_function(tolua_S,"getProperties",lua_cocos2dx_FastTMXTiledMap_getProperties); + tolua_function(tolua_S,"getPropertiesForGID",lua_cocos2dx_FastTMXTiledMap_getPropertiesForGID); + tolua_function(tolua_S,"setTileSize",lua_cocos2dx_FastTMXTiledMap_setTileSize); + tolua_function(tolua_S,"setProperties",lua_cocos2dx_FastTMXTiledMap_setProperties); + tolua_function(tolua_S,"getLayer",lua_cocos2dx_FastTMXTiledMap_getLayer); + tolua_function(tolua_S,"getMapOrientation",lua_cocos2dx_FastTMXTiledMap_getMapOrientation); + tolua_function(tolua_S,"setMapOrientation",lua_cocos2dx_FastTMXTiledMap_setMapOrientation); + tolua_function(tolua_S,"create", lua_cocos2dx_FastTMXTiledMap_create); + tolua_function(tolua_S,"createWithXML", lua_cocos2dx_FastTMXTiledMap_createWithXML); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::FastTMXTiledMap).name(); + g_luaType[typeName] = "cc.FastTMXTiledMap"; + g_typeCast["FastTMXTiledMap"] = "cc.FastTMXTiledMap"; + return 1; +} + int lua_cocos2dx_MotionStreak3D_reset(lua_State* tolua_S) { int argc = 0; @@ -104228,6 +106108,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_EaseBounceIn(tolua_S); lua_register_cocos2dx_Camera(tolua_S); lua_register_cocos2dx_TMXObjectGroup(tolua_S); + lua_register_cocos2dx_FastTMXTiledMap(tolua_S); lua_register_cocos2dx_ParticleGalaxy(tolua_S); lua_register_cocos2dx_Twirl(tolua_S); lua_register_cocos2dx_MenuItemLabel(tolua_S); @@ -104261,6 +106142,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_SpriteFrame(tolua_S); lua_register_cocos2dx_Liquid(tolua_S); lua_register_cocos2dx_UserDefault(tolua_S); + lua_register_cocos2dx_FastTMXLayer(tolua_S); lua_register_cocos2dx_TransitionZoomFlipX(tolua_S); lua_register_cocos2dx_EventFocus(tolua_S); lua_register_cocos2dx_TransitionFade(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index e377d2ed2c..3e1cc6c6fe 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2273,6 +2273,45 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.cpp index a0ecf4def2..f8f2c29006 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.cpp @@ -3,6 +3,7 @@ #include "renderer/backend/ProgramState.h" #include "renderer/backend/Texture.h" #include "renderer/backend/VertexLayout.h" +#include "renderer/backend/Device.h" #include "scripting/lua-bindings/manual/tolua_fix.h" #include "scripting/lua-bindings/manual/LuaBasicConversions.h" @@ -856,6 +857,42 @@ int lua_cocos2dx_backend_Program_getVertexShader(lua_State* tolua_S) return 0; } +int lua_cocos2dx_backend_Program_getBuiltinProgram(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccb.Program",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::backend::ProgramType arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccb.Program:getBuiltinProgram"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_backend_Program_getBuiltinProgram'", nullptr); + return 0; + } + cocos2d::backend::Program* ret = cocos2d::backend::Program::getBuiltinProgram(arg0); + object_to_luaval(tolua_S, "ccb.Program",(cocos2d::backend::Program*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccb.Program:getBuiltinProgram",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_backend_Program_getBuiltinProgram'.",&tolua_err); +#endif + return 0; +} static int lua_cocos2dx_backend_Program_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Program)"); @@ -878,6 +915,7 @@ int lua_register_cocos2dx_backend_Program(lua_State* tolua_S) tolua_function(tolua_S,"getActiveAttributes",lua_cocos2dx_backend_Program_getActiveAttributes); tolua_function(tolua_S,"getAttributeLocation",lua_cocos2dx_backend_Program_getAttributeLocation); tolua_function(tolua_S,"getVertexShader",lua_cocos2dx_backend_Program_getVertexShader); + tolua_function(tolua_S,"getBuiltinProgram", lua_cocos2dx_backend_Program_getBuiltinProgram); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::backend::Program).name(); g_luaType[typeName] = "ccb.Program"; @@ -1461,46 +1499,32 @@ int lua_cocos2dx_backend_ProgramState_constructor(lua_State* tolua_S) int argc = 0; cocos2d::backend::ProgramState* cobj = nullptr; bool ok = true; + #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif + + argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 1) { - cocos2d::backend::ProgramType arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccb.ProgramState:ProgramState"); + if (argc == 1) + { + cocos2d::backend::Program* arg0; - if (!ok) { break; } - cobj = new cocos2d::backend::ProgramState(arg0); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccb.ProgramState"); - return 1; + ok &= luaval_to_object(tolua_S, 2, "ccb.Program",&arg0, "ccb.ProgramState:ProgramState"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_backend_ProgramState_constructor'", nullptr); + return 0; } - }while(0); - ok = true; - do{ - if (argc == 2) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccb.ProgramState:ProgramState"); - - if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccb.ProgramState:ProgramState"); - - if (!ok) { break; } - cobj = new cocos2d::backend::ProgramState(arg0, arg1); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccb.ProgramState"); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccb.ProgramState:ProgramState",argc, 2); + cobj = new cocos2d::backend::ProgramState(arg0); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccb.ProgramState"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccb.ProgramState:ProgramState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1899,20 +1923,20 @@ int lua_cocos2dx_backend_TextureBackend_getBytes(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 6) { - int arg0; - int arg1; - int arg2; - int arg3; + unsigned int arg0; + unsigned int arg1; + unsigned int arg2; + unsigned int arg3; bool arg4; - std::function arg5; + std::function arg5; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccb.TextureBackend:getBytes"); + ok &= luaval_to_uint32(tolua_S, 2,&arg0, "ccb.TextureBackend:getBytes"); - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccb.TextureBackend:getBytes"); + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "ccb.TextureBackend:getBytes"); - ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "ccb.TextureBackend:getBytes"); + ok &= luaval_to_uint32(tolua_S, 4,&arg2, "ccb.TextureBackend:getBytes"); - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "ccb.TextureBackend:getBytes"); + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ccb.TextureBackend:getBytes"); ok &= luaval_to_boolean(tolua_S, 6,&arg4, "ccb.TextureBackend:getBytes"); @@ -2417,6 +2441,114 @@ int lua_register_cocos2dx_backend_TextureCubemapBackend(lua_State* tolua_S) g_typeCast["TextureCubemapBackend"] = "ccb.TextureCubemapBackend"; return 1; } + +int lua_cocos2dx_backend_Device_newProgram(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::backend::Device* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccb.Device",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::backend::Device*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_backend_Device_newProgram'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + std::string arg0; + std::string arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccb.Device:newProgram"); + + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccb.Device:newProgram"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_backend_Device_newProgram'", nullptr); + return 0; + } + cocos2d::backend::Program* ret = cobj->newProgram(arg0, arg1); + object_to_luaval(tolua_S, "ccb.Program",(cocos2d::backend::Program*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccb.Device:newProgram",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_backend_Device_newProgram'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_backend_Device_getInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccb.Device",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_backend_Device_getInstance'", nullptr); + return 0; + } + cocos2d::backend::Device* ret = cocos2d::backend::Device::getInstance(); + object_to_luaval(tolua_S, "ccb.Device",(cocos2d::backend::Device*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccb.Device:getInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_backend_Device_getInstance'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_backend_Device_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Device)"); + return 0; +} + +int lua_register_cocos2dx_backend_Device(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"ccb.Device"); + tolua_cclass(tolua_S,"Device","ccb.Device","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"Device"); + tolua_function(tolua_S,"newProgram",lua_cocos2dx_backend_Device_newProgram); + tolua_function(tolua_S,"getInstance", lua_cocos2dx_backend_Device_getInstance); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::backend::Device).name(); + g_luaType[typeName] = "ccb.Device"; + g_typeCast["Device"] = "ccb.Device"; + return 1; +} TOLUA_API int register_all_cocos2dx_backend(lua_State* tolua_S) { tolua_open(tolua_S); @@ -2436,6 +2568,7 @@ TOLUA_API int register_all_cocos2dx_backend(lua_State* tolua_S) lua_register_cocos2dx_backend_TextureCubeFace(tolua_S); lua_register_cocos2dx_backend_VertexLayout(tolua_S); lua_register_cocos2dx_backend_BlendFactor(tolua_S); + lua_register_cocos2dx_backend_Device(tolua_S); lua_register_cocos2dx_backend_VertexFormat(tolua_S); lua_register_cocos2dx_backend_VertexStepMode(tolua_S); lua_register_cocos2dx_backend_StencilOperation(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.hpp index 2f17382371..d022b93be1 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.hpp @@ -50,6 +50,10 @@ int register_all_cocos2dx_backend(lua_State* tolua_S); + + + + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp deleted file mode 100644 index a50523af58..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp +++ /dev/null @@ -1,1882 +0,0 @@ -#include "scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp" -#include "2d/CCFastTMXLayer.h" -#include "2d/CCFastTMXTiledMap.h" -#include "scripting/lua-bindings/manual/tolua_fix.h" -#include "scripting/lua-bindings/manual/LuaBasicConversions.h" - -int lua_cocos2dx_experimental_TMXLayer_getPositionAt(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getPositionAt'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec2 arg0; - - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:getPositionAt"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getPositionAt'", nullptr); - return 0; - } - cocos2d::Vec2 ret = cobj->getPositionAt(arg0); - vec2_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getPositionAt",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getPositionAt'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setLayerOrientation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setLayerOrientation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.TMXLayer:setLayerOrientation"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setLayerOrientation'", nullptr); - return 0; - } - cobj->setLayerOrientation(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setLayerOrientation",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setLayerOrientation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getLayerSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getLayerSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getLayerSize'", nullptr); - return 0; - } - const cocos2d::Size& ret = cobj->getLayerSize(); - size_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getLayerSize",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getLayerSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setMapTileSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setMapTileSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Size arg0; - - ok &= luaval_to_size(tolua_S, 2, &arg0, "ccexp.TMXLayer:setMapTileSize"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setMapTileSize'", nullptr); - return 0; - } - cobj->setMapTileSize(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setMapTileSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setMapTileSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getLayerOrientation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getLayerOrientation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getLayerOrientation'", nullptr); - return 0; - } - int ret = cobj->getLayerOrientation(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getLayerOrientation",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getLayerOrientation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setProperties(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setProperties'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::ValueMap arg0; - - ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "ccexp.TMXLayer:setProperties"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setProperties'", nullptr); - return 0; - } - cobj->setProperties(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setProperties",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setProperties'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setLayerName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setLayerName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXLayer:setLayerName"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setLayerName'", nullptr); - return 0; - } - cobj->setLayerName(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setLayerName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setLayerName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_removeTileAt(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_removeTileAt'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec2 arg0; - - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:removeTileAt"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_removeTileAt'", nullptr); - return 0; - } - cobj->removeTileAt(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:removeTileAt",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_removeTileAt'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getProperties(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getProperties'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 0) { - cocos2d::ValueMap& ret = cobj->getProperties(); - ccvaluemap_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 0) { - const cocos2d::ValueMap& ret = cobj->getProperties(); - ccvaluemap_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getProperties",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getProperties'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setupTiles(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setupTiles'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setupTiles'", nullptr); - return 0; - } - cobj->setupTiles(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setupTiles",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setupTiles'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setupTileSprite(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setupTileSprite'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - cocos2d::Sprite* arg0; - cocos2d::Vec2 arg1; - unsigned int arg2; - - ok &= luaval_to_object(tolua_S, 2, "cc.Sprite",&arg0, "ccexp.TMXLayer:setupTileSprite"); - - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ccexp.TMXLayer:setupTileSprite"); - - ok &= luaval_to_uint32(tolua_S, 4,&arg2, "ccexp.TMXLayer:setupTileSprite"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setupTileSprite'", nullptr); - return 0; - } - cobj->setupTileSprite(arg0, arg1, arg2); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setupTileSprite",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setupTileSprite'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setTileGID(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setTileGID'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 3) { - int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.TMXLayer:setTileGID"); - - if (!ok) { break; } - cocos2d::Vec2 arg1; - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ccexp.TMXLayer:setTileGID"); - - if (!ok) { break; } - cocos2d::TMXTileFlags_ arg2; - ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "ccexp.TMXLayer:setTileGID"); - - if (!ok) { break; } - cobj->setTileGID(arg0, arg1, arg2); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.TMXLayer:setTileGID"); - - if (!ok) { break; } - cocos2d::Vec2 arg1; - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ccexp.TMXLayer:setTileGID"); - - if (!ok) { break; } - cobj->setTileGID(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setTileGID",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setTileGID'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getMapTileSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getMapTileSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getMapTileSize'", nullptr); - return 0; - } - const cocos2d::Size& ret = cobj->getMapTileSize(); - size_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getMapTileSize",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getMapTileSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getProperty(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getProperty'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXLayer:getProperty"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getProperty'", nullptr); - return 0; - } - cocos2d::Value ret = cobj->getProperty(arg0); - ccvalue_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getProperty",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getProperty'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setLayerSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setLayerSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Size arg0; - - ok &= luaval_to_size(tolua_S, 2, &arg0, "ccexp.TMXLayer:setLayerSize"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setLayerSize'", nullptr); - return 0; - } - cobj->setLayerSize(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setLayerSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setLayerSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getLayerName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getLayerName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getLayerName'", nullptr); - return 0; - } - const std::string& ret = cobj->getLayerName(); - lua_pushlstring(tolua_S,ret.c_str(),ret.length()); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getLayerName",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getLayerName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_setTileSet(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_setTileSet'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::TMXTilesetInfo* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.TMXTilesetInfo",&arg0, "ccexp.TMXLayer:setTileSet"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_setTileSet'", nullptr); - return 0; - } - cobj->setTileSet(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:setTileSet",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_setTileSet'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getTileSet(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getTileSet'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getTileSet'", nullptr); - return 0; - } - cocos2d::TMXTilesetInfo* ret = cobj->getTileSet(); - object_to_luaval(tolua_S, "cc.TMXTilesetInfo",(cocos2d::TMXTilesetInfo*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getTileSet",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getTileSet'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_getTileAt(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getTileAt'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec2 arg0; - - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:getTileAt"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_getTileAt'", nullptr); - return 0; - } - cocos2d::Sprite* ret = cobj->getTileAt(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getTileAt",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getTileAt'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 3) - { - cocos2d::TMXTilesetInfo* arg0; - cocos2d::TMXLayerInfo* arg1; - cocos2d::TMXMapInfo* arg2; - ok &= luaval_to_object(tolua_S, 2, "cc.TMXTilesetInfo",&arg0, "ccexp.TMXLayer:create"); - ok &= luaval_to_object(tolua_S, 3, "cc.TMXLayerInfo",&arg1, "ccexp.TMXLayer:create"); - ok &= luaval_to_object(tolua_S, 4, "cc.TMXMapInfo",&arg2, "ccexp.TMXLayer:create"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_create'", nullptr); - return 0; - } - cocos2d::experimental::TMXLayer* ret = cocos2d::experimental::TMXLayer::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "ccexp.TMXLayer",(cocos2d::experimental::TMXLayer*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.TMXLayer:create",argc, 3); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_experimental_TMXLayer_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXLayer_constructor'", nullptr); - return 0; - } - cobj = new cocos2d::experimental::TMXLayer(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccexp.TMXLayer"); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:TMXLayer",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_experimental_TMXLayer_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (TMXLayer)"); - return 0; -} - -int lua_register_cocos2dx_experimental_TMXLayer(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"ccexp.TMXLayer"); - tolua_cclass(tolua_S,"TMXLayer","ccexp.TMXLayer","cc.Node",nullptr); - - tolua_beginmodule(tolua_S,"TMXLayer"); - tolua_function(tolua_S,"new",lua_cocos2dx_experimental_TMXLayer_constructor); - tolua_function(tolua_S,"getPositionAt",lua_cocos2dx_experimental_TMXLayer_getPositionAt); - tolua_function(tolua_S,"setLayerOrientation",lua_cocos2dx_experimental_TMXLayer_setLayerOrientation); - tolua_function(tolua_S,"getLayerSize",lua_cocos2dx_experimental_TMXLayer_getLayerSize); - tolua_function(tolua_S,"setMapTileSize",lua_cocos2dx_experimental_TMXLayer_setMapTileSize); - tolua_function(tolua_S,"getLayerOrientation",lua_cocos2dx_experimental_TMXLayer_getLayerOrientation); - tolua_function(tolua_S,"setProperties",lua_cocos2dx_experimental_TMXLayer_setProperties); - tolua_function(tolua_S,"setLayerName",lua_cocos2dx_experimental_TMXLayer_setLayerName); - tolua_function(tolua_S,"removeTileAt",lua_cocos2dx_experimental_TMXLayer_removeTileAt); - tolua_function(tolua_S,"getProperties",lua_cocos2dx_experimental_TMXLayer_getProperties); - tolua_function(tolua_S,"setupTiles",lua_cocos2dx_experimental_TMXLayer_setupTiles); - tolua_function(tolua_S,"setupTileSprite",lua_cocos2dx_experimental_TMXLayer_setupTileSprite); - tolua_function(tolua_S,"setTileGID",lua_cocos2dx_experimental_TMXLayer_setTileGID); - tolua_function(tolua_S,"getMapTileSize",lua_cocos2dx_experimental_TMXLayer_getMapTileSize); - tolua_function(tolua_S,"getProperty",lua_cocos2dx_experimental_TMXLayer_getProperty); - tolua_function(tolua_S,"setLayerSize",lua_cocos2dx_experimental_TMXLayer_setLayerSize); - tolua_function(tolua_S,"getLayerName",lua_cocos2dx_experimental_TMXLayer_getLayerName); - tolua_function(tolua_S,"setTileSet",lua_cocos2dx_experimental_TMXLayer_setTileSet); - tolua_function(tolua_S,"getTileSet",lua_cocos2dx_experimental_TMXLayer_getTileSet); - tolua_function(tolua_S,"getTileAt",lua_cocos2dx_experimental_TMXLayer_getTileAt); - tolua_function(tolua_S,"create", lua_cocos2dx_experimental_TMXLayer_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::TMXLayer).name(); - g_luaType[typeName] = "ccexp.TMXLayer"; - g_typeCast["TMXLayer"] = "ccexp.TMXLayer"; - return 1; -} - -int lua_cocos2dx_experimental_TMXTiledMap_setObjectGroups(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_setObjectGroups'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vector arg0; - - ok &= luaval_to_ccvector(tolua_S, 2, &arg0, "ccexp.TMXTiledMap:setObjectGroups"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_setObjectGroups'", nullptr); - return 0; - } - cobj->setObjectGroups(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:setObjectGroups",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_setObjectGroups'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getProperty(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getProperty'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXTiledMap:getProperty"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getProperty'", nullptr); - return 0; - } - cocos2d::Value ret = cobj->getProperty(arg0); - ccvalue_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getProperty",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getProperty'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_setMapSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_setMapSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Size arg0; - - ok &= luaval_to_size(tolua_S, 2, &arg0, "ccexp.TMXTiledMap:setMapSize"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_setMapSize'", nullptr); - return 0; - } - cobj->setMapSize(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:setMapSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_setMapSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getObjectGroup(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getObjectGroup'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXTiledMap:getObjectGroup"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getObjectGroup'", nullptr); - return 0; - } - cocos2d::TMXObjectGroup* ret = cobj->getObjectGroup(arg0); - object_to_luaval(tolua_S, "cc.TMXObjectGroup",(cocos2d::TMXObjectGroup*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getObjectGroup",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getObjectGroup'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getObjectGroups(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getObjectGroups'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 0) { - cocos2d::Vector& ret = cobj->getObjectGroups(); - ccvector_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 0) { - const cocos2d::Vector& ret = cobj->getObjectGroups(); - ccvector_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getObjectGroups",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getObjectGroups'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getTileSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getTileSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getTileSize'", nullptr); - return 0; - } - const cocos2d::Size& ret = cobj->getTileSize(); - size_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getTileSize",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getTileSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getMapSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getMapSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getMapSize'", nullptr); - return 0; - } - const cocos2d::Size& ret = cobj->getMapSize(); - size_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getMapSize",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getMapSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getProperties(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getProperties'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getProperties'", nullptr); - return 0; - } - const cocos2d::ValueMap& ret = cobj->getProperties(); - ccvaluemap_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getProperties",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getProperties'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getPropertiesForGID(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getPropertiesForGID'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.TMXTiledMap:getPropertiesForGID"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getPropertiesForGID'", nullptr); - return 0; - } - cocos2d::Value ret = cobj->getPropertiesForGID(arg0); - ccvalue_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getPropertiesForGID",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getPropertiesForGID'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_setTileSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_setTileSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Size arg0; - - ok &= luaval_to_size(tolua_S, 2, &arg0, "ccexp.TMXTiledMap:setTileSize"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_setTileSize'", nullptr); - return 0; - } - cobj->setTileSize(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:setTileSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_setTileSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_setProperties(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_setProperties'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::ValueMap arg0; - - ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "ccexp.TMXTiledMap:setProperties"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_setProperties'", nullptr); - return 0; - } - cobj->setProperties(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:setProperties",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_setProperties'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getLayer(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getLayer'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXTiledMap:getLayer"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getLayer'", nullptr); - return 0; - } - cocos2d::experimental::TMXLayer* ret = cobj->getLayer(arg0); - object_to_luaval(tolua_S, "ccexp.TMXLayer",(cocos2d::experimental::TMXLayer*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getLayer",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getLayer'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_getMapOrientation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_getMapOrientation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_getMapOrientation'", nullptr); - return 0; - } - int ret = cobj->getMapOrientation(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:getMapOrientation",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_getMapOrientation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_setMapOrientation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXTiledMap* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXTiledMap_setMapOrientation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.TMXTiledMap:setMapOrientation"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_setMapOrientation'", nullptr); - return 0; - } - cobj->setMapOrientation(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXTiledMap:setMapOrientation",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_setMapOrientation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXTiledMap:create"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_create'", nullptr); - return 0; - } - cocos2d::experimental::TMXTiledMap* ret = cocos2d::experimental::TMXTiledMap::create(arg0); - object_to_luaval(tolua_S, "ccexp.TMXTiledMap",(cocos2d::experimental::TMXTiledMap*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.TMXTiledMap:create",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_experimental_TMXTiledMap_createWithXML(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 2) - { - std::string arg0; - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.TMXTiledMap:createWithXML"); - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccexp.TMXTiledMap:createWithXML"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_TMXTiledMap_createWithXML'", nullptr); - return 0; - } - cocos2d::experimental::TMXTiledMap* ret = cocos2d::experimental::TMXTiledMap::createWithXML(arg0, arg1); - object_to_luaval(tolua_S, "ccexp.TMXTiledMap",(cocos2d::experimental::TMXTiledMap*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.TMXTiledMap:createWithXML",argc, 2); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXTiledMap_createWithXML'.",&tolua_err); -#endif - return 0; -} -static int lua_cocos2dx_experimental_TMXTiledMap_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (TMXTiledMap)"); - return 0; -} - -int lua_register_cocos2dx_experimental_TMXTiledMap(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"ccexp.TMXTiledMap"); - tolua_cclass(tolua_S,"TMXTiledMap","ccexp.TMXTiledMap","cc.Node",nullptr); - - tolua_beginmodule(tolua_S,"TMXTiledMap"); - tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_experimental_TMXTiledMap_setObjectGroups); - tolua_function(tolua_S,"getProperty",lua_cocos2dx_experimental_TMXTiledMap_getProperty); - tolua_function(tolua_S,"setMapSize",lua_cocos2dx_experimental_TMXTiledMap_setMapSize); - tolua_function(tolua_S,"getObjectGroup",lua_cocos2dx_experimental_TMXTiledMap_getObjectGroup); - tolua_function(tolua_S,"getObjectGroups",lua_cocos2dx_experimental_TMXTiledMap_getObjectGroups); - tolua_function(tolua_S,"getTileSize",lua_cocos2dx_experimental_TMXTiledMap_getTileSize); - tolua_function(tolua_S,"getMapSize",lua_cocos2dx_experimental_TMXTiledMap_getMapSize); - tolua_function(tolua_S,"getProperties",lua_cocos2dx_experimental_TMXTiledMap_getProperties); - tolua_function(tolua_S,"getPropertiesForGID",lua_cocos2dx_experimental_TMXTiledMap_getPropertiesForGID); - tolua_function(tolua_S,"setTileSize",lua_cocos2dx_experimental_TMXTiledMap_setTileSize); - tolua_function(tolua_S,"setProperties",lua_cocos2dx_experimental_TMXTiledMap_setProperties); - tolua_function(tolua_S,"getLayer",lua_cocos2dx_experimental_TMXTiledMap_getLayer); - tolua_function(tolua_S,"getMapOrientation",lua_cocos2dx_experimental_TMXTiledMap_getMapOrientation); - tolua_function(tolua_S,"setMapOrientation",lua_cocos2dx_experimental_TMXTiledMap_setMapOrientation); - tolua_function(tolua_S,"create", lua_cocos2dx_experimental_TMXTiledMap_create); - tolua_function(tolua_S,"createWithXML", lua_cocos2dx_experimental_TMXTiledMap_createWithXML); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::TMXTiledMap).name(); - g_luaType[typeName] = "ccexp.TMXTiledMap"; - g_typeCast["TMXTiledMap"] = "ccexp.TMXTiledMap"; - return 1; -} -TOLUA_API int register_all_cocos2dx_experimental(lua_State* tolua_S) -{ - tolua_open(tolua_S); - - tolua_module(tolua_S,"ccexp",0); - tolua_beginmodule(tolua_S,"ccexp"); - - lua_register_cocos2dx_experimental_TMXTiledMap(tolua_S); - lua_register_cocos2dx_experimental_TMXLayer(tolua_S); - - tolua_endmodule(tolua_S); - return 1; -} - diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp deleted file mode 100644 index 1510f395f7..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "base/ccConfig.h" -#ifndef __cocos2dx_experimental_h__ -#define __cocos2dx_experimental_h__ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -int register_all_cocos2dx_experimental(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_experimental_h__ diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp deleted file mode 100644 index 57860b5056..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp +++ /dev/null @@ -1,1002 +0,0 @@ -#include "scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#include "ui/UIVideoPlayer.h" -#include "scripting/lua-bindings/manual/tolua_fix.h" -#include "scripting/lua-bindings/manual/LuaBasicConversions.h" - -int lua_cocos2dx_experimental_video_VideoPlayer_getFileName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_getFileName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_getFileName'", nullptr); - return 0; - } - const std::string& ret = cobj->getFileName(); - lua_pushlstring(tolua_S,ret.c_str(),ret.length()); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:getFileName",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_getFileName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_getURL(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_getURL'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_getURL'", nullptr); - return 0; - } - const std::string& ret = cobj->getURL(); - lua_pushlstring(tolua_S,ret.c_str(),ret.length()); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:getURL",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_getURL'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_play(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_play'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_play'", nullptr); - return 0; - } - cobj->play(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:play",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_play'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_isUserInputEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_isUserInputEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_isUserInputEnabled'", nullptr); - return 0; - } - bool ret = cobj->isUserInputEnabled(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:isUserInputEnabled",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_isUserInputEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.VideoPlayer:setKeepAspectRatioEnabled"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled'", nullptr); - return 0; - } - cobj->setKeepAspectRatioEnabled(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setKeepAspectRatioEnabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_stop(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_stop'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_stop'", nullptr); - return 0; - } - cobj->stop(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:stop",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_stop'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.VideoPlayer:setFullScreenEnabled"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled'", nullptr); - return 0; - } - cobj->setFullScreenEnabled(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setFullScreenEnabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setFileName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setFileName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.VideoPlayer:setFileName"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setFileName'", nullptr); - return 0; - } - cobj->setFileName(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setFileName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setFileName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setURL(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setURL'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.VideoPlayer:setURL"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setURL'", nullptr); - return 0; - } - cobj->setURL(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setURL",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setURL'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setStyle(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setStyle'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::experimental::ui::VideoPlayer::StyleType arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.VideoPlayer:setStyle"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setStyle'", nullptr); - return 0; - } - cobj->setStyle(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setStyle",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setStyle'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_seekTo(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_seekTo'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "ccexp.VideoPlayer:seekTo"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_seekTo'", nullptr); - return 0; - } - cobj->seekTo(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:seekTo",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_seekTo'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled'", nullptr); - return 0; - } - bool ret = cobj->isKeepAspectRatioEnabled(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:isKeepAspectRatioEnabled",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_onPlayEvent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_onPlayEvent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.VideoPlayer:onPlayEvent"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_onPlayEvent'", nullptr); - return 0; - } - cobj->onPlayEvent(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:onPlayEvent",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_onPlayEvent'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled'", nullptr); - return 0; - } - bool ret = cobj->isFullScreenEnabled(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:isFullScreenEnabled",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_isLooping(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_isLooping'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_isLooping'", nullptr); - return 0; - } - bool ret = cobj->isLooping(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:isLooping",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_isLooping'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_isPlaying(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_isPlaying'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_isPlaying'", nullptr); - return 0; - } - bool ret = cobj->isPlaying(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:isPlaying",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_isPlaying'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setLooping(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setLooping'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.VideoPlayer:setLooping"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setLooping'", nullptr); - return 0; - } - cobj->setLooping(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setLooping",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setLooping'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_setUserInputEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_video_VideoPlayer_setUserInputEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.VideoPlayer:setUserInputEnabled"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_setUserInputEnabled'", nullptr); - return 0; - } - cobj->setUserInputEnabled(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:setUserInputEnabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_setUserInputEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_create'", nullptr); - return 0; - } - cocos2d::experimental::ui::VideoPlayer* ret = cocos2d::experimental::ui::VideoPlayer::create(); - object_to_luaval(tolua_S, "ccexp.VideoPlayer",(cocos2d::experimental::ui::VideoPlayer*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.VideoPlayer:create",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_experimental_video_VideoPlayer_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_video_VideoPlayer_constructor'", nullptr); - return 0; - } - cobj = new cocos2d::experimental::ui::VideoPlayer(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccexp.VideoPlayer"); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.VideoPlayer:VideoPlayer",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_video_VideoPlayer_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_experimental_video_VideoPlayer_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (VideoPlayer)"); - return 0; -} - -int lua_register_cocos2dx_experimental_video_VideoPlayer(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"ccexp.VideoPlayer"); - tolua_cclass(tolua_S,"VideoPlayer","ccexp.VideoPlayer","ccui.Widget",nullptr); - - tolua_beginmodule(tolua_S,"VideoPlayer"); - tolua_function(tolua_S,"new",lua_cocos2dx_experimental_video_VideoPlayer_constructor); - tolua_function(tolua_S,"getFileName",lua_cocos2dx_experimental_video_VideoPlayer_getFileName); - tolua_function(tolua_S,"getURL",lua_cocos2dx_experimental_video_VideoPlayer_getURL); - tolua_function(tolua_S,"play",lua_cocos2dx_experimental_video_VideoPlayer_play); - tolua_function(tolua_S,"isUserInputEnabled",lua_cocos2dx_experimental_video_VideoPlayer_isUserInputEnabled); - tolua_function(tolua_S,"setKeepAspectRatioEnabled",lua_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled); - tolua_function(tolua_S,"stop",lua_cocos2dx_experimental_video_VideoPlayer_stop); - tolua_function(tolua_S,"setFullScreenEnabled",lua_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled); - tolua_function(tolua_S,"setFileName",lua_cocos2dx_experimental_video_VideoPlayer_setFileName); - tolua_function(tolua_S,"setURL",lua_cocos2dx_experimental_video_VideoPlayer_setURL); - tolua_function(tolua_S,"setStyle",lua_cocos2dx_experimental_video_VideoPlayer_setStyle); - tolua_function(tolua_S,"seekTo",lua_cocos2dx_experimental_video_VideoPlayer_seekTo); - tolua_function(tolua_S,"isKeepAspectRatioEnabled",lua_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled); - tolua_function(tolua_S,"onPlayEvent",lua_cocos2dx_experimental_video_VideoPlayer_onPlayEvent); - tolua_function(tolua_S,"isFullScreenEnabled",lua_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled); - tolua_function(tolua_S,"isLooping",lua_cocos2dx_experimental_video_VideoPlayer_isLooping); - tolua_function(tolua_S,"isPlaying",lua_cocos2dx_experimental_video_VideoPlayer_isPlaying); - tolua_function(tolua_S,"setLooping",lua_cocos2dx_experimental_video_VideoPlayer_setLooping); - tolua_function(tolua_S,"setUserInputEnabled",lua_cocos2dx_experimental_video_VideoPlayer_setUserInputEnabled); - tolua_function(tolua_S,"create", lua_cocos2dx_experimental_video_VideoPlayer_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::ui::VideoPlayer).name(); - g_luaType[typeName] = "ccexp.VideoPlayer"; - g_typeCast["VideoPlayer"] = "ccexp.VideoPlayer"; - return 1; -} -TOLUA_API int register_all_cocos2dx_experimental_video(lua_State* tolua_S) -{ - tolua_open(tolua_S); - - tolua_module(tolua_S,"ccexp",0); - tolua_beginmodule(tolua_S,"ccexp"); - - lua_register_cocos2dx_experimental_video_VideoPlayer(tolua_S); - - tolua_endmodule(tolua_S); - return 1; -} - -#endif diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp deleted file mode 100644 index eb3ac2043d..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#ifndef __cocos2dx_experimental_video_h__ -#define __cocos2dx_experimental_video_h__ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -int register_all_cocos2dx_experimental_video(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_experimental_video_h__ -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.cpp deleted file mode 100644 index ea4c314ff5..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.cpp +++ /dev/null @@ -1,977 +0,0 @@ -#include "scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#include "ui/UIWebView/UIWebView.h" -#include "scripting/lua-bindings/manual/tolua_fix.h" -#include "scripting/lua-bindings/manual/LuaBasicConversions.h" - -int lua_cocos2dx_experimental_webview_WebView_setOpacityWebView(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setOpacityWebView'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "ccexp.WebView:setOpacityWebView"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setOpacityWebView'", nullptr); - return 0; - } - cobj->setOpacityWebView(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setOpacityWebView",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setOpacityWebView'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_canGoBack(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_canGoBack'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_canGoBack'", nullptr); - return 0; - } - bool ret = cobj->canGoBack(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:canGoBack",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_canGoBack'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_loadHTMLString(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadHTMLString"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'", nullptr); - return 0; - } - cobj->loadHTMLString(arg0); - lua_settop(tolua_S, 1); - return 1; - } - if (argc == 2) - { - std::string arg0; - std::string arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadHTMLString"); - - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccexp.WebView:loadHTMLString"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'", nullptr); - return 0; - } - cobj->loadHTMLString(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:loadHTMLString",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_goForward(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_goForward'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_goForward'", nullptr); - return 0; - } - cobj->goForward(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:goForward",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_goForward'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_goBack(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_goBack'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_goBack'", nullptr); - return 0; - } - cobj->goBack(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:goBack",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_goBack'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.WebView:setScalesPageToFit"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit'", nullptr); - return 0; - } - cobj->setScalesPageToFit(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setScalesPageToFit",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_loadFile(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_loadFile'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadFile'", nullptr); - return 0; - } - cobj->loadFile(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:loadFile",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_loadFile'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_loadURL(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_loadURL'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 2) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadURL"); - - if (!ok) { break; } - bool arg1; - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "ccexp.WebView:loadURL"); - - if (!ok) { break; } - cobj->loadURL(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 1) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadURL"); - - if (!ok) { break; } - cobj->loadURL(arg0); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:loadURL",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_loadURL'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_setBounces(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setBounces'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.WebView:setBounces"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setBounces'", nullptr); - return 0; - } - cobj->setBounces(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setBounces",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setBounces'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_evaluateJS(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_evaluateJS'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:evaluateJS"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_evaluateJS'", nullptr); - return 0; - } - cobj->evaluateJS(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:evaluateJS",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_evaluateJS'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_setBackgroundTransparent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setBackgroundTransparent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setBackgroundTransparent'", nullptr); - return 0; - } - cobj->setBackgroundTransparent(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setBackgroundTransparent",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setBackgroundTransparent'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_getOnJSCallback(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_getOnJSCallback'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_getOnJSCallback'", nullptr); - return 0; - } - cocos2d::experimental::ui::WebView::ccWebViewCallback ret = cobj->getOnJSCallback(); - #pragma warning NO CONVERSION FROM NATIVE FOR std::function; - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:getOnJSCallback",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_getOnJSCallback'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_canGoForward(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_canGoForward'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_canGoForward'", nullptr); - return 0; - } - bool ret = cobj->canGoForward(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:canGoForward",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_canGoForward'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_stopLoading(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_stopLoading'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_stopLoading'", nullptr); - return 0; - } - cobj->stopLoading(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:stopLoading",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_stopLoading'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_getOpacityWebView(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_getOpacityWebView'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_getOpacityWebView'", nullptr); - return 0; - } - double ret = cobj->getOpacityWebView(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:getOpacityWebView",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_getOpacityWebView'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_reload(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_reload'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_reload'", nullptr); - return 0; - } - cobj->reload(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:reload",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_reload'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:setJavascriptInterfaceScheme"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme'", nullptr); - return 0; - } - cobj->setJavascriptInterfaceScheme(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setJavascriptInterfaceScheme",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_create'", nullptr); - return 0; - } - cocos2d::experimental::ui::WebView* ret = cocos2d::experimental::ui::WebView::create(); - object_to_luaval(tolua_S, "ccexp.WebView",(cocos2d::experimental::ui::WebView*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:create",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_experimental_webview_WebView_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::ui::WebView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_constructor'", nullptr); - return 0; - } - cobj = new cocos2d::experimental::ui::WebView(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccexp.WebView"); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:WebView",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_experimental_webview_WebView_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (WebView)"); - return 0; -} - -int lua_register_cocos2dx_experimental_webview_WebView(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"ccexp.WebView"); - tolua_cclass(tolua_S,"WebView","ccexp.WebView","ccui.Widget",nullptr); - - tolua_beginmodule(tolua_S,"WebView"); - tolua_function(tolua_S,"new",lua_cocos2dx_experimental_webview_WebView_constructor); - tolua_function(tolua_S,"setOpacityWebView",lua_cocos2dx_experimental_webview_WebView_setOpacityWebView); - tolua_function(tolua_S,"canGoBack",lua_cocos2dx_experimental_webview_WebView_canGoBack); - tolua_function(tolua_S,"loadHTMLString",lua_cocos2dx_experimental_webview_WebView_loadHTMLString); - tolua_function(tolua_S,"goForward",lua_cocos2dx_experimental_webview_WebView_goForward); - tolua_function(tolua_S,"goBack",lua_cocos2dx_experimental_webview_WebView_goBack); - tolua_function(tolua_S,"setScalesPageToFit",lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit); - tolua_function(tolua_S,"loadFile",lua_cocos2dx_experimental_webview_WebView_loadFile); - tolua_function(tolua_S,"loadURL",lua_cocos2dx_experimental_webview_WebView_loadURL); - tolua_function(tolua_S,"setBounces",lua_cocos2dx_experimental_webview_WebView_setBounces); - tolua_function(tolua_S,"evaluateJS",lua_cocos2dx_experimental_webview_WebView_evaluateJS); - tolua_function(tolua_S,"setBackgroundTransparent",lua_cocos2dx_experimental_webview_WebView_setBackgroundTransparent); - tolua_function(tolua_S,"getOnJSCallback",lua_cocos2dx_experimental_webview_WebView_getOnJSCallback); - tolua_function(tolua_S,"canGoForward",lua_cocos2dx_experimental_webview_WebView_canGoForward); - tolua_function(tolua_S,"stopLoading",lua_cocos2dx_experimental_webview_WebView_stopLoading); - tolua_function(tolua_S,"getOpacityWebView",lua_cocos2dx_experimental_webview_WebView_getOpacityWebView); - tolua_function(tolua_S,"reload",lua_cocos2dx_experimental_webview_WebView_reload); - tolua_function(tolua_S,"setJavascriptInterfaceScheme",lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme); - tolua_function(tolua_S,"create", lua_cocos2dx_experimental_webview_WebView_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::ui::WebView).name(); - g_luaType[typeName] = "ccexp.WebView"; - g_typeCast["WebView"] = "ccexp.WebView"; - return 1; -} -TOLUA_API int register_all_cocos2dx_experimental_webview(lua_State* tolua_S) -{ - tolua_open(tolua_S); - - tolua_module(tolua_S,"ccexp",0); - tolua_beginmodule(tolua_S,"ccexp"); - - lua_register_cocos2dx_experimental_webview_WebView(tolua_S); - - tolua_endmodule(tolua_S); - return 1; -} - -#endif diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp deleted file mode 100644 index 3d5c1be37c..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#ifndef __cocos2dx_experimental_webview_h__ -#define __cocos2dx_experimental_webview_h__ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -int register_all_cocos2dx_experimental_webview(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_experimental_webview_h__ -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.cpp new file mode 100644 index 0000000000..6c6f9559a3 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.cpp @@ -0,0 +1,1000 @@ +#include "scripting/lua-bindings/auto/lua_cocos2dx_video_auto.hpp" +#include "ui/UIVideoPlayer.h" +#include "scripting/lua-bindings/manual/tolua_fix.h" +#include "scripting/lua-bindings/manual/LuaBasicConversions.h" + +int lua_cocos2dx_video_VideoPlayer_getFileName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_getFileName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_getFileName'", nullptr); + return 0; + } + const std::string& ret = cobj->getFileName(); + lua_pushlstring(tolua_S,ret.c_str(),ret.length()); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:getFileName",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_getFileName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_getURL(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_getURL'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_getURL'", nullptr); + return 0; + } + const std::string& ret = cobj->getURL(); + lua_pushlstring(tolua_S,ret.c_str(),ret.length()); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:getURL",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_getURL'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_play(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_play'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_play'", nullptr); + return 0; + } + cobj->play(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:play",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_play'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_isUserInputEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_isUserInputEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_isUserInputEnabled'", nullptr); + return 0; + } + bool ret = cobj->isUserInputEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:isUserInputEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_isUserInputEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setKeepAspectRatioEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setKeepAspectRatioEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.VideoPlayer:setKeepAspectRatioEnabled"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setKeepAspectRatioEnabled'", nullptr); + return 0; + } + cobj->setKeepAspectRatioEnabled(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setKeepAspectRatioEnabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setKeepAspectRatioEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_stop(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_stop'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_stop'", nullptr); + return 0; + } + cobj->stop(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:stop",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_stop'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setFullScreenEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setFullScreenEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.VideoPlayer:setFullScreenEnabled"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setFullScreenEnabled'", nullptr); + return 0; + } + cobj->setFullScreenEnabled(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setFullScreenEnabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setFullScreenEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setFileName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setFileName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.VideoPlayer:setFileName"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setFileName'", nullptr); + return 0; + } + cobj->setFileName(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setFileName",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setFileName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setURL(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setURL'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.VideoPlayer:setURL"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setURL'", nullptr); + return 0; + } + cobj->setURL(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setURL",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setURL'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setStyle(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setStyle'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ui::VideoPlayer::StyleType arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.VideoPlayer:setStyle"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setStyle'", nullptr); + return 0; + } + cobj->setStyle(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setStyle",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setStyle'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_seekTo(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_seekTo'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.VideoPlayer:seekTo"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_seekTo'", nullptr); + return 0; + } + cobj->seekTo(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:seekTo",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_seekTo'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_isKeepAspectRatioEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_isKeepAspectRatioEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_isKeepAspectRatioEnabled'", nullptr); + return 0; + } + bool ret = cobj->isKeepAspectRatioEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:isKeepAspectRatioEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_isKeepAspectRatioEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_onPlayEvent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_onPlayEvent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.VideoPlayer:onPlayEvent"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_onPlayEvent'", nullptr); + return 0; + } + cobj->onPlayEvent(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:onPlayEvent",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_onPlayEvent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_isFullScreenEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_isFullScreenEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_isFullScreenEnabled'", nullptr); + return 0; + } + bool ret = cobj->isFullScreenEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:isFullScreenEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_isFullScreenEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_isLooping(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_isLooping'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_isLooping'", nullptr); + return 0; + } + bool ret = cobj->isLooping(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:isLooping",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_isLooping'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_isPlaying(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_isPlaying'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_isPlaying'", nullptr); + return 0; + } + bool ret = cobj->isPlaying(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:isPlaying",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_isPlaying'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setLooping(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setLooping'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.VideoPlayer:setLooping"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setLooping'", nullptr); + return 0; + } + cobj->setLooping(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setLooping",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setLooping'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_setUserInputEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::VideoPlayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_video_VideoPlayer_setUserInputEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.VideoPlayer:setUserInputEnabled"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_setUserInputEnabled'", nullptr); + return 0; + } + cobj->setUserInputEnabled(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:setUserInputEnabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_setUserInputEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_video_VideoPlayer_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_create'", nullptr); + return 0; + } + cocos2d::ui::VideoPlayer* ret = cocos2d::ui::VideoPlayer::create(); + object_to_luaval(tolua_S, "ccui.VideoPlayer",(cocos2d::ui::VideoPlayer*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.VideoPlayer:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_video_VideoPlayer_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::VideoPlayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_video_VideoPlayer_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::ui::VideoPlayer(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.VideoPlayer"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.VideoPlayer:VideoPlayer",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_video_VideoPlayer_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_video_VideoPlayer_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (VideoPlayer)"); + return 0; +} + +int lua_register_cocos2dx_video_VideoPlayer(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"ccui.VideoPlayer"); + tolua_cclass(tolua_S,"VideoPlayer","ccui.VideoPlayer","ccui.Widget",nullptr); + + tolua_beginmodule(tolua_S,"VideoPlayer"); + tolua_function(tolua_S,"new",lua_cocos2dx_video_VideoPlayer_constructor); + tolua_function(tolua_S,"getFileName",lua_cocos2dx_video_VideoPlayer_getFileName); + tolua_function(tolua_S,"getURL",lua_cocos2dx_video_VideoPlayer_getURL); + tolua_function(tolua_S,"play",lua_cocos2dx_video_VideoPlayer_play); + tolua_function(tolua_S,"isUserInputEnabled",lua_cocos2dx_video_VideoPlayer_isUserInputEnabled); + tolua_function(tolua_S,"setKeepAspectRatioEnabled",lua_cocos2dx_video_VideoPlayer_setKeepAspectRatioEnabled); + tolua_function(tolua_S,"stop",lua_cocos2dx_video_VideoPlayer_stop); + tolua_function(tolua_S,"setFullScreenEnabled",lua_cocos2dx_video_VideoPlayer_setFullScreenEnabled); + tolua_function(tolua_S,"setFileName",lua_cocos2dx_video_VideoPlayer_setFileName); + tolua_function(tolua_S,"setURL",lua_cocos2dx_video_VideoPlayer_setURL); + tolua_function(tolua_S,"setStyle",lua_cocos2dx_video_VideoPlayer_setStyle); + tolua_function(tolua_S,"seekTo",lua_cocos2dx_video_VideoPlayer_seekTo); + tolua_function(tolua_S,"isKeepAspectRatioEnabled",lua_cocos2dx_video_VideoPlayer_isKeepAspectRatioEnabled); + tolua_function(tolua_S,"onPlayEvent",lua_cocos2dx_video_VideoPlayer_onPlayEvent); + tolua_function(tolua_S,"isFullScreenEnabled",lua_cocos2dx_video_VideoPlayer_isFullScreenEnabled); + tolua_function(tolua_S,"isLooping",lua_cocos2dx_video_VideoPlayer_isLooping); + tolua_function(tolua_S,"isPlaying",lua_cocos2dx_video_VideoPlayer_isPlaying); + tolua_function(tolua_S,"setLooping",lua_cocos2dx_video_VideoPlayer_setLooping); + tolua_function(tolua_S,"setUserInputEnabled",lua_cocos2dx_video_VideoPlayer_setUserInputEnabled); + tolua_function(tolua_S,"create", lua_cocos2dx_video_VideoPlayer_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::ui::VideoPlayer).name(); + g_luaType[typeName] = "ccui.VideoPlayer"; + g_typeCast["VideoPlayer"] = "ccui.VideoPlayer"; + return 1; +} +TOLUA_API int register_all_cocos2dx_video(lua_State* tolua_S) +{ + tolua_open(tolua_S); + + tolua_module(tolua_S,"ccui",0); + tolua_beginmodule(tolua_S,"ccui"); + + lua_register_cocos2dx_video_VideoPlayer(tolua_S); + + tolua_endmodule(tolua_S); + return 1; +} + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.hpp new file mode 100644 index 0000000000..31ac70ecb2 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.hpp @@ -0,0 +1,36 @@ +#include "base/ccConfig.h" +#ifndef __cocos2dx_video_h__ +#define __cocos2dx_video_h__ + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +int register_all_cocos2dx_video(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + +#endif // __cocos2dx_video_h__ diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.cpp new file mode 100644 index 0000000000..baf0094bf0 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.cpp @@ -0,0 +1,975 @@ +#include "scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.hpp" +#include "ui/UIWebView/UIWebView.h" +#include "scripting/lua-bindings/manual/tolua_fix.h" +#include "scripting/lua-bindings/manual/LuaBasicConversions.h" + +int lua_cocos2dx_webview_WebView_setOpacityWebView(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_setOpacityWebView'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.WebView:setOpacityWebView"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_setOpacityWebView'", nullptr); + return 0; + } + cobj->setOpacityWebView(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:setOpacityWebView",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_setOpacityWebView'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_canGoBack(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_canGoBack'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_canGoBack'", nullptr); + return 0; + } + bool ret = cobj->canGoBack(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:canGoBack",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_canGoBack'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_loadHTMLString(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_loadHTMLString'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:loadHTMLString"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_loadHTMLString'", nullptr); + return 0; + } + cobj->loadHTMLString(arg0); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 2) + { + std::string arg0; + std::string arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:loadHTMLString"); + + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccui.WebView:loadHTMLString"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_loadHTMLString'", nullptr); + return 0; + } + cobj->loadHTMLString(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:loadHTMLString",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_loadHTMLString'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_goForward(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_goForward'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_goForward'", nullptr); + return 0; + } + cobj->goForward(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:goForward",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_goForward'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_goBack(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_goBack'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_goBack'", nullptr); + return 0; + } + cobj->goBack(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:goBack",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_goBack'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_setScalesPageToFit(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_setScalesPageToFit'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.WebView:setScalesPageToFit"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_setScalesPageToFit'", nullptr); + return 0; + } + cobj->setScalesPageToFit(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:setScalesPageToFit",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_setScalesPageToFit'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_loadFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_loadFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:loadFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_loadFile'", nullptr); + return 0; + } + cobj->loadFile(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:loadFile",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_loadFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_loadURL(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_loadURL'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 2) { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:loadURL"); + + if (!ok) { break; } + bool arg1; + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "ccui.WebView:loadURL"); + + if (!ok) { break; } + cobj->loadURL(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 1) { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:loadURL"); + + if (!ok) { break; } + cobj->loadURL(arg0); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:loadURL",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_loadURL'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_setBounces(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_setBounces'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.WebView:setBounces"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_setBounces'", nullptr); + return 0; + } + cobj->setBounces(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:setBounces",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_setBounces'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_evaluateJS(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_evaluateJS'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:evaluateJS"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_evaluateJS'", nullptr); + return 0; + } + cobj->evaluateJS(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:evaluateJS",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_evaluateJS'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_setBackgroundTransparent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_setBackgroundTransparent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_setBackgroundTransparent'", nullptr); + return 0; + } + cobj->setBackgroundTransparent(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:setBackgroundTransparent",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_setBackgroundTransparent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_getOnJSCallback(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_getOnJSCallback'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_getOnJSCallback'", nullptr); + return 0; + } + cocos2d::ui::WebView::ccWebViewCallback ret = cobj->getOnJSCallback(); + #pragma warning NO CONVERSION FROM NATIVE FOR std::function; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:getOnJSCallback",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_getOnJSCallback'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_canGoForward(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_canGoForward'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_canGoForward'", nullptr); + return 0; + } + bool ret = cobj->canGoForward(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:canGoForward",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_canGoForward'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_stopLoading(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_stopLoading'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_stopLoading'", nullptr); + return 0; + } + cobj->stopLoading(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:stopLoading",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_stopLoading'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_getOpacityWebView(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_getOpacityWebView'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_getOpacityWebView'", nullptr); + return 0; + } + double ret = cobj->getOpacityWebView(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:getOpacityWebView",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_getOpacityWebView'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_reload(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_reload'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_reload'", nullptr); + return 0; + } + cobj->reload(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:reload",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_reload'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_setJavascriptInterfaceScheme(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::WebView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_webview_WebView_setJavascriptInterfaceScheme'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.WebView:setJavascriptInterfaceScheme"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_setJavascriptInterfaceScheme'", nullptr); + return 0; + } + cobj->setJavascriptInterfaceScheme(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:setJavascriptInterfaceScheme",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_setJavascriptInterfaceScheme'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_webview_WebView_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_create'", nullptr); + return 0; + } + cocos2d::ui::WebView* ret = cocos2d::ui::WebView::create(); + object_to_luaval(tolua_S, "ccui.WebView",(cocos2d::ui::WebView*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.WebView:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_webview_WebView_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::WebView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_webview_WebView_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::ui::WebView(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.WebView"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.WebView:WebView",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_webview_WebView_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_webview_WebView_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (WebView)"); + return 0; +} + +int lua_register_cocos2dx_webview_WebView(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"ccui.WebView"); + tolua_cclass(tolua_S,"WebView","ccui.WebView","ccui.Widget",nullptr); + + tolua_beginmodule(tolua_S,"WebView"); + tolua_function(tolua_S,"new",lua_cocos2dx_webview_WebView_constructor); + tolua_function(tolua_S,"setOpacityWebView",lua_cocos2dx_webview_WebView_setOpacityWebView); + tolua_function(tolua_S,"canGoBack",lua_cocos2dx_webview_WebView_canGoBack); + tolua_function(tolua_S,"loadHTMLString",lua_cocos2dx_webview_WebView_loadHTMLString); + tolua_function(tolua_S,"goForward",lua_cocos2dx_webview_WebView_goForward); + tolua_function(tolua_S,"goBack",lua_cocos2dx_webview_WebView_goBack); + tolua_function(tolua_S,"setScalesPageToFit",lua_cocos2dx_webview_WebView_setScalesPageToFit); + tolua_function(tolua_S,"loadFile",lua_cocos2dx_webview_WebView_loadFile); + tolua_function(tolua_S,"loadURL",lua_cocos2dx_webview_WebView_loadURL); + tolua_function(tolua_S,"setBounces",lua_cocos2dx_webview_WebView_setBounces); + tolua_function(tolua_S,"evaluateJS",lua_cocos2dx_webview_WebView_evaluateJS); + tolua_function(tolua_S,"setBackgroundTransparent",lua_cocos2dx_webview_WebView_setBackgroundTransparent); + tolua_function(tolua_S,"getOnJSCallback",lua_cocos2dx_webview_WebView_getOnJSCallback); + tolua_function(tolua_S,"canGoForward",lua_cocos2dx_webview_WebView_canGoForward); + tolua_function(tolua_S,"stopLoading",lua_cocos2dx_webview_WebView_stopLoading); + tolua_function(tolua_S,"getOpacityWebView",lua_cocos2dx_webview_WebView_getOpacityWebView); + tolua_function(tolua_S,"reload",lua_cocos2dx_webview_WebView_reload); + tolua_function(tolua_S,"setJavascriptInterfaceScheme",lua_cocos2dx_webview_WebView_setJavascriptInterfaceScheme); + tolua_function(tolua_S,"create", lua_cocos2dx_webview_WebView_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::ui::WebView).name(); + g_luaType[typeName] = "ccui.WebView"; + g_typeCast["WebView"] = "ccui.WebView"; + return 1; +} +TOLUA_API int register_all_cocos2dx_webview(lua_State* tolua_S) +{ + tolua_open(tolua_S); + + tolua_module(tolua_S,"ccui",0); + tolua_beginmodule(tolua_S,"ccui"); + + lua_register_cocos2dx_webview_WebView(tolua_S); + + tolua_endmodule(tolua_S); + return 1; +} + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.hpp new file mode 100644 index 0000000000..b3ba8fa20f --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.hpp @@ -0,0 +1,35 @@ +#include "base/ccConfig.h" +#ifndef __cocos2dx_webview_h__ +#define __cocos2dx_webview_h__ + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +int register_all_cocos2dx_webview(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + +#endif // __cocos2dx_webview_h__ 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 a01569d353..bdee328444 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 @@ -30,56 +30,6 @@ #include "3d/CCSprite3D.h" #include "3d/CCTerrain.h" -extern int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* L); - -CC_DEPRECATED_ATTRIBUTE int lua_cocos2dx_3d_Sprite3D_setBlendFunc01(lua_State* L) -{ - int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; - - tolua_Error tolua_err; - - if (!tolua_isusertype(L,1,"cc.Sprite3D",0,&tolua_err)) - goto tolua_lerror; - - 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_setBlendFunc01'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(L)-1; - if (argc != 2) - { - goto tolua_lerror; - } - else - { - CCLOG("setBlendFunc of cc.Sprite3D will deprecate two int parameter form,please pass a table like {src = xx, dst = xx} as a parameter"); - - GLenum src, dst; - if (!luaval_to_int32(L, 2, (int32_t*)&src, "cc.Sprite3D:setBlendFunc")) - return 0; - - if (!luaval_to_int32(L, 3, (int32_t*)&dst, "cc.Sprite3D:setBlendFunc")) - return 0; - -//TODO minggo -// BlendFunc blendFunc = {src, dst}; -// cobj->setBlendFunc(blendFunc); - - lua_settop(L, 1); - return 1; - } - -tolua_lerror: - return lua_cocos2dx_3d_Sprite3D_setBlendFunc(L); -} - int lua_cocos2dx_3d_Sprite3D_getAABB(lua_State* L) { int argc = 0; @@ -210,7 +160,6 @@ static void extendSprite3D(lua_State* L) lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "setBlendFunc", lua_cocos2dx_3d_Sprite3D_setBlendFunc01); tolua_function(L, "getAABB", lua_cocos2dx_3d_Sprite3D_getAABB); tolua_function(L, "createAsync", lua_cocos2dx_3d_Sprite3D_createAsync); } @@ -519,6 +468,67 @@ tolua_lerror: return 0; } +int lua_cocos2dx_3d_Terrain_getIntersectionPoint(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* 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.Terrain", 0, &tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S, 1, 0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S, "invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_getIntersectionPoint'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S) - 1; + do { + if (argc == 2) { + cocos2d::Ray* arg0 = nullptr; + ok &= luaval_to_object(tolua_S, 2, "cc.Ray", &arg0, "cc.Terrain:getIntersectionPoint"); + + if (!ok) { break; } + cocos2d::Vec3 arg1; + ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.Terrain:getIntersectionPoint"); + + if (!ok) { break; } + bool ret = cobj->getIntersectionPoint(*arg0, arg1); + tolua_pushboolean(tolua_S, (bool)ret); + vec3_to_luaval(tolua_S, arg1); + return 2; + } + } while (0); + ok = true; + do { + if (argc == 1) { + cocos2d::Ray* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Ray", &arg0, "cc.Terrain:getIntersectionPoint"); + + if (!ok) { break; } + cocos2d::Vec3 ret = cobj->getIntersectionPoint(*arg0); + vec3_to_luaval(tolua_S, ret); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:getIntersectionPoint", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S, "#ferror in function 'lua_cocos2dx_3d_Terrain_getIntersectionPoint'.", &tolua_err); +#endif + + return 0; +} + static void extendTerrain(lua_State* L) { lua_pushstring(L, "cc.Terrain"); @@ -527,6 +537,7 @@ static void extendTerrain(lua_State* L) { tolua_function(L, "create", lua_cocos2dx_3d_Terrain_create); tolua_function(L, "getHeight", lua_cocos2dx_3d_Terrain_getHeight); + tolua_function(L, "getIntersectionPoint", lua_cocos2dx_3d_Terrain_getIntersectionPoint); } lua_pop(L, 1); } diff --git a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp index 31d0599fa4..2767ca0234 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -52,9 +52,7 @@ extern "C" { #include "scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.h" #include "scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.hpp" #include "scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_physics_manual.hpp" -#include "scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp" #include "scripting/lua-bindings/auto/lua_cocos2dx_backend_auto.hpp" -#include "scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp" #include "base/ZipUtils.h" #include "scripting/deprecated/CCBool.h" #include "scripting/deprecated/CCDouble.h" @@ -152,9 +150,6 @@ bool LuaStack::init() register_all_cocos2dx_shaders_manual(_state); register_all_cocos2dx_bytearray_manual(_state); - register_all_cocos2dx_experimental(_state); - register_all_cocos2dx_experimental_manual(_state); - tolua_luanode_open(_state); register_luanode_manual(_state); #if CC_USE_PHYSICS diff --git a/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.cpp b/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.cpp index 91bbe3509c..fc9a715f9d 100644 --- a/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.cpp @@ -22,12 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "platform/CCPlatformConfig.h" - #include "scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX - #include "scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.hpp" #include "scripting/lua-bindings/manual/tolua_fix.h" #include "scripting/lua-bindings/manual/LuaBasicConversions.h" @@ -36,14 +31,14 @@ static int lua_get_AudioProfile_name(lua_State* L) { - cocos2d::experimental::AudioProfile* self = nullptr; + cocos2d::AudioProfile* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.AudioProfile",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AudioProfile",0,&tolua_err)) goto tolua_lerror; #endif - self = (cocos2d::experimental::AudioProfile*) tolua_tousertype(L,1,0); + self = (cocos2d::AudioProfile*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -65,14 +60,14 @@ tolua_lerror: static int lua_set_AudioProfile_name(lua_State* L) { int argc = 0; - cocos2d::experimental::AudioProfile* self = nullptr; + cocos2d::AudioProfile* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.AudioProfile",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AudioProfile",0,&tolua_err)) goto tolua_lerror; #endif - self = (cocos2d::experimental::AudioProfile*) tolua_tousertype(L,1,0); + self = (cocos2d::AudioProfile*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -104,14 +99,14 @@ tolua_lerror: static int lua_get_AudioProfile_maxInstances(lua_State* L) { - cocos2d::experimental::AudioProfile* self = nullptr; + cocos2d::AudioProfile* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.AudioProfile",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AudioProfile",0,&tolua_err)) goto tolua_lerror; #endif - self = (cocos2d::experimental::AudioProfile*) tolua_tousertype(L,1,0); + self = (cocos2d::AudioProfile*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -133,14 +128,14 @@ tolua_lerror: static int lua_set_AudioProfile_maxInstances(lua_State* L) { int argc = 0; - cocos2d::experimental::AudioProfile* self = nullptr; + cocos2d::AudioProfile* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.AudioProfile",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AudioProfile",0,&tolua_err)) goto tolua_lerror; #endif - self = (cocos2d::experimental::AudioProfile*) tolua_tousertype(L,1,0); + self = (cocos2d::AudioProfile*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -172,14 +167,14 @@ tolua_lerror: static int lua_get_AudioProfile_minDelay(lua_State* L) { - cocos2d::experimental::AudioProfile* self = nullptr; + cocos2d::AudioProfile* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.AudioProfile",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AudioProfile",0,&tolua_err)) goto tolua_lerror; #endif - self = (cocos2d::experimental::AudioProfile*) tolua_tousertype(L,1,0); + self = (cocos2d::AudioProfile*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -201,14 +196,14 @@ tolua_lerror: static int lua_set_AudioProfile_minDelay(lua_State* L) { int argc = 0; - cocos2d::experimental::AudioProfile* self = nullptr; + cocos2d::AudioProfile* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.AudioProfile",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AudioProfile",0,&tolua_err)) goto tolua_lerror; #endif - self = (cocos2d::experimental::AudioProfile*) tolua_tousertype(L,1,0); + self = (cocos2d::AudioProfile*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -248,7 +243,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setFinishCallback(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.AudioEngine",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.AudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -256,7 +251,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setFinishCallback(lua_State* tolua_S) if (argc == 2) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccexp.AudioEngine:setFinishCallback"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AudioEngine:setFinishCallback"); #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err)) @@ -267,7 +262,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setFinishCallback(lua_State* tolua_S) LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,3,0)); - cocos2d::experimental::AudioEngine::setFinishCallback(arg0, [handler](int audioID, std::string filePath){ + cocos2d::AudioEngine::setFinishCallback(arg0, [handler](int audioID, std::string filePath){ LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); stack->pushInt(audioID); @@ -280,7 +275,7 @@ int lua_cocos2dx_audioengine_AudioEngine_setFinishCallback(lua_State* tolua_S) return 0; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.AudioEngine:setFinishCallback",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setFinishCallback",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -297,7 +292,7 @@ int register_audioengine_module(lua_State* L) register_all_cocos2dx_audioengine(L); if (L) { - lua_pushstring(L, "ccexp.AudioProfile"); + lua_pushstring(L, "cc.AudioProfile"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -307,7 +302,7 @@ int register_audioengine_module(lua_State* L) } lua_pop(L, 1); - lua_pushstring(L, "ccexp.AudioEngine"); + lua_pushstring(L, "cc.AudioEngine"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -320,12 +315,3 @@ int register_audioengine_module(lua_State* L) return 1; } - -#else - -int register_audioengine_module(lua_State* L) -{ - return 1; -} - -#endif diff --git a/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.h b/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.h index 26552e372f..07c9dbe4f4 100644 --- a/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.h +++ b/cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.h @@ -22,8 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_AUDIOENGINE_LUA_COCOS2DX_AUDIOENGINE_MANUAL_H__ -#define COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_AUDIOENGINE_LUA_COCOS2DX_AUDIOENGINE_MANUAL_H__ +#pragma once #ifdef __cplusplus extern "C" { @@ -40,7 +39,7 @@ extern "C" { /** * Call this function can import the lua bindings for the audioengine module. - * After registering, we could call the related audioengine code conveniently in the lua.eg,.ccexp.AudioEngine:stop(audioID). + * After registering, we could call the related audioengine code conveniently in the lua.eg,.cc.AudioEngine:stop(audioID). * If you don't want to use the audioengine module in the lua, you only don't call this registering function. * If you don't register the audioengine module, the package size would become smaller . * The current mechanism,this function is called in the lua_module_register.h @@ -50,5 +49,3 @@ TOLUA_API int register_audioengine_module(lua_State* L); // end group /// @} - -#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_AUDIOENGINE_LUA_COCOS2DX_AUDIOENGINE_MANUAL_H__ diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp deleted file mode 100644 index 6d3d7ede1d..0000000000 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp" -#include "scripting/lua-bindings/manual/tolua_fix.h" -#include "scripting/lua-bindings/manual/LuaBasicConversions.h" -#include "scripting/lua-bindings/manual/CCLuaValue.h" -#include "scripting/lua-bindings/manual/CCLuaEngine.h" -#include "2d/CCFastTMXLayer.h" - -static int lua_cocos2dx_experimental_TMXLayer_getTileGIDAt(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::TMXLayer* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.TMXLayer",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::TMXLayer*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_TMXLayer_getTileGIDAt'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec2 arg0; - - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:getTileGIDAt"); - if(!ok) - return 0; - int ret = cobj->getTileGIDAt(arg0); - tolua_pushnumber(tolua_S,(lua_Number)ret); - tolua_pushnumber(tolua_S,(lua_Number)0); - return 2; - } - if (argc == 2) - { - cocos2d::Vec2 arg0; - int arg1 = 0; - - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccexp.TMXLayer:getTileGIDAt"); - ok &= luaval_to_int32(tolua_S, 3, &arg1, "ccexp.TMXLayer:getTileGIDAt"); - - if(!ok) - return 0; - - unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1); - tolua_pushnumber(tolua_S,(lua_Number)ret); - tolua_pushnumber(tolua_S,(lua_Number)arg1); - return 2; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.TMXLayer:getTileGIDAt",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_TMXLayer_getTileGIDAt'.",&tolua_err); -#endif - - return 0; -} - -static void extendExperimentalTMXLayer(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "ccexp.TMXLayer"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - tolua_function(tolua_S, "getTileGIDAt", lua_cocos2dx_experimental_TMXLayer_getTileGIDAt); - } - lua_pop(tolua_S, 1); -} - -bool isVectorV3FC4BT2F(lua_State* tolua_S, int lo) -{ - if (!lua_istable(tolua_S, lo)) - return false; - - lua_pushnumber(tolua_S, 1); - lua_gettable(tolua_S,lo); - if (!lua_istable(tolua_S, -1)) - return false; - - lua_pushstring(tolua_S, "vertices"); - lua_gettable(tolua_S, -2); - if (lua_isnil(tolua_S, -1)) - return false; - lua_pop(tolua_S, 1); - - lua_pushstring(tolua_S, "colors"); - lua_gettable(tolua_S, -2); - if (lua_isnil(tolua_S, -1)) - return false; - lua_pop(tolua_S, 1); - - lua_pushstring(tolua_S, "texCoords"); - lua_gettable(tolua_S, -2); - if (lua_isnil(tolua_S, -1)) - return false; - lua_pop(tolua_S, 1); - - return true; -} - -int register_all_cocos2dx_experimental_manual(lua_State* L) -{ - if (nullptr == L) - return 0; - - extendExperimentalTMXLayer(L); - - return 0; -} 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 857ba69a7b..14e48df7c1 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -48,6 +48,8 @@ #include "2d/CCSpriteBatchNode.h" #include "2d/CCTMXLayer.h" #include "2d/CCTMXTiledMap.h" +#include "2d/CCFastTMXLayer.h" +#include "2d/CCFastTMXTiledMap.h" #include "2d/CCRenderTexture.h" #include "base/CCEventDispatcher.h" #include "base/CCEventListenerKeyboard.h" @@ -598,7 +600,7 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) return 0; } - for (auto i = 0; i < argc; ++i) + for (int i = 0; i < argc; ++i) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, i + 2,"cc.MenuItem",0,&tolua_err) ) @@ -2403,7 +2405,7 @@ int tolua_cocos2d_Node_setAnchorPoint(lua_State* tolua_S) if (!ok) return 0; - cobj->setAnchorPoint(cocos2d::Vec2(x,y)); + cobj->setAnchorPoint(cocos2d::Vec2((float)x,(float)y)); lua_settop(tolua_S, 1); return 1; } @@ -3656,155 +3658,6 @@ tolua_lerror: return 0; } -// setBlendFunc -template -static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className) -{ - if (NULL == tolua_S || NULL == className || strlen(className) == 0) - return 0; - - int argc = 0; - T* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,className,0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(tolua_S,1,0)); - - argc = lua_gettop(tolua_S) - 1; - if (2 == argc) - { - CCLOG("setBlendFunc of %s will deprecate two int parameter form,please pass a table like {src = xx, dst = xx} as a parameter", className); - -//TODO minggo -// GLenum src, dst; -// if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src, StringUtils::format("%s%s",className, ":setBlendFunc").c_str())) -// return 0; -// -// if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst, StringUtils::format("%s%s",className, ":setBlendFunc").c_str())) -// return 0; -// -// BlendFunc blendFunc = {src, dst}; -// self->setBlendFunc(blendFunc); - return 0; - } - - - luaL_error(tolua_S, "'setBlendFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua_cocos2dx_setBlendFunc'.",&tolua_err); - return 0; -#endif -} -extern int lua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_Sprite_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.Sprite"); - } - - return lua_cocos2dx_Sprite_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_SpriteBatchNode_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_SpriteBatchNode_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.SpriteBatchNode"); - } - - return lua_cocos2dx_SpriteBatchNode_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_MotionStreak_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_MotionStreak_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.MotionStreak"); - } - - return lua_cocos2dx_MotionStreak_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_AtlasNode_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_AtlasNode_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.AtlasNode"); - } - - return lua_cocos2dx_AtlasNode_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_ParticleBatchNode_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_ParticleBatchNode_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.ParticleBatchNode"); - } - - return lua_cocos2dx_ParticleBatchNode_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_LayerColor_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.LayerColor"); - } - - return lua_cocos2dx_LayerColor_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_ParticleSystem_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_ParticleSystem_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.ParticleSystem"); - } - - return lua_cocos2dx_ParticleSystem_setBlendFunc(tolua_S); -} - -extern int lua_cocos2dx_DrawNode_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_DrawNode_setBlendFunc01(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.DrawNode"); - } - - return lua_cocos2dx_DrawNode_setBlendFunc(tolua_S); -} - static int tolua_cocos2dx_LayerMultiplex_create(lua_State* tolua_S) { if (nullptr == tolua_S) @@ -4584,10 +4437,6 @@ static void extendDrawNode(lua_State* tolua_S) lua_pushstring(tolua_S,"drawPoints"); lua_pushcfunction(tolua_S,tolua_cocos2dx_DrawNode_drawPoints); lua_rawset(tolua_S,-3); - - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_DrawNode_setBlendFunc01); - lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } @@ -4773,7 +4622,6 @@ static void extendSprite(lua_State* tolua_S) lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { - tolua_function(tolua_S, "setBlendFunc", tolua_cocos2dx_Sprite_setBlendFunc01); tolua_function(tolua_S, "initWithPolygon", lua_cocos2dx_Sprite_initWithPolygon); tolua_function(tolua_S, "setPolygonInfo", lua_cocos2dx_Sprite_setPolygonInfo); tolua_function(tolua_S, "create", lua_cocos2dx_Sprite_create); @@ -4781,19 +4629,6 @@ static void extendSprite(lua_State* tolua_S) lua_pop(tolua_S, 1); } -static void extendLayerColor(lua_State* tolua_S) -{ - lua_pushstring(tolua_S,"cc.LayerColor"); - lua_rawget(tolua_S,LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerColor_setBlendFunc01); - lua_rawset(tolua_S,-3); - } - lua_pop(tolua_S, 1); -} - static void extendLayerMultiplex(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.LayerMultiplex"); @@ -4807,19 +4642,6 @@ static void extendLayerMultiplex(lua_State* tolua_S) lua_pop(tolua_S, 1); } -static void extendParticleSystem(lua_State* tolua_S) -{ - lua_pushstring(tolua_S,"cc.ParticleSystem"); - lua_rawget(tolua_S,LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleSystem_setBlendFunc01); - lua_rawset(tolua_S,-3); - } - lua_pop(tolua_S, 1); -} - static void extendFileUtils(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.FileUtils"); @@ -4859,49 +4681,6 @@ static void extendSpriteBatchNode(lua_State* tolua_S) lua_pushstring(tolua_S,"getDescendants"); lua_pushcfunction(tolua_S,tolua_cocos2dx_SpriteBatchNode_getDescendants ); lua_rawset(tolua_S,-3); - - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_SpriteBatchNode_setBlendFunc01); - lua_rawset(tolua_S,-3); - } - lua_pop(tolua_S, 1); -} - -static void extendMotionStreak(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "cc.MotionStreak"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_MotionStreak_setBlendFunc01); - lua_rawset(tolua_S,-3); - } - lua_pop(tolua_S, 1); -} - -static void extendAtlasNode(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "cc.AtlasNode"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_AtlasNode_setBlendFunc01); - lua_rawset(tolua_S,-3); - } - lua_pop(tolua_S, 1); -} - -static void extendParticleBatchNode(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "cc.ParticleBatchNode"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleBatchNode_setBlendFunc01); - lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } @@ -6676,6 +6455,82 @@ static void extendTMXLayer(lua_State* tolua_S) lua_pop(tolua_S, 1); } +static int lua_cocos2dx_FastTMXLayer_getTileGIDAt(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::FastTMXLayer* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getTileGIDAt'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "cc.FastTMXLayer:getTileGIDAt"); + if(!ok) + return 0; + int ret = cobj->getTileGIDAt(arg0); + tolua_pushnumber(tolua_S,(lua_Number)ret); + tolua_pushnumber(tolua_S,(lua_Number)0); + return 2; + } + if (argc == 2) + { + cocos2d::Vec2 arg0; + int arg1 = 0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "cc.FastTMXLayer:getTileGIDAt"); + ok &= luaval_to_int32(tolua_S, 3, &arg1, "cc.FastTMXLayer:getTileGIDAt"); + + if(!ok) + return 0; + + unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1); + tolua_pushnumber(tolua_S,(lua_Number)ret); + tolua_pushnumber(tolua_S,(lua_Number)arg1); + return 2; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.FastTMXLayer:getTileGIDAt",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getTileGIDAt'.",&tolua_err); +#endif + + return 0; +} + +static void extendFastTMXLayer(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "cc.FastTMXLayer"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "getTileGIDAt", lua_cocos2dx_FastTMXLayer_getTileGIDAt); + } + lua_pop(tolua_S, 1); +} + int lua_cocos2dx_Application_isIOS64bit(lua_State* tolua_S) { @@ -7598,9 +7453,7 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) extendBezierTo(tolua_S); extendDrawNode(tolua_S); extendSprite(tolua_S); - extendLayerColor(tolua_S); extendLayerMultiplex(tolua_S); - extendParticleSystem(tolua_S); extendFileUtils(tolua_S); extendUserDefault(tolua_S); extendTexture2D(tolua_S); @@ -7616,14 +7469,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) extendPipelineDescriptor(tolua_S); extendProgramState(tolua_S); - extendMotionStreak(tolua_S); - extendAtlasNode(tolua_S); - extendParticleBatchNode(tolua_S); extendLabel(tolua_S); extendTMXTiledMap(tolua_S); extendConsole(tolua_S); extendOrbitCamera(tolua_S); extendTMXLayer(tolua_S); + extendFastTMXLayer(tolua_S); extendApplication(tolua_S); extendTextureCache(tolua_S); extendGLView(tolua_S); @@ -7830,10 +7681,10 @@ static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S) if (!ok) return 0; - x = (float)tolua_tonumber(tolua_S, 2, 0); - y = (float)tolua_tonumber(tolua_S, 3, 0); - z = (float)tolua_tonumber(tolua_S, 4, 0); - w = (float)tolua_tonumber(tolua_S, 5, 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); mat.transformVector(x,y,z,w, &dst); vec3_to_luaval(tolua_S, dst); @@ -8832,7 +8683,7 @@ static int tolua_cocos2d_bytearray_floatv(lua_State *L) } lua_pop(L, 1); lua_newtable(L); - for (size_t idx = 0; idx < arg.size(); idx++) + for (auto idx = 0; idx < arg.size(); idx++) { lua_pushnumber(L, arg[idx]); lua_rawseti(L, 1, idx + 1); diff --git a/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp b/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp index c7f8624da4..f8dfa58e77 100644 --- a/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp +++ b/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp @@ -237,9 +237,9 @@ static int lua_downloader_setOnTaskProgress(lua_State *L) if (ret) { pushTaskTable(L, task); //stack callbackfn, task - lua_pushnumber(L, bytesReceived); - lua_pushnumber(L, totalBytesReceived); - lua_pushnumber(L, totalBytesExpected); + lua_pushnumber(L, (lua_Number)bytesReceived); + lua_pushnumber(L, (lua_Number)totalBytesReceived); + lua_pushnumber(L, (lua_Number)totalBytesExpected); if (lua_pcall(L, 4, 0, 0) != 0) { lua_pop(L, 1); // remove callback or nil diff --git a/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp b/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp index c059dd4279..2deee55119 100644 --- a/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp @@ -36,53 +36,6 @@ using namespace spine; -// setBlendFunc -template -static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className) -{ - if (NULL == tolua_S || NULL == className || strlen(className) == 0) - return 0; - - int argc = 0; - T* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,className,0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(tolua_S,1,0)); - - argc = lua_gettop(tolua_S) - 1; - if (2 == argc) - { - CCLOG("setBlendFunc of %s will deprecate two int parameter form,please pass a table like {src = xx, dst = xx} as a parameter", className); - - GLenum src, dst; - if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src, StringUtils::format("%s%s",className,":setBlendFunc").c_str())) - return 0; - - if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst,StringUtils::format("%s%s",className,":setBlendFunc").c_str())) - return 0; - -//TODO minggo -// BlendFunc blendFunc = {src, dst}; -// self->setBlendFunc(blendFunc); - return 0; - } - - - luaL_error(tolua_S, "'setBlendFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'setBlendFunc'.",&tolua_err); - return 0; -#endif -} - - static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L) { if (nullptr == L) @@ -357,19 +310,6 @@ tolua_lerror: #endif } -extern int lua_cocos2dx_spine_SkeletonRenderer_setBlendFunc(lua_State* tolua_S); - -CC_DEPRECATED_ATTRIBUTE static int tolua_spine_SkeletoneAnimation_setBlendFunc(lua_State* tolua_S) -{ - int argc = lua_gettop(tolua_S) - 1; - if (argc == 2) - { - return tolua_cocos2dx_setBlendFunc(tolua_S,"sp.SkeletonAnimation"); - } - - return lua_cocos2dx_spine_SkeletonRenderer_setBlendFunc(tolua_S); -} - static int lua_cocos2dx_spine_SkeletonAnimation_addAnimation(lua_State* tolua_S) { int argc = 0; @@ -512,7 +452,6 @@ static void extendCCSkeletonAnimation(lua_State* L) tolua_function(L, "create", lua_cocos2dx_CCSkeletonAnimation_createWithFile); tolua_function(L, "registerSpineEventHandler", tolua_Cocos2d_CCSkeletonAnimation_registerSpineEventHandler00); tolua_function(L, "unregisterSpineEventHandler", tolua_Cocos2d_CCSkeletonAnimation_unregisterSpineEventHandler00); - tolua_function(L, "setBlendFunc", tolua_spine_SkeletoneAnimation_setBlendFunc); tolua_function(L, "addAnimation", lua_cocos2dx_spine_SkeletonAnimation_addAnimation); tolua_function(L, "setAnimation", lua_cocos2dx_spine_SkeletonAnimation_setAnimation); } diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.hpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.hpp deleted file mode 100644 index feeb1f9203..0000000000 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - -#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_WEBVIEW_MANUAL_H -#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_WEBVIEW_MANUAL_H - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -TOLUA_API int register_all_cocos2dx_experimental_webview_manual(lua_State* L); - -#endif //#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_WEBVIEW_MANUAL_H -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) 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 ed30f98f4e..0a46ceba76 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 @@ -25,10 +25,10 @@ #include "scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.hpp" #include "scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#include "scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp" -#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp" -#include "scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp" -#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.hpp" +#include "scripting/lua-bindings/auto/lua_cocos2dx_video_auto.hpp" +#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp" +#include "scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.hpp" +#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.hpp" #endif #include "scripting/lua-bindings/manual/tolua_fix.h" @@ -1183,10 +1183,10 @@ int register_ui_module(lua_State* L) register_all_cocos2dx_ui(L); register_all_cocos2dx_ui_manual(L); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - register_all_cocos2dx_experimental_video(L); - register_all_cocos2dx_experimental_video_manual(L); - register_all_cocos2dx_experimental_webview(L); - register_all_cocos2dx_experimental_webview_manual(L); + register_all_cocos2dx_video(L); + register_all_cocos2dx_video_manual(L); + register_all_cocos2dx_webview(L); + register_all_cocos2dx_webview_manual(L); #endif extendEventListenerFocusEvent(L); } diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.cpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.cpp similarity index 73% rename from cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.cpp rename to cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.cpp index f6a2f2df46..6652f25efb 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.cpp @@ -21,11 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - +#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp" #include "ui/UIVideoPlayer.h" #include "scripting/lua-bindings/manual/tolua_fix.h" #include "scripting/lua-bindings/manual/LuaBasicConversions.h" @@ -34,18 +30,18 @@ -static int lua_cocos2dx_experimental_video_VideoPlayer_addEventListener(lua_State* L) +static int lua_cocos2dx_video_VideoPlayer_addEventListener(lua_State* L) { int argc = 0; - cocos2d::experimental::ui::VideoPlayer* self = nullptr; + cocos2d::ui::VideoPlayer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.VideoPlayer",0,&tolua_err)) goto tolua_lerror; #endif - self = static_cast(tolua_tousertype(L,1,0)); + self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { @@ -67,7 +63,7 @@ static int lua_cocos2dx_experimental_video_VideoPlayer_addEventListener(lua_Stat LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - self->addEventListener([=](cocos2d::Ref* ref, cocos2d::experimental::ui::VideoPlayer::EventType eventType){ + self->addEventListener([=](cocos2d::Ref* ref, cocos2d::ui::VideoPlayer::EventType eventType){ LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); stack->pushObject(ref, "cc.Ref"); @@ -78,27 +74,27 @@ static int lua_cocos2dx_experimental_video_VideoPlayer_addEventListener(lua_Stat return 0; } - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.VideoPlayer:addEventListener",argc, 0); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.VideoPlayer:addEventListener",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_VideoPlayer_addEventListener'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_VideoPlayer_addEventListener'.", &tolua_err); #endif return 0; } static void extendVideoPlayer(lua_State* L) { - lua_pushstring(L, "ccexp.VideoPlayer"); + lua_pushstring(L, "ccui.VideoPlayer"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "addEventListener", lua_cocos2dx_experimental_video_VideoPlayer_addEventListener); + tolua_function(L, "addEventListener", lua_cocos2dx_video_VideoPlayer_addEventListener); } lua_pop(L, 1); } -int register_all_cocos2dx_experimental_video_manual(lua_State* L) +int register_all_cocos2dx_video_manual(lua_State* L) { if (nullptr == L) return 0; @@ -107,5 +103,3 @@ int register_all_cocos2dx_experimental_video_manual(lua_State* L) return 0; } - -#endif diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp similarity index 81% rename from cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp rename to cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp index 493ac64572..369f1fd6a4 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp @@ -22,10 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "base/ccConfig.h" - -#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_MANUAL_H -#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_MANUAL_H +#pragma once #ifdef __cplusplus extern "C" { @@ -35,6 +32,4 @@ extern "C" { } #endif -TOLUA_API int register_all_cocos2dx_experimental_manual(lua_State* L); - -#endif //#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_MANUAL_H +TOLUA_API int register_all_cocos2dx_video_manual(lua_State* L); diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.cpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.cpp similarity index 63% rename from cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.cpp rename to cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.cpp index 7d8e80c0eb..8c20622b45 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.cpp @@ -21,10 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.hpp" #include "ui/UIWebView/UIWebView.h" #include "scripting/lua-bindings/manual/tolua_fix.h" @@ -34,22 +31,22 @@ -static int lua_cocos2dx_experimental_WebView_setOnShouldStartLoading(lua_State* L) +static int lua_cocos2dx_WebView_setOnShouldStartLoading(lua_State* L) { int argc = 0; - cocos2d::experimental::ui::WebView* self = nullptr; + cocos2d::ui::WebView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; #endif - self = static_cast(tolua_tousertype(L,1,0)); + self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_experimental_WebView_setOnShouldStartLoading'\n", nullptr); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_WebView_setOnShouldStartLoading'\n", nullptr); return 0; } #endif @@ -66,8 +63,8 @@ static int lua_cocos2dx_experimental_WebView_setOnShouldStartLoading(lua_State* #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - std::function callback = [L,handler](experimental::ui::WebView *sender, const std::string &url)->bool{ - toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccexp.WebView"); + std::function callback = [L,handler](ui::WebView *sender, const std::string &url)->bool{ + toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccui.WebView"); tolua_pushcppstring(L, url); return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); }; @@ -77,31 +74,31 @@ static int lua_cocos2dx_experimental_WebView_setOnShouldStartLoading(lua_State* return 0; } - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:setOnShouldStartLoading",argc, 1); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.WebView:setOnShouldStartLoading",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_WebView_setOnShouldStartLoading'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_WebView_setOnShouldStartLoading'.", &tolua_err); #endif return 0; } -static int lua_cocos2dx_experimental_WebView_setOnDidFinishLoading(lua_State* L) +static int lua_cocos2dx_WebView_setOnDidFinishLoading(lua_State* L) { int argc = 0; - cocos2d::experimental::ui::WebView* self = nullptr; + cocos2d::ui::WebView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; #endif - self = static_cast(tolua_tousertype(L,1,0)); + self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_experimental_WebView_setOnDidFinishLoading'\n", nullptr); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_WebView_setOnDidFinishLoading'\n", nullptr); return 0; } #endif @@ -118,8 +115,8 @@ static int lua_cocos2dx_experimental_WebView_setOnDidFinishLoading(lua_State* L) #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - std::function callback = [L,handler](experimental::ui::WebView *sender, const std::string &url){ - toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccexp.WebView"); + std::function callback = [L,handler](ui::WebView *sender, const std::string &url){ + toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccui.WebView"); tolua_pushcppstring(L, url); LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); }; @@ -128,31 +125,31 @@ static int lua_cocos2dx_experimental_WebView_setOnDidFinishLoading(lua_State* L) self->setOnDidFinishLoading(callback); return 0; } - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:setOnDidFinishLoading",argc, 1); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.WebView:setOnDidFinishLoading",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_WebView_setOnDidFinishLoading'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_WebView_setOnDidFinishLoading'.", &tolua_err); #endif return 0; } -static int lua_cocos2dx_experimental_WebView_setOnDidFailLoading(lua_State* L) +static int lua_cocos2dx_WebView_setOnDidFailLoading(lua_State* L) { int argc = 0; - cocos2d::experimental::ui::WebView* self = nullptr; + cocos2d::ui::WebView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.WebView",0,&tolua_err)) goto tolua_lerror; #endif - self = static_cast(tolua_tousertype(L,1,0)); + self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_experimental_WebView_setOnDidFailLoading'\n", nullptr); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_WebView_setOnDidFailLoading'\n", nullptr); return 0; } #endif @@ -169,8 +166,8 @@ static int lua_cocos2dx_experimental_WebView_setOnDidFailLoading(lua_State* L) #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - std::function callback = [L,handler](experimental::ui::WebView *sender, const std::string &url){ - toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccexp.WebView"); + std::function callback = [L,handler](ui::WebView *sender, const std::string &url){ + toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccui.WebView"); tolua_pushcppstring(L, url); LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); }; @@ -179,29 +176,29 @@ static int lua_cocos2dx_experimental_WebView_setOnDidFailLoading(lua_State* L) self->setOnDidFailLoading(callback); return 0; } - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:setOnDidFailLoading",argc, 1); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.WebView:setOnDidFailLoading",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_WebView_setOnDidFailLoading'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_WebView_setOnDidFailLoading'.", &tolua_err); #endif return 0; } static void extendWebView(lua_State* L) { - lua_pushstring(L, "ccexp.WebView"); + lua_pushstring(L, "ccui.WebView"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "setOnShouldStartLoading", lua_cocos2dx_experimental_WebView_setOnShouldStartLoading); - tolua_function(L, "setOnDidFinishLoading", lua_cocos2dx_experimental_WebView_setOnDidFinishLoading); - tolua_function(L, "setOnDidFailLoading", lua_cocos2dx_experimental_WebView_setOnDidFailLoading); + tolua_function(L, "setOnShouldStartLoading", lua_cocos2dx_WebView_setOnShouldStartLoading); + tolua_function(L, "setOnDidFinishLoading", lua_cocos2dx_WebView_setOnDidFinishLoading); + tolua_function(L, "setOnDidFailLoading", lua_cocos2dx_WebView_setOnDidFailLoading); } lua_pop(L, 1); } -int register_all_cocos2dx_experimental_webview_manual(lua_State* L) +int register_all_cocos2dx_webview_manual(lua_State* L) { if (nullptr == L) return 0; @@ -210,5 +207,3 @@ int register_all_cocos2dx_experimental_webview_manual(lua_State* L) return 0; } - -#endif diff --git a/cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.hpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.hpp similarity index 72% rename from cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.hpp rename to cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.hpp index 0bd585ba61..05fb220099 100644 --- a/cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.hpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.hpp @@ -22,11 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - -#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_VIDEO_MANUAL_H -#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_VIDEO_MANUAL_H +#pragma once #ifdef __cplusplus extern "C" { @@ -36,7 +32,4 @@ extern "C" { } #endif -TOLUA_API int register_all_cocos2dx_experimental_video_manual(lua_State* L); - -#endif //#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_VIDEO_MANUAL_H -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +TOLUA_API int register_all_cocos2dx_webview_manual(lua_State* L); diff --git a/cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.cpp b/cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.cpp deleted file mode 100644 index a123f95ca6..0000000000 --- a/cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.hpp" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - -#include "ui/UIVideoPlayer.h" -#include "scripting/lua-bindings/manual/tolua_fix.h" -#include "scripting/lua-bindings/manual/LuaBasicConversions.h" -#include "scripting/lua-bindings/manual/CCLuaValue.h" -#include "scripting/lua-bindings/manual/CCLuaEngine.h" - - - -static int lua_cocos2dx_experimental_video_VideoPlayer_addEventListener(lua_State* L) -{ - - int argc = 0; - cocos2d::experimental::ui::VideoPlayer* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccexp.VideoPlayer",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", nullptr); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (argc == 1) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - self->addEventListener([=](cocos2d::Ref* ref, cocos2d::experimental::ui::VideoPlayer::EventType eventType){ - LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); - - stack->pushObject(ref, "cc.Ref"); - stack->pushInt((int)eventType); - - stack->executeFunctionByHandler(handler, 2); - }); - - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.VideoPlayer:addEventListener",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_VideoPlayer_addEventListener'.", &tolua_err); -#endif - return 0; -} - -static void extendVideoPlayer(lua_State* L) -{ - lua_pushstring(L, "ccexp.VideoPlayer"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListener", lua_cocos2dx_experimental_video_VideoPlayer_addEventListener); - } - lua_pop(L, 1); -} - -int register_all_cocos2dx_experimental_video_manual(lua_State* L) -{ - if (nullptr == L) - return 0; - - extendVideoPlayer(L); - - return 0; -} - -#endif diff --git a/cocos/scripting/lua-bindings/script/init.lua b/cocos/scripting/lua-bindings/script/init.lua index dc72992ce6..6c8eeb20ba 100644 --- a/cocos/scripting/lua-bindings/script/init.lua +++ b/cocos/scripting/lua-bindings/script/init.lua @@ -41,7 +41,6 @@ end -- ui if nil ~= ccui then require "cocos.ui.GuiConstants" - require "cocos.ui.experimentalUIConstants" end -- extensions diff --git a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua index 2801a9a22f..b116af6d69 100644 --- a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua +++ b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua @@ -220,3 +220,10 @@ ccui.LayoutComponent.VerticalEdge = { Top = 2, Center = 3, } + +ccui.VideoPlayerEvent = { + PLAYING = 0, + PAUSED = 1, + STOPPED= 2, + COMPLETED =3, +} diff --git a/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua b/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua deleted file mode 100644 index b2bcc05bf1..0000000000 --- a/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua +++ /dev/null @@ -1,10 +0,0 @@ -if nil == ccexp then - return -end - -ccexp.VideoPlayerEvent = { - PLAYING = 0, - PAUSED = 1, - STOPPED= 2, - COMPLETED =3, -} diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp index a5984708a2..cfd5b166db 100755 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp @@ -93,13 +93,13 @@ void EditBoxImplCommon::initInactiveLabels(const Size& size) const char* pDefaultFontName = this->getNativeDefaultFontName(); _label = Label::create(); - _label->setAnchorPoint(Vec2(0,1)); + _label->setAnchorPoint(Vec2(0.0f,1.0f)); _label->setOverflow(Label::Overflow::CLAMP); _label->setVisible(false); _editBox->addChild(_label, kLabelZOrder); _labelPlaceHolder = Label::create(); - _labelPlaceHolder->setAnchorPoint(Vec2(0, 1.0f)); + _labelPlaceHolder->setAnchorPoint(Vec2(0.0f, 1.0f)); _labelPlaceHolder->setTextColor(Color4B::GRAY); _labelPlaceHolder->enableWrap(false); _editBox->addChild(_labelPlaceHolder, kLabelZOrder); @@ -115,20 +115,20 @@ void EditBoxImplCommon::placeInactiveLabels(const Size& size) auto placeholderSize = _labelPlaceHolder->getContentSize(); if(_editBoxInputMode == EditBox::InputMode::ANY){ - _label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height - CC_EDIT_BOX_PADDING)); + _label->setPosition(Vec2((float)CC_EDIT_BOX_PADDING, size.height - CC_EDIT_BOX_PADDING)); _label->setVerticalAlignment(TextVAlignment::TOP); _label->enableWrap(true); - _labelPlaceHolder->setPosition(Vec2(CC_EDIT_BOX_PADDING, + _labelPlaceHolder->setPosition(Vec2((float)CC_EDIT_BOX_PADDING, size.height - CC_EDIT_BOX_PADDING)); _labelPlaceHolder->setVerticalAlignment(TextVAlignment::TOP); } else { _label->enableWrap(false); - _label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height)); + _label->setPosition(Vec2((float)CC_EDIT_BOX_PADDING, size.height)); _label->setVerticalAlignment(TextVAlignment::CENTER); - _labelPlaceHolder->setPosition(Vec2(CC_EDIT_BOX_PADDING, + _labelPlaceHolder->setPosition(Vec2((float)CC_EDIT_BOX_PADDING, (size.height + placeholderSize.height) / 2)); _labelPlaceHolder->setVerticalAlignment(TextVAlignment::CENTER); } diff --git a/cocos/ui/UIEditBox/iOS/CCUIEditBoxIOS.h b/cocos/ui/UIEditBox/iOS/CCUIEditBoxIOS.h index 3befee2994..7b69afa2fb 100644 --- a/cocos/ui/UIEditBox/iOS/CCUIEditBoxIOS.h +++ b/cocos/ui/UIEditBox/iOS/CCUIEditBoxIOS.h @@ -43,25 +43,25 @@ @property (nonatomic, readwrite) BOOL returnPressed; - (instancetype)initWithFrame:(CGRect)frameRect editBox:(void *)editBox; -- ()doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance; +- (void)doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance; - (NSString *)getDefaultFontName; - (cocos2d::ui::EditBoxDelegate::EditBoxEndAction)getEndAction; -- ()setInputMode:(cocos2d::ui::EditBox::InputMode)inputMode; -- ()setInputFlag:(cocos2d::ui::EditBox::InputFlag)flag; -- ()setReturnType:(cocos2d::ui::EditBox::KeyboardReturnType)returnType; -- ()setTextHorizontalAlignment:(cocos2d::TextHAlignment)alignment; +- (void)setInputMode:(cocos2d::ui::EditBox::InputMode)inputMode; +- (void)setInputFlag:(cocos2d::ui::EditBox::InputFlag)flag; +- (void)setReturnType:(cocos2d::ui::EditBox::KeyboardReturnType)returnType; +- (void)setTextHorizontalAlignment:(cocos2d::TextHAlignment)alignment; -- ()setPlaceHolder:(NSString *)text; -- ()setPlaceholderFont:(UIFont *)font; -- ()setPlaceholderTextColor:(UIColor *)color; -- ()setVisible:(BOOL)visible; -- ()setTextColor:(UIColor*)color; -- ()setFont:(UIFont *)font; -- ()updateFrame:(CGRect)rect; +- (void)setPlaceHolder:(NSString *)text; +- (void)setPlaceholderFont:(UIFont *)font; +- (void)setPlaceholderTextColor:(UIColor *)color; +- (void)setVisible:(BOOL)visible; +- (void)setTextColor:(UIColor*)color; +- (void)setFont:(UIFont *)font; +- (void)updateFrame:(CGRect)rect; -- ()openKeyboard; -- ()closeKeyboard; +- (void)openKeyboard; +- (void)closeKeyboard; @end diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index 70bbcdd83a..a8ad0ecc1e 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -101,7 +101,7 @@ void LoadingBar::initRenderer() _barRenderer = Scale9Sprite::create(); _barRenderer->setScale9Enabled(false); addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1); - _barRenderer->setAnchorPoint(Vec2(0.0,0.5)); + _barRenderer->setAnchorPoint(Vec2(0.0f,0.5f)); } @@ -117,7 +117,7 @@ void LoadingBar::setDirection(cocos2d::ui::LoadingBar::Direction direction) { case Direction::LEFT: _barRenderer->setAnchorPoint(Vec2(0.0f,0.5f)); - _barRenderer->setPosition(Vec2(0,_contentSize.height*0.5f)); + _barRenderer->setPosition(Vec2(0.0f,_contentSize.height*0.5f)); break; case Direction::RIGHT: _barRenderer->setAnchorPoint(Vec2(1.0f,0.5f)); diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 5f98d1a97c..689f366018 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -166,7 +166,7 @@ void ScrollView::onSizeChanged() float innerSizeWidth = MAX(orginInnerSizeWidth, _contentSize.width); float innerSizeHeight = MAX(orginInnerSizeHeight, _contentSize.height); _innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight)); - setInnerContainerPosition(Vec2(0, _contentSize.height - _innerContainer->getContentSize().height)); + setInnerContainerPosition(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height)); if (_verticalScrollBar != nullptr) { @@ -1090,10 +1090,10 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende switch (_direction) { case Direction::HORIZONTAL: - offsetInInch = convertDistanceFromPointToInch(Vec2(std::abs(sender->getTouchBeganPosition().x - touchPoint.x), 0)); + offsetInInch = convertDistanceFromPointToInch(Vec2(std::abs(sender->getTouchBeganPosition().x - touchPoint.x), 0.0f)); break; case Direction::VERTICAL: - offsetInInch = convertDistanceFromPointToInch(Vec2(0, std::abs(sender->getTouchBeganPosition().y - touchPoint.y))); + offsetInInch = convertDistanceFromPointToInch(Vec2(0.0f, std::abs(sender->getTouchBeganPosition().y - touchPoint.y))); break; case Direction::BOTH: offsetInInch = convertDistanceFromPointToInch(sender->getTouchBeganPosition() - touchPoint); diff --git a/cocos/ui/UITabControl.cpp b/cocos/ui/UITabControl.cpp index f3be7629bf..038e93e4f8 100644 --- a/cocos/ui/UITabControl.cpp +++ b/cocos/ui/UITabControl.cpp @@ -481,7 +481,7 @@ namespace ui if (tabcell != nullptr && tabcell->init()) { tabcell->_frontCrossRenderer->setVisible(false); // _isSelected == false - tabcell->_anchorPoint = Vec2(.5f, 0); + tabcell->_anchorPoint = Vec2(.5f, 0.0f); tabcell->autorelease(); return tabcell; } @@ -503,7 +503,7 @@ namespace ui { tabcell->_frontCrossRenderer->setVisible(false); tabcell->_tabLabelRender->setString(titleStr); - tabcell->_anchorPoint = Vec2(.5f, 0); + tabcell->_anchorPoint = Vec2(.5f, 0.0f); tabcell->autorelease(); return tabcell; } @@ -529,7 +529,7 @@ namespace ui { tabcell->_frontCrossRenderer->setVisible(false); tabcell->_tabLabelRender->setString(titleStr); - tabcell->_anchorPoint = Vec2(.5f, 0); + tabcell->_anchorPoint = Vec2(.5f, 0.0f); tabcell->autorelease(); return tabcell; } diff --git a/cocos/ui/UIVideoPlayer-android.cpp b/cocos/ui/UIVideoPlayer-android.cpp index 344f7960ad..61307920ac 100644 --- a/cocos/ui/UIVideoPlayer-android.cpp +++ b/cocos/ui/UIVideoPlayer-android.cpp @@ -87,7 +87,7 @@ void setUserInputEnabledJNI(int index, bool enableInput) //----------------------------------------------------------------------------------------------------------- -using namespace cocos2d::experimental::ui; +using namespace cocos2d::ui; static std::unordered_map s_allVideoPlayers; diff --git a/cocos/ui/UIVideoPlayer-ios.mm b/cocos/ui/UIVideoPlayer-ios.mm index 1ef018e34d..2c67a74d50 100644 --- a/cocos/ui/UIVideoPlayer-ios.mm +++ b/cocos/ui/UIVideoPlayer-ios.mm @@ -28,7 +28,7 @@ // No Available on tvOS #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS && !defined(CC_TARGET_OS_TVOS) -using namespace cocos2d::experimental::ui; +using namespace cocos2d::ui; //------------------------------------------------------------------------------------- #include "platform/ios/CCEAGLView-ios.h" @@ -87,7 +87,7 @@ typedef NS_ENUM(NSInteger, PlayerbackState) { -(id)init:(void*)videoPlayer { if (self = [super init]) { - self.playerController = [AVPlayerViewController new]; + self.playerController = [[AVPlayerViewController new] autorelease]; [self setRepeatEnabled:FALSE]; [self showPlaybackControls:TRUE]; @@ -110,6 +110,7 @@ typedef NS_ENUM(NSInteger, PlayerbackState) { -(void) clean { + _videoPlayer = nullptr; [self stop]; [self removePlayerEventListener]; [self.playerController.view removeFromSuperview]; @@ -243,7 +244,11 @@ typedef NS_ENUM(NSInteger, PlayerbackState) { [self seekTo:0]; [self.playerController.player pause]; _state = PlayerbackStopped; - _videoPlayer->onPlayEvent((int)VideoPlayer::EventType::STOPPED); + + // stop() will be invoked in dealloc, which is invoked by _videoPlayer's destructor, + // so do't send the message when _videoPlayer is being deleted. + if (_videoPlayer) + _videoPlayer->onPlayEvent((int)VideoPlayer::EventType::STOPPED); } } @@ -268,15 +273,6 @@ typedef NS_ENUM(NSInteger, PlayerbackState) { //------------------------------------------------------------------------------------------------------------ VideoPlayer::VideoPlayer() -: _isPlaying(false) -, _fullScreenDirty(false) -, _fullScreenEnabled(false) -, _keepAspectRatioEnabled(false) -, _videoPlayerIndex(-1) -, _eventCallback(nullptr) -, _isLooping(false) -, _isUserInputEnabled(true) -, _styleType(StyleType::DEFAULT) { _videoView = [[UIVideoViewWrapperIos alloc] init:this]; diff --git a/cocos/ui/UIVideoPlayer.h b/cocos/ui/UIVideoPlayer.h index 4e8be1c9c5..53c6153264 100644 --- a/cocos/ui/UIVideoPlayer.h +++ b/cocos/ui/UIVideoPlayer.h @@ -22,9 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __COCOS2D_UI_VIDEOWEIGTH_H_ -#define __COCOS2D_UI_VIDEOWEIGTH_H_ +#pragma once #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) && !defined(CC_PLATFORM_OS_TVOS) @@ -36,236 +34,233 @@ */ NS_CC_BEGIN -namespace experimental{ - namespace ui{ +namespace ui{ + + /** + * @class VideoPlayer + * @brief Displays a video file. + * + * @note VideoPlayer displays a video file base on system widget. + * It's mean VideoPlayer displays a video file above all graphical elements of cocos2d-x. + * @js NA + */ + class VideoPlayer : public cocos2d::ui::Widget + { + public: + /** + * Videoplayer play event type. + */ + enum class EventType + { + PLAYING = 0, + PAUSED, + STOPPED, + COMPLETED, + ERROR + }; + + /** + * Styles of how the the video player is presented + * For now only used on iOS to use either MPMovieControlStyleEmbedded (DEFAULT) or + * MPMovieControlStyleNone (NONE) + */ + enum class StyleType + { + DEFAULT = 0, + NONE + }; /** - * @class VideoPlayer - * @brief Displays a video file. - * - * @note VideoPlayer displays a video file base on system widget. - * It's mean VideoPlayer displays a video file above all graphical elements of cocos2d-x. - * @js NA + * A callback which will be called after specific VideoPlayer event happens. */ - class VideoPlayer : public cocos2d::ui::Widget - { - public: - /** - * Videoplayer play event type. - */ - enum class EventType - { - PLAYING = 0, - PAUSED, - STOPPED, - COMPLETED, - ERROR - }; - - /** - * Styles of how the the video player is presented - * For now only used on iOS to use either MPMovieControlStyleEmbedded (DEFAULT) or - * MPMovieControlStyleNone (NONE) - */ - enum class StyleType - { - DEFAULT = 0, - NONE - }; + typedef std::function ccVideoPlayerCallback; - /** - * A callback which will be called after specific VideoPlayer event happens. - */ - typedef std::function ccVideoPlayerCallback; + /** + *Static create method for instancing a VideoPlayer. + */ + CREATE_FUNC(VideoPlayer); - /** - *Static create method for instancing a VideoPlayer. - */ - CREATE_FUNC(VideoPlayer); + /** + * Sets a file path as a video source for VideoPlayer. + */ + virtual void setFileName(const std::string& videoPath); + + /** + * @brief Get the local video file name. + * + * @return The video file name. + */ + virtual const std::string& getFileName() const { return _videoURL;} - /** - * Sets a file path as a video source for VideoPlayer. - */ - virtual void setFileName(const std::string& videoPath); - - /** - * @brief Get the local video file name. - * - * @return The video file name. - */ - virtual const std::string& getFileName() const { return _videoURL;} + /** + * Sets a URL as a video source for VideoPlayer. + */ + virtual void setURL(const std::string& _videoURL); - /** - * Sets a URL as a video source for VideoPlayer. - */ - virtual void setURL(const std::string& _videoURL); + + /** + * @brief Get the URL of remoting video source. + * + * @return A remoting URL address. + */ + virtual const std::string& getURL() const { return _videoURL;} + + /** + * @brief Set if playback is done in loop mode + * + * @param looping the video will or not automatically restart at the end + */ + virtual void setLooping(bool looping); + + /** + * Set if the player will enable user input for basic pause and resume of video + * + * @param enableInput If true, input will be handled for basic functionality (pause/resume) + */ + virtual void setUserInputEnabled(bool enableInput); + + /** + * Set the style of the player + * + * @param style The corresponding style + */ + virtual void setStyle(StyleType style); - - /** - * @brief Get the URL of remoting video source. - * - * @return A remoting URL address. - */ - virtual const std::string& getURL() const { return _videoURL;} - - /** - * @brief Set if playback is done in loop mode - * - * @param looping the video will or not automatically restart at the end - */ - virtual void setLooping(bool looping); - - /** - * Set if the player will enable user input for basic pause and resume of video - * - * @param enableInput If true, input will be handled for basic functionality (pause/resume) - */ - virtual void setUserInputEnabled(bool enableInput); - - /** - * Set the style of the player - * - * @param style The corresponding style - */ - virtual void setStyle(StyleType style); + /** + * Starts playback. + */ + virtual void play(); - /** - * Starts playback. - */ - virtual void play(); + /** + * Pauses playback. + */ + virtual void pause()override; - /** - * Pauses playback. - */ - virtual void pause()override; + /** + * Resumes playback. + */ + virtual void resume()override; - /** - * Resumes playback. - */ - virtual void resume()override; + /** + * Stops playback. + */ + virtual void stop(); - /** - * Stops playback. - */ - virtual void stop(); + /** + * Seeks to specified time position. + * + * @param sec The offset in seconds from the start to seek to. + */ + virtual void seekTo(float sec); - /** - * Seeks to specified time position. - * - * @param sec The offset in seconds from the start to seek to. - */ - virtual void seekTo(float sec); - - /** - * Checks whether the VideoPlayer is playing. - * - * @return True if currently playing, false otherwise. - */ - virtual bool isPlaying() const; - - /** - * Checks whether the VideoPlayer is set with looping mode. - * - * @return true if the videoplayer is set to loop, false otherwise. - */ - virtual bool isLooping() const; + /** + * Checks whether the VideoPlayer is playing. + * + * @return True if currently playing, false otherwise. + */ + virtual bool isPlaying() const; + + /** + * Checks whether the VideoPlayer is set with looping mode. + * + * @return true if the videoplayer is set to loop, false otherwise. + */ + virtual bool isLooping() const; - /** - * Checks whether the VideoPlayer is set to listen user input to resume and pause the video - * - * @return true if the videoplayer user input is set, false otherwise. - */ - virtual bool isUserInputEnabled() const; - + /** + * Checks whether the VideoPlayer is set to listen user input to resume and pause the video + * + * @return true if the videoplayer user input is set, false otherwise. + */ + virtual bool isUserInputEnabled() const; + - /** - * Causes the video player to keep aspect ratio or no when displaying the video. - * - * @param enable Specify true to keep aspect ratio or false to scale the video until - * both dimensions fit the visible bounds of the view exactly. - */ - virtual void setKeepAspectRatioEnabled(bool enable); + /** + * Causes the video player to keep aspect ratio or no when displaying the video. + * + * @param enable Specify true to keep aspect ratio or false to scale the video until + * both dimensions fit the visible bounds of the view exactly. + */ + virtual void setKeepAspectRatioEnabled(bool enable); - /** - * Indicates whether the video player keep aspect ratio when displaying the video. - */ - virtual bool isKeepAspectRatioEnabled()const { return _keepAspectRatioEnabled;} + /** + * Indicates whether the video player keep aspect ratio when displaying the video. + */ + virtual bool isKeepAspectRatioEnabled()const { return _keepAspectRatioEnabled;} - /** - * Causes the video player to enter or exit full-screen mode. - * - * @param fullscreen Specify true to enter full-screen mode or false to exit full-screen mode. - */ - virtual void setFullScreenEnabled(bool fullscreen); + /** + * Causes the video player to enter or exit full-screen mode. + * + * @param fullscreen Specify true to enter full-screen mode or false to exit full-screen mode. + */ + virtual void setFullScreenEnabled(bool fullscreen); - /** - * Indicates whether the video player is in full-screen mode. - * - * @return True if the video player is in full-screen mode, false otherwise. - */ - virtual bool isFullScreenEnabled()const; + /** + * Indicates whether the video player is in full-screen mode. + * + * @return True if the video player is in full-screen mode, false otherwise. + */ + virtual bool isFullScreenEnabled()const; - /** - * Register a callback to be invoked when the video state is updated. - * - * @param callback The callback that will be run. - */ - virtual void addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback); - - /** - * @brief A function which will be called when video is playing. - * - * @param event @see VideoPlayer::EventType. - - */ - virtual void onPlayEvent(int event); - virtual void setVisible(bool visible) override; - virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags) override; - virtual void onEnter() override; - virtual void onExit() override; + /** + * Register a callback to be invoked when the video state is updated. + * + * @param callback The callback that will be run. + */ + virtual void addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback); + + /** + * @brief A function which will be called when video is playing. + * + * @param event @see VideoPlayer::EventType. + + */ + virtual void onPlayEvent(int event); + virtual void setVisible(bool visible) override; + virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags) override; + virtual void onEnter() override; + virtual void onExit() override; - protected: - virtual cocos2d::ui::Widget* createCloneInstance() override; - virtual void copySpecialProperties(Widget* model) override; - - CC_CONSTRUCTOR_ACCESS: - VideoPlayer(); - virtual ~VideoPlayer(); + protected: + virtual cocos2d::ui::Widget* createCloneInstance() override; + virtual void copySpecialProperties(Widget* model) override; + + CC_CONSTRUCTOR_ACCESS: + VideoPlayer(); + virtual ~VideoPlayer(); - protected: + protected: #if CC_VIDEOPLAYER_DEBUG_DRAW - DrawNode *_debugDrawNode; + DrawNode *_debugDrawNode; #endif - enum class Source - { - FILENAME = 0, - URL - }; - - bool _isPlaying; - bool _isLooping; - bool _isUserInputEnabled; - bool _fullScreenDirty; - bool _fullScreenEnabled; - bool _keepAspectRatioEnabled; - - StyleType _styleType; - - std::string _videoURL; - Source _videoSource; - - int _videoPlayerIndex; - ccVideoPlayerCallback _eventCallback; - - void* _videoView; + enum class Source + { + FILENAME = 0, + URL }; - } + + bool _isPlaying = false; + bool _isLooping = false; + bool _isUserInputEnabled = true; + bool _fullScreenDirty = false; + bool _fullScreenEnabled = false; + bool _keepAspectRatioEnabled = false; + + StyleType _styleType = StyleType::DEFAULT; + + std::string _videoURL; + Source _videoSource; + + int _videoPlayerIndex = -1; + ccVideoPlayerCallback _eventCallback = nullptr; + + void* _videoView = nullptr; + }; } NS_CC_END // end group /// @} #endif -#endif diff --git a/cocos/ui/UIWebView/UIWebView-inl.h b/cocos/ui/UIWebView/UIWebView-inl.h index 0e12e07c6b..e635ca75b3 100644 --- a/cocos/ui/UIWebView/UIWebView-inl.h +++ b/cocos/ui/UIWebView/UIWebView-inl.h @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#pragma once /// @cond DO_NOT_SHOW @@ -31,216 +32,209 @@ #include "platform/CCFileUtils.h" NS_CC_BEGIN -namespace experimental{ - namespace ui{ +namespace ui{ + WebView::WebView() + : _impl(new WebViewImpl(this)) + { + } - WebView::WebView() - : _impl(new WebViewImpl(this)), - _onJSCallback(nullptr), - _onShouldStartLoading(nullptr), - _onDidFinishLoading(nullptr), - _onDidFailLoading(nullptr) - { - } + WebView::~WebView() + { + CC_SAFE_DELETE(_impl); + } - WebView::~WebView() + WebView *WebView::create() + { + auto webView = new(std::nothrow) WebView(); + if (webView && webView->init()) { - CC_SAFE_DELETE(_impl); + webView->autorelease(); + return webView; } + CC_SAFE_DELETE(webView); + return nullptr; + } - WebView *WebView::create() - { - auto webView = new(std::nothrow) WebView(); - if (webView && webView->init()) - { - webView->autorelease(); - return webView; - } - CC_SAFE_DELETE(webView); - return nullptr; - } + void WebView::setJavascriptInterfaceScheme(const std::string &scheme) + { + _impl->setJavascriptInterfaceScheme(scheme); + } - void WebView::setJavascriptInterfaceScheme(const std::string &scheme) - { - _impl->setJavascriptInterfaceScheme(scheme); - } + void WebView::loadData(const cocos2d::Data &data, + const std::string &MIMEType, + const std::string &encoding, + const std::string &baseURL) + { + _impl->loadData(data, MIMEType, encoding, baseURL); + } - void WebView::loadData(const cocos2d::Data &data, - const std::string &MIMEType, - const std::string &encoding, - const std::string &baseURL) - { - _impl->loadData(data, MIMEType, encoding, baseURL); - } + void WebView::loadHTMLString(const std::string &string, const std::string &baseURL) + { + _impl->loadHTMLString(string, baseURL); + } - void WebView::loadHTMLString(const std::string &string, const std::string &baseURL) - { - _impl->loadHTMLString(string, baseURL); - } + void WebView::loadURL(const std::string &url) + { + this->loadURL(url, false); + } - void WebView::loadURL(const std::string &url) - { - this->loadURL(url, false); - } + void WebView::loadURL(const std::string& url, bool cleanCachedData) + { + _impl->loadURL(url, cleanCachedData); + } - void WebView::loadURL(const std::string& url, bool cleanCachedData) - { - _impl->loadURL(url, cleanCachedData); - } + void WebView::loadFile(const std::string &fileName) + { + _impl->loadFile(fileName); + } - void WebView::loadFile(const std::string &fileName) - { - _impl->loadFile(fileName); - } + void WebView::stopLoading() + { + _impl->stopLoading(); + } - void WebView::stopLoading() - { - _impl->stopLoading(); - } + void WebView::reload() + { + _impl->reload(); + } - void WebView::reload() - { - _impl->reload(); - } + bool WebView::canGoBack() + { + return _impl->canGoBack(); + } - bool WebView::canGoBack() - { - return _impl->canGoBack(); - } + bool WebView::canGoForward() + { + return _impl->canGoForward(); + } - bool WebView::canGoForward() - { - return _impl->canGoForward(); - } + void WebView::goBack() + { + _impl->goBack(); + } - void WebView::goBack() - { - _impl->goBack(); - } + void WebView::goForward() + { + _impl->goForward(); + } - void WebView::goForward() - { - _impl->goForward(); - } + void WebView::evaluateJS(const std::string &js) + { + _impl->evaluateJS(js); + } - void WebView::evaluateJS(const std::string &js) - { - _impl->evaluateJS(js); - } + void WebView::setScalesPageToFit(bool const scalesPageToFit) + { + _impl->setScalesPageToFit(scalesPageToFit); + } - void WebView::setScalesPageToFit(bool const scalesPageToFit) - { - _impl->setScalesPageToFit(scalesPageToFit); - } + void WebView::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) + { + cocos2d::ui::Widget::draw(renderer, transform, flags); + _impl->draw(renderer, transform, flags); + } - void WebView::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) + void WebView::setVisible(bool visible) + { + Node::setVisible(visible); + if (!visible || isRunning()) { - cocos2d::ui::Widget::draw(renderer, transform, flags); - _impl->draw(renderer, transform, flags); + _impl->setVisible(visible); } + } + + void WebView::setOpacityWebView(float opacity){ + _impl->setOpacityWebView(opacity); + } + + float WebView::getOpacityWebView() const{ + return _impl->getOpacityWebView(); + } + + void WebView::setBackgroundTransparent() + { + _impl->setBackgroundTransparent(); + }; - void WebView::setVisible(bool visible) + void WebView::onEnter() + { + Widget::onEnter(); + if(isVisible()) { - Node::setVisible(visible); - if (!visible || isRunning()) - { - _impl->setVisible(visible); - } + _impl->setVisible(true); } - - void WebView::setOpacityWebView(float opacity){ - _impl->setOpacityWebView(opacity); - } - - float WebView::getOpacityWebView() const{ - return _impl->getOpacityWebView(); - } - - void WebView::setBackgroundTransparent() - { - _impl->setBackgroundTransparent(); - }; + } - void WebView::onEnter() - { - Widget::onEnter(); - if(isVisible()) - { - _impl->setVisible(true); - } - } + void WebView::onExit() + { + Widget::onExit(); + _impl->setVisible(false); + } + + void WebView::setBounces(bool bounces) + { + _impl->setBounces(bounces); + } + + cocos2d::ui::Widget* WebView::createCloneInstance() + { + return WebView::create(); + } - void WebView::onExit() + void WebView::copySpecialProperties(Widget* model) + { + WebView* webView = dynamic_cast(model); + if (webView) { - Widget::onExit(); - _impl->setVisible(false); - } - - void WebView::setBounces(bool bounces) - { - _impl->setBounces(bounces); - } - - cocos2d::ui::Widget* WebView::createCloneInstance() - { - return WebView::create(); + this->_impl = webView->_impl; + this->_onShouldStartLoading = webView->_onShouldStartLoading; + this->_onDidFinishLoading = webView->_onDidFinishLoading; + this->_onDidFailLoading = webView->_onDidFailLoading; + this->_onJSCallback = webView->_onJSCallback; } + } - void WebView::copySpecialProperties(Widget* model) - { - WebView* webView = dynamic_cast(model); - if (webView) - { - this->_impl = webView->_impl; - this->_onShouldStartLoading = webView->_onShouldStartLoading; - this->_onDidFinishLoading = webView->_onDidFinishLoading; - this->_onDidFailLoading = webView->_onDidFailLoading; - this->_onJSCallback = webView->_onJSCallback; - } - } + void WebView::setOnDidFailLoading(const ccWebViewCallback &callback) + { + _onDidFailLoading = callback; + } - void WebView::setOnDidFailLoading(const ccWebViewCallback &callback) - { - _onDidFailLoading = callback; - } + void WebView::setOnDidFinishLoading(const ccWebViewCallback &callback) + { + _onDidFinishLoading = callback; + } - void WebView::setOnDidFinishLoading(const ccWebViewCallback &callback) - { - _onDidFinishLoading = callback; - } + void WebView::setOnShouldStartLoading(const std::function &callback) + { + _onShouldStartLoading = callback; + } - void WebView::setOnShouldStartLoading(const std::function &callback) - { - _onShouldStartLoading = callback; - } + void WebView::setOnJSCallback(const ccWebViewCallback &callback) + { + _onJSCallback = callback; + } - void WebView::setOnJSCallback(const ccWebViewCallback &callback) - { - _onJSCallback = callback; - } + std::function WebView::getOnShouldStartLoading()const + { + return _onShouldStartLoading; + } - std::function WebView::getOnShouldStartLoading()const - { - return _onShouldStartLoading; - } + WebView::ccWebViewCallback WebView::getOnDidFailLoading()const + { + return _onDidFailLoading; + } - WebView::ccWebViewCallback WebView::getOnDidFailLoading()const - { - return _onDidFailLoading; - } + WebView::ccWebViewCallback WebView::getOnDidFinishLoading()const + { + return _onDidFinishLoading; + } - WebView::ccWebViewCallback WebView::getOnDidFinishLoading()const - { - return _onDidFinishLoading; - } + WebView::ccWebViewCallback WebView::getOnJSCallback()const + { + return _onJSCallback; + } - WebView::ccWebViewCallback WebView::getOnJSCallback()const - { - return _onJSCallback; - } - - } // namespace ui -} // namespace experimental +} // namespace ui } //namespace cocos2d /// @endcond diff --git a/cocos/ui/UIWebView/UIWebView.cpp b/cocos/ui/UIWebView/UIWebView.cpp index 937a8445d7..d8a7e30bcf 100644 --- a/cocos/ui/UIWebView/UIWebView.cpp +++ b/cocos/ui/UIWebView/UIWebView.cpp @@ -22,11 +22,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "platform/CCPlatformConfig.h" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - #include "ui/UIWebView/UIWebViewImpl-android.h" #include "ui/UIWebView/UIWebView-inl.h" - -#endif diff --git a/cocos/ui/UIWebView/UIWebView.h b/cocos/ui/UIWebView/UIWebView.h index b9dd65af33..1d97be01af 100644 --- a/cocos/ui/UIWebView/UIWebView.h +++ b/cocos/ui/UIWebView/UIWebView.h @@ -22,15 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __COCOS2D_UI_WEBVIEW_H -#define __COCOS2D_UI_WEBVIEW_H - -#include "platform/CCPlatformConfig.h" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_PLATFORM_OS_TVOS) - - +#pragma once #include "ui/UIWidget.h" #include "ui/GUIExport.h" @@ -42,8 +34,7 @@ */ NS_CC_BEGIN -namespace experimental{ - namespace ui{ +namespace ui{ class WebViewImpl; @@ -238,13 +229,10 @@ protected: virtual cocos2d::ui::Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; - std::function _onShouldStartLoading; - - ccWebViewCallback _onDidFinishLoading; - - ccWebViewCallback _onDidFailLoading; - - ccWebViewCallback _onJSCallback; + std::function _onShouldStartLoading = nullptr; + ccWebViewCallback _onDidFinishLoading = nullptr; + ccWebViewCallback _onDidFailLoading = nullptr; + ccWebViewCallback _onJSCallback = nullptr; CC_CONSTRUCTOR_ACCESS: /** @@ -258,15 +246,12 @@ CC_CONSTRUCTOR_ACCESS: virtual ~WebView(); private: - WebViewImpl *_impl; + WebViewImpl *_impl = nullptr; friend class WebViewImpl; }; - } // namespace ui - } // namespace experimental +} // namespace ui }//namespace cocos2d -#endif // end group /// @} -#endif //__COCOS2D_UI_WEBVIEW_H diff --git a/cocos/ui/UIWebView/UIWebView.mm b/cocos/ui/UIWebView/UIWebView.mm index e639a3a91f..31a5694674 100644 --- a/cocos/ui/UIWebView/UIWebView.mm +++ b/cocos/ui/UIWebView/UIWebView.mm @@ -23,11 +23,5 @@ THE SOFTWARE. ****************************************************************************/ -#include "platform/CCPlatformConfig.h" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_PLATFORM_OS_TVOS) - #include "ui/UIWebView/UIWebViewImpl-ios.h" #include "ui/UIWebView/UIWebView-inl.h" - -#endif diff --git a/cocos/ui/UIWebView/UIWebViewImpl-android.cpp b/cocos/ui/UIWebView/UIWebViewImpl-android.cpp index e8fe07fe1d..e307cadc72 100644 --- a/cocos/ui/UIWebView/UIWebViewImpl-android.cpp +++ b/cocos/ui/UIWebView/UIWebViewImpl-android.cpp @@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifdef __ANDROID__ - #include "ui/UIWebView/UIWebViewImpl-android.h" #include @@ -85,7 +82,7 @@ extern "C" { auto charUrl = env->GetStringUTFChars(jurl, NULL); std::string url = charUrl; env->ReleaseStringUTFChars(jurl, charUrl); - return cocos2d::experimental::ui::WebViewImpl::shouldStartLoading(index, url); + return cocos2d::ui::WebViewImpl::shouldStartLoading(index, url); } /* @@ -98,7 +95,7 @@ extern "C" { auto charUrl = env->GetStringUTFChars(jurl, NULL); std::string url = charUrl; env->ReleaseStringUTFChars(jurl, charUrl); - cocos2d::experimental::ui::WebViewImpl::didFinishLoading(index, url); + cocos2d::ui::WebViewImpl::didFinishLoading(index, url); } /* @@ -111,7 +108,7 @@ extern "C" { auto charUrl = env->GetStringUTFChars(jurl, NULL); std::string url = charUrl; env->ReleaseStringUTFChars(jurl, charUrl); - cocos2d::experimental::ui::WebViewImpl::didFailLoading(index, url); + cocos2d::ui::WebViewImpl::didFailLoading(index, url); } /* @@ -124,7 +121,7 @@ extern "C" { auto charMessage = env->GetStringUTFChars(jmessage, NULL); std::string message = charMessage; env->ReleaseStringUTFChars(jmessage, charMessage); - cocos2d::experimental::ui::WebViewImpl::onJsCallback(index, message); + cocos2d::ui::WebViewImpl::onJsCallback(index, message); } } @@ -159,152 +156,148 @@ std::string getUrlStringByFileName(const std::string &fileName) { } // namespace namespace cocos2d { - namespace experimental { - namespace ui{ +namespace ui{ - static std::unordered_map s_WebViewImpls; + static std::unordered_map s_WebViewImpls; - WebViewImpl::WebViewImpl(WebView *webView) : _viewTag(-1), _webView(webView) { - _viewTag = createWebViewJNI(); - s_WebViewImpls[_viewTag] = this; + WebViewImpl::WebViewImpl(WebView *webView) : _viewTag(-1), _webView(webView) { + _viewTag = createWebViewJNI(); + s_WebViewImpls[_viewTag] = this; + } + + WebViewImpl::~WebViewImpl() { + JniHelper::callStaticVoidMethod(className, "removeWebView", _viewTag); + s_WebViewImpls.erase(_viewTag); + } + + void WebViewImpl::loadData(const Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL) { + std::string dataString(reinterpret_cast(data.getBytes()), static_cast(data.getSize())); + JniHelper::callStaticVoidMethod(className, "setJavascriptInterfaceScheme", _viewTag, dataString, MIMEType, encoding, baseURL); + } + + void WebViewImpl::loadHTMLString(const std::string &string, const std::string &baseURL) { + JniHelper::callStaticVoidMethod(className, "loadHTMLString", _viewTag, string, getFixedBaseUrl(baseURL)); + } + + void WebViewImpl::loadURL(const std::string &url) { + this->loadURL(url, false); + } + + void WebViewImpl::loadURL(const std::string &url, bool cleanCachedData) { + JniHelper::callStaticVoidMethod(className, "loadUrl", _viewTag, url, cleanCachedData); + } + + void WebViewImpl::loadFile(const std::string &fileName) { + auto fullPath = getUrlStringByFileName(fileName); + JniHelper::callStaticVoidMethod(className, "loadFile", _viewTag, fullPath); + } + + void WebViewImpl::stopLoading() { + JniHelper::callStaticVoidMethod(className, "stopLoading", _viewTag); + } + + void WebViewImpl::reload() { + JniHelper::callStaticVoidMethod(className, "reload", _viewTag); + } + + bool WebViewImpl::canGoBack() { + return JniHelper::callStaticBooleanMethod(className, "canGoBack", _viewTag); + } + + bool WebViewImpl::canGoForward() { + return JniHelper::callStaticBooleanMethod(className, "canGoForward", _viewTag); + } + + void WebViewImpl::goBack() { + JniHelper::callStaticVoidMethod(className, "goBack", _viewTag); + } + + void WebViewImpl::goForward() { + JniHelper::callStaticVoidMethod(className, "goForward", _viewTag); + } + + void WebViewImpl::setJavascriptInterfaceScheme(const std::string &scheme) { + JniHelper::callStaticVoidMethod(className, "setJavascriptInterfaceScheme", _viewTag, scheme); + } + + void WebViewImpl::evaluateJS(const std::string &js) { + JniHelper::callStaticVoidMethod(className, "evaluateJS", _viewTag, js); + } + + void WebViewImpl::setScalesPageToFit(const bool scalesPageToFit) { + JniHelper::callStaticVoidMethod(className, "setScalesPageToFit", _viewTag, scalesPageToFit); + } + + bool WebViewImpl::shouldStartLoading(const int viewTag, const std::string &url) { + bool allowLoad = true; + auto it = s_WebViewImpls.find(viewTag); + if (it != s_WebViewImpls.end()) { + auto webView = it->second->_webView; + if (webView->_onShouldStartLoading) { + allowLoad = webView->_onShouldStartLoading(webView, url); } + } + return allowLoad; + } - WebViewImpl::~WebViewImpl() { - JniHelper::callStaticVoidMethod(className, "removeWebView", _viewTag); - s_WebViewImpls.erase(_viewTag); + void WebViewImpl::didFinishLoading(const int viewTag, const std::string &url){ + auto it = s_WebViewImpls.find(viewTag); + if (it != s_WebViewImpls.end()) { + auto webView = it->second->_webView; + if (webView->_onDidFinishLoading) { + webView->_onDidFinishLoading(webView, url); } + } + } - void WebViewImpl::loadData(const Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL) { - std::string dataString(reinterpret_cast(data.getBytes()), static_cast(data.getSize())); - JniHelper::callStaticVoidMethod(className, "setJavascriptInterfaceScheme", _viewTag, dataString, MIMEType, encoding, baseURL); + void WebViewImpl::didFailLoading(const int viewTag, const std::string &url){ + auto it = s_WebViewImpls.find(viewTag); + if (it != s_WebViewImpls.end()) { + auto webView = it->second->_webView; + if (webView->_onDidFailLoading) { + webView->_onDidFailLoading(webView, url); } + } + } - void WebViewImpl::loadHTMLString(const std::string &string, const std::string &baseURL) { - JniHelper::callStaticVoidMethod(className, "loadHTMLString", _viewTag, string, getFixedBaseUrl(baseURL)); + void WebViewImpl::onJsCallback(const int viewTag, const std::string &message){ + auto it = s_WebViewImpls.find(viewTag); + if (it != s_WebViewImpls.end()) { + auto webView = it->second->_webView; + if (webView->_onJSCallback) { + webView->_onJSCallback(webView, message); } + } + } - void WebViewImpl::loadURL(const std::string &url) { - this->loadURL(url, false); - } + void WebViewImpl::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) { + if (flags & cocos2d::Node::FLAGS_TRANSFORM_DIRTY) { + auto uiRect = cocos2d::ui::Helper::convertBoundingBoxToScreen(_webView); + JniHelper::callStaticVoidMethod(className, "setWebViewRect", _viewTag, + (int)uiRect.origin.x, (int)uiRect.origin.y, + (int)uiRect.size.width, (int)uiRect.size.height); + } + } - void WebViewImpl::loadURL(const std::string &url, bool cleanCachedData) { - JniHelper::callStaticVoidMethod(className, "loadUrl", _viewTag, url, cleanCachedData); - } + void WebViewImpl::setVisible(bool visible) { + JniHelper::callStaticVoidMethod(className, "setVisible", _viewTag, visible); + } + + void WebViewImpl::setOpacityWebView(const float opacity){ + JniHelper::callStaticVoidMethod(className, "setOpacityWebView", _viewTag, opacity); + }; + + + float WebViewImpl::getOpacityWebView()const{ + return JniHelper::callStaticFloatMethod(className, "getOpacityWebView", _viewTag); + }; + + void WebViewImpl::setBackgroundTransparent(){ + JniHelper::callStaticVoidMethod(className, "setBackgroundTransparent", _viewTag); + }; - void WebViewImpl::loadFile(const std::string &fileName) { - auto fullPath = getUrlStringByFileName(fileName); - JniHelper::callStaticVoidMethod(className, "loadFile", _viewTag, fullPath); - } - - void WebViewImpl::stopLoading() { - JniHelper::callStaticVoidMethod(className, "stopLoading", _viewTag); - } - - void WebViewImpl::reload() { - JniHelper::callStaticVoidMethod(className, "reload", _viewTag); - } - - bool WebViewImpl::canGoBack() { - return JniHelper::callStaticBooleanMethod(className, "canGoBack", _viewTag); - } - - bool WebViewImpl::canGoForward() { - return JniHelper::callStaticBooleanMethod(className, "canGoForward", _viewTag); - } - - void WebViewImpl::goBack() { - JniHelper::callStaticVoidMethod(className, "goBack", _viewTag); - } - - void WebViewImpl::goForward() { - JniHelper::callStaticVoidMethod(className, "goForward", _viewTag); - } - - void WebViewImpl::setJavascriptInterfaceScheme(const std::string &scheme) { - JniHelper::callStaticVoidMethod(className, "setJavascriptInterfaceScheme", _viewTag, scheme); - } - - void WebViewImpl::evaluateJS(const std::string &js) { - JniHelper::callStaticVoidMethod(className, "evaluateJS", _viewTag, js); - } - - void WebViewImpl::setScalesPageToFit(const bool scalesPageToFit) { - JniHelper::callStaticVoidMethod(className, "setScalesPageToFit", _viewTag, scalesPageToFit); - } - - bool WebViewImpl::shouldStartLoading(const int viewTag, const std::string &url) { - bool allowLoad = true; - auto it = s_WebViewImpls.find(viewTag); - if (it != s_WebViewImpls.end()) { - auto webView = it->second->_webView; - if (webView->_onShouldStartLoading) { - allowLoad = webView->_onShouldStartLoading(webView, url); - } - } - return allowLoad; - } - - void WebViewImpl::didFinishLoading(const int viewTag, const std::string &url){ - auto it = s_WebViewImpls.find(viewTag); - if (it != s_WebViewImpls.end()) { - auto webView = it->second->_webView; - if (webView->_onDidFinishLoading) { - webView->_onDidFinishLoading(webView, url); - } - } - } - - void WebViewImpl::didFailLoading(const int viewTag, const std::string &url){ - auto it = s_WebViewImpls.find(viewTag); - if (it != s_WebViewImpls.end()) { - auto webView = it->second->_webView; - if (webView->_onDidFailLoading) { - webView->_onDidFailLoading(webView, url); - } - } - } - - void WebViewImpl::onJsCallback(const int viewTag, const std::string &message){ - auto it = s_WebViewImpls.find(viewTag); - if (it != s_WebViewImpls.end()) { - auto webView = it->second->_webView; - if (webView->_onJSCallback) { - webView->_onJSCallback(webView, message); - } - } - } - - void WebViewImpl::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) { - if (flags & cocos2d::Node::FLAGS_TRANSFORM_DIRTY) { - auto uiRect = cocos2d::ui::Helper::convertBoundingBoxToScreen(_webView); - JniHelper::callStaticVoidMethod(className, "setWebViewRect", _viewTag, - (int)uiRect.origin.x, (int)uiRect.origin.y, - (int)uiRect.size.width, (int)uiRect.size.height); - } - } - - void WebViewImpl::setVisible(bool visible) { - JniHelper::callStaticVoidMethod(className, "setVisible", _viewTag, visible); - } - - void WebViewImpl::setOpacityWebView(const float opacity){ - JniHelper::callStaticVoidMethod(className, "setOpacityWebView", _viewTag, opacity); - }; - - - float WebViewImpl::getOpacityWebView()const{ - return JniHelper::callStaticFloatMethod(className, "getOpacityWebView", _viewTag); - }; - - void WebViewImpl::setBackgroundTransparent(){ - JniHelper::callStaticVoidMethod(className, "setBackgroundTransparent", _viewTag); - }; - - void WebViewImpl::setBounces(bool bounces) { - // empty function as this was mainly a fix for iOS - } - } // namespace ui - } // namespace experimental + void WebViewImpl::setBounces(bool bounces) { + // empty function as this was mainly a fix for iOS + } +} // namespace ui } //namespace cocos2d - -#endif // __ANDROID__ diff --git a/cocos/ui/UIWebView/UIWebViewImpl-android.h b/cocos/ui/UIWebView/UIWebViewImpl-android.h index 14cd172733..b77fd5becb 100644 --- a/cocos/ui/UIWebView/UIWebViewImpl-android.h +++ b/cocos/ui/UIWebView/UIWebViewImpl-android.h @@ -22,13 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#pragma once -#ifndef __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_ -#define __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_ /// @cond DO_NOT_SHOW -#ifdef __ANDROID__ - #include #include @@ -37,77 +34,71 @@ namespace cocos2d { class Renderer; class Mat4; - namespace experimental { - namespace ui{ - class WebView; - } + namespace ui{ + class WebView; } } namespace cocos2d { - namespace experimental { - namespace ui{ +namespace ui{ - class WebViewImpl { - public: - WebViewImpl(cocos2d::experimental::ui::WebView *webView); + class WebViewImpl { + public: + WebViewImpl(cocos2d::ui::WebView *webView); - virtual ~WebViewImpl(); + virtual ~WebViewImpl(); - void setJavascriptInterfaceScheme(const std::string &scheme); + void setJavascriptInterfaceScheme(const std::string &scheme); - void loadData(const cocos2d::Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL); + void loadData(const cocos2d::Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL); - void loadHTMLString(const std::string &string, const std::string &baseURL); + void loadHTMLString(const std::string &string, const std::string &baseURL); - void loadURL(const std::string &url); - void loadURL(const std::string &url, bool cleanCachedData); + void loadURL(const std::string &url); + void loadURL(const std::string &url, bool cleanCachedData); - void loadFile(const std::string &fileName); + void loadFile(const std::string &fileName); - void stopLoading(); + void stopLoading(); - void reload(); + void reload(); - bool canGoBack(); + bool canGoBack(); - bool canGoForward(); + bool canGoForward(); - void goBack(); + void goBack(); - void goForward(); + void goForward(); - void evaluateJS(const std::string &js); + void evaluateJS(const std::string &js); - void setScalesPageToFit(const bool scalesPageToFit); + void setScalesPageToFit(const bool scalesPageToFit); - virtual void draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags); + virtual void draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags); - virtual void setVisible(bool visible); + virtual void setVisible(bool visible); - void setBounces(bool bounces); - - void setOpacityWebView(float opacity); - - float getOpacityWebView()const; - - void setBackgroundTransparent(); + void setBounces(bool bounces); + + void setOpacityWebView(float opacity); + + float getOpacityWebView()const; + + void setBackgroundTransparent(); - static bool shouldStartLoading(const int viewTag, const std::string &url); - static void didFinishLoading(const int viewTag, const std::string &url); - static void didFailLoading(const int viewTag, const std::string &url); - static void onJsCallback(const int viewTag, const std::string &message); + static bool shouldStartLoading(const int viewTag, const std::string &url); + static void didFinishLoading(const int viewTag, const std::string &url); + static void didFailLoading(const int viewTag, const std::string &url); + static void onJsCallback(const int viewTag, const std::string &message); - private: - int _viewTag; - WebView *_webView; - }; + private: + int _viewTag; + WebView *_webView; + }; - } // namespace ui - } // namespace experimental +} // namespace ui } //cocos2d -#endif // __ANDROID__ /// @endcond -#endif /* __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_ */ diff --git a/cocos/ui/UIWebView/UIWebViewImpl-ios.h b/cocos/ui/UIWebView/UIWebViewImpl-ios.h index 74603987f9..d4ff5511cb 100644 --- a/cocos/ui/UIWebView/UIWebViewImpl-ios.h +++ b/cocos/ui/UIWebView/UIWebViewImpl-ios.h @@ -22,9 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#ifndef __COCOS2D_UI_WEBVIEWIMPL_IOS_H_ -#define __COCOS2D_UI_WEBVIEWIMPL_IOS_H_ +#pragma once /// @cond DO_NOT_SHOW #include @@ -37,9 +35,8 @@ namespace cocos2d { class Data; class Renderer; class Mat4; - -namespace experimental { - namespace ui{ + +namespace ui{ class WebView; @@ -97,8 +94,6 @@ private: }; } // namespace ui - } // namespace experimental }//namespace cocos2d /// @endcond -#endif /* __COCOS2D_UI_WEBVIEWIMPL_IOS_H_ */ diff --git a/cocos/ui/UIWebView/UIWebViewImpl-ios.mm b/cocos/ui/UIWebView/UIWebViewImpl-ios.mm index 339797b8ab..e2c448249e 100644 --- a/cocos/ui/UIWebView/UIWebViewImpl-ios.mm +++ b/cocos/ui/UIWebView/UIWebViewImpl-ios.mm @@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" - -// Webview not available on tvOS -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - #import #import #import @@ -88,7 +82,7 @@ @interface UIWebViewWrapper () -@property(nonatomic, retain) WKWebView *wkWebView; +@property(nonatomic) WKWebView *wkWebView; @property(nonatomic, copy) NSString *jsScheme; @end @@ -250,7 +244,7 @@ #pragma mark - WKNavigationDelegate - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { - NSString *url = [webView.URL absoluteString]; + NSString *url = [[[navigationAction request] URL] absoluteString]; if ([[webView.URL scheme] isEqualToString:self.jsScheme]) { self.onJsCallback([url UTF8String]); decisionHandler(WKNavigationActionPolicyCancel); @@ -298,7 +292,7 @@ completionHandler(); }]]; - auto rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; + auto rootViewController = [UIApplication sharedApplication].windows[0].rootViewController; [rootViewController presentViewController:alertController animated:YES completion:^{}]; } @@ -307,8 +301,7 @@ namespace cocos2d { -namespace experimental { - namespace ui{ +namespace ui{ WebViewImpl::WebViewImpl(WebView *webView) : _uiWebViewWrapper([UIWebViewWrapper newWebViewWrapper]), @@ -451,8 +444,5 @@ void WebViewImpl::setBackgroundTransparent(){ } - } // namespace ui -} // namespace experimental +} // namespace ui } //namespace cocos2d - -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index da4ca4b805..c1cb9c7662 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -2,69 +2,37 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Cocos2d-x 3.17 Release Notes](#cocos2d-x-317-release-notes) - - [Android requirements](#android-requirements) +- [Cocos2d-x 4.0 Release Notes](#cocos2d-x-40-release-notes) - [Highlights](#highlights) - - [added support for iPhone X](#added-support-for-iphone-x) - - [added support Android Studio 3.0+](#added-support-android-studio-30) - - [CMake is now supported on all platforms](#cmake-is-now-supported-on-all-platforms) - - [upgrade 3rd-party libraries](#upgrade-3rd-party-libraries) - - [remove outdated](#remove-outdated) - - [misc bugs fix and stability improvements](#misc-bugs-fix-and-stability-improvements) + - [Documentation](#documentation) -# Cocos2d-x 3.17 Release Notes # -The 3.17 release focuses on stability and increased performance with some under the hood enhancements that will make cross-platform development easier. +# Cocos2d-x 4.0 Release Notes # -## Android requirements +This version is mainly to support metal on iOS/macOS. In order to support metal, this version does a big refactor of the rendering system. And this version also remove deprecated functions, so there are some API modification. -v3.17 has been tested using Android Studio (3.0, 3.1, 3.1.1) with NDK r16 +In order to help develpers easily update to v4, we wrote some documentations. These documentations can be found [here](https://docs.cocos.com/cocos2d-x/v4/manual/en/upgradeGuide/). ## Highlights -- added support for iPhone X -- added support Android Studio 3.0+ -- CMake is now supported on all platforms -- upgraded Spine runtime to v3.6.39 -- upgraded GLFW to 3.2.1 -- misc bugs fix and stability improvements +- support metal on iOS/macOS +- use CMake for all platforms +- update GLFW to 3.3 +- update minizip to 1.2 +- remove deprecated functions +- remove h5 engine and JSB +- remove tiff +- remove `SimpleAudioEngine` +- remove `experimetnal` namespace +- fix bug that system font can not work correctly on macOS15 +- fix lua crash issue on 64bit devices +- fix bugs for iOS13 + - UIWebView uses WKWebView instead + - VideoPlayer uses AVPlayerController instead -### added support for iPhone X +## Documentation -3.17 brings support for iPhone X including supporting full screen mode, using Storyboards for launch images, __safe area__ API and support for auto hiding the Home indicator. It is important to note exactly what and where the safe area is: - -

- -

- -Developers can get the safe area easily by calling: `Director::getSafeAreaRect()`. - -### added support Android Studio 3.0+ - -Android Studio is the only official IDE for Google's Android operating system. -Cocos2d-x supports Android Studio using NDK version r16 to r16. Gradle configurations have been updated, including simplifying Gradle PROP_* values, changing the deprecated `compile` to the new `implementation`in dependency declaration, and added Proguard configuration to reduce Release package size. - -### CMake is now supported on all platforms - -CMake is now supported on all platforms, including Android(NDK), iOS, macOS, Windows (VC++ compiler), Linux. Supports precompile libraries for engine, and reusing precompiled libraries in the new build process. Your projects build time will be greatly reduced. For detailed usage, please refer to [CMake Doc](https://github.com/cocos2d/cocos2d-x/blob/v3/cmake/README.md) - -### upgrade 3rd-party libraries - -Spine skeleton animation is widely used in games developed by Cocos2d-x. Spine runtime has been upgraded to 3.6.39 to keep current. - -GLFW has been upgraded to 3.2.1 to help fix joystick issues. You can also now use GLFW as a precompiled library. - -Box2D hasn't been updated in quite some time. A new production version has yet to be released so far in 2018. We felt GitHub commit f655c603ba9d83 was stable. You can also now use Box2D as a precompiled library. - -Each Cocos2d-x release comes with a specific version of third-party libraries. If you want to upgrade third-party libraries due to your projects needs, please refer to: [3rd-party Doc](https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src/blob/v3/README.md) - -### remove outdated - -Google officially deprecated ant build support starting in [Android SDK Tools 25.3.0](http://tools.android.com/recent/androidsdktoolsrevision2530feb2017). The old ant based `proj.android` and been dropped and now `proj.android` is an Android Studio project. The default architecture is changed from `armeabi` to `armeabi-v7a`. - -Visual Studio 2013 support has been dropped. Visual Studio 2015/2017 are still currently supported. The existing win32 project files is quite suitable for 2015. To use 2017, you can open a 2015 project file, modify the configuration to suit your needs, or use CMake (See above). - -### misc bugs fix and stability improvements - -This release contains more than 51 bugs fixed and 33 misc improvements, please refer to [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG) +We wrote some documentations to help developers upgrade to v4: +- [how to run tests and how to create a new project and run](https://docs.cocos2d-x.org/cocos2d-x/v4/en/installation/) +- [v4 updrade guide](https://docs.cocos2d-x.org/cocos2d-x/v4/en/upgradeGuide/) diff --git a/docs/RELEASE_NOTES_CN.md b/docs/RELEASE_NOTES_CN.md index e8cb6991cc..1c66622ae6 100644 --- a/docs/RELEASE_NOTES_CN.md +++ b/docs/RELEASE_NOTES_CN.md @@ -2,79 +2,33 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Cocos2d-x 3.17 Release Notes](#cocos2d-x-317-release-notes) - - [测试环境](#%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83) +- [Cocos2d-x v4 Release Notes](#cocos2d-x-v4-release-notes) - [版本特性](#%E7%89%88%E6%9C%AC%E7%89%B9%E6%80%A7) - - [详细介绍](#%E8%AF%A6%E7%BB%86%E4%BB%8B%E7%BB%8D) - - [支持 iPhone X](#%E6%94%AF%E6%8C%81-iphone-x) - - [支持 Android Studio 3.0+](#%E6%94%AF%E6%8C%81-android-studio-30) - - [CMake 支持全平台](#cmake-%E6%94%AF%E6%8C%81%E5%85%A8%E5%B9%B3%E5%8F%B0) - - [升级第三方库](#%E5%8D%87%E7%BA%A7%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93) - - [移除过时的内容](#%E7%A7%BB%E9%99%A4%E8%BF%87%E6%97%B6%E7%9A%84%E5%86%85%E5%AE%B9) - - [Bugs 修复,提高稳定性](#bugs-%E4%BF%AE%E5%A4%8D%E6%8F%90%E9%AB%98%E7%A8%B3%E5%AE%9A%E6%80%A7) + - [文档](#%E6%96%87%E6%A1%A3) -# Cocos2d-x 3.17 Release Notes # - -Cocos2d-x 3.17 版本着重于工具链的更新,和稳定性的增强。 - -## 测试环境 - - Android 平台使用 Android Studio (3.0, 3.1, 3.1.1) 和 NDK r16 进行测试。 +# Cocos2d-x v4 Release Notes # ## 版本特性 -- 支持 iPhone X -- 支持 Android Studio 3.0+ -- CMake 支持全平台,支持预编译引擎库 -- 升级 Spine runtime 至 v3.6.39 -- 升级 GLFW 至 3.2.1,并提供预编译库 -- 更新 Box2D,并提供预编译库 -- 去除 Android 的 ant 工程 -- 去除 Visual Studio 2013 的支持 +- iOS/macOS 支持 metal +- 使用 CMake,删除各平台的工程文件 +- 升级 GLFW 到 3.3 +- 升级 minizip 到 1.2 +- 删除废弃函数 +- 删除 h5 引擎和 Javascript 绑定 +- 删除 tiff +- 删除 `SimpleAudioEngine` +- 删除 `experimental` 名字空间 +- 修复 macOS 15 系统字体绘制问题 +- 适配 iOS13 + - UIWebView 使用 WKWebView 实现 + - VideoPlayer 使用 AVPlayerController 实现 +- 修复 lua 工程在 64 位设备的崩溃问题 -## 详细介绍 - -### 支持 iPhone X - -3.17 带来对 iPhone X 的支持,包含支持全屏模式,支持自动隐藏 Home 指示器,改用 Storyboard 作为启动屏幕,和增加获取 Safe Area 的接口。在开发支持 iPhone X 的应用时,最需要了解清楚的就是 Safe Area: - -

- -

- -开发者可以通过调用 `Director::getSafeAreaRect()` 来获取 Safe Area 区域。 - -### 支持 Android Studio 3.0+ - -Android Studio 是 Google 官方唯一支持的 Android 开发 IDE。 - -该版本增加了对 Android Studio 3.0+ 的支持。在支持的过程中,同时将 NDK 版本从 r14 升级到 r16。对 Gradle 工程配置也进行了诸多改进,包括简化 Gradle 变量 PROP_*,将依赖声明中弃用的 `compile` 改为新的 `implementation`,增加用以削减 Release 包体积的 Proguard 文件。 - -### CMake 支持全平台 - -扩展 CMake 构建支持至全平台,包括 Android (NDK)、iOS、macOS、Linux、Windows(VC++ compiler)。支持将引擎部分进行预编译,并在新的构建过程中重用预编译的引擎库。通过使用预编译库,可以极大的缩短工程构建时间。 - -详细的使用方法请参考 [CMake 文档](https://github.com/cocos2d/cocos2d-x/blob/v3/cmake/README.md) - -### 升级第三方库 - -Spine 骨骼动画广泛用于 Cocos2d-x 开发的游戏,引擎跟进 Spine 的升级,升级 Runtime 至 3.6.39。 - -升级 GLFW 至 3.2.1 以修复支持游戏手柄时存在的问题,同时提供 GLFW 预编译库。 - -社区希望引擎升级 Box2D,可 Box2D 的新版本迟迟未发布,根据反馈 GitHub 提交 f655c603ba9d83 是稳定的,升级 Box2D 至该提交,同时提供 Box2D 的预编译库。 - -每一次版本发布,都会附带特定版本的第三方预编译库,如果由于项目需要想对第三方库进行定制,请参考: [第三方库文档](https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src/blob/v3/README.md) - -### 移除过时的内容 - -由于 Google 官方自 [Android SDK Tools 25.3.0](http://tools.android.com/recent/androidsdktoolsrevision2530feb2017) 就已放弃 ant 支持。移除旧有的 `proj.android` ant 工程,新的 `proj.android` 是 Android Studio 工程。[NDK r16](https://developer.android.com/ndk/guides/abis) 弃用了 armeabi,引擎调整默认的编译架构从 armeabi 为 armeabi-v7a。 - -在 win32 平台,越来越多的开发者已经使用 Visual Studio 2015/2017 进行开发,移除对年代久远的 2013 的支持。现存的工程配置适合于 2015 ,如果需要使用 2017,可打开现有的 sln 文件,调整配置,或使用 CMake。 - -### Bugs 修复,提高稳定性 - -改版本包含 51 项 bugs 修复和 33 项小改进,不再列举,请参考 [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG)。 +## 文档 +编写了一些文档方便开发者升级到 v4: +- [如何运行测试例子,如何新建工程并运行](https://docs.cocos2d-x.org/cocos2d-x/v4/zn/installation) +- [v4 升级指南](https://docs.cocos2d-x.org/cocos2d-x/v4/en/upgradeGuide/) \ No newline at end of file diff --git a/docs/doxygen.config b/docs/doxygen.config index 629b0e73de..370e1e279f 100644 --- a/docs/doxygen.config +++ b/docs/doxygen.config @@ -38,7 +38,7 @@ PROJECT_NAME = Cocos2d-x # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v3.16 +PROJECT_NUMBER = v4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 19bc35847a..c183e41723 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -110,8 +110,8 @@ void ControlSaturationBrightnessPicker::updateWithHSV(HSV hsv) void ControlSaturationBrightnessPicker::updateDraggerWithHSV(HSV hsv) { // Set the position of the slider to the correct saturation and brightness - Vec2 pos(_startPos.x + boxPos + (boxSize*(1 - hsv.s)), - _startPos.y + boxPos + (boxSize*hsv.v)); + Vec2 pos(_startPos.x + boxPos + (boxSize*(1 - (float)hsv.s)), + _startPos.y + boxPos + (boxSize*(float)hsv.v)); // update updateSliderPosition(pos); diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index 647246d788..5602860a6f 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -424,7 +424,7 @@ bool ControlSwitch::onTouchBegan(Touch *pTouch, Event* /*pEvent*/) void ControlSwitch::onTouchMoved(Touch *pTouch, Event* /*pEvent*/) { Vec2 location = this->locationFromTouch(pTouch); - location = Vec2(location.x - _initialTouchXPosition, 0); + location = Vec2(location.x - _initialTouchXPosition, 0.0f); _moved = true; diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 0f43b667bc..2c22f7dee3 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -307,11 +307,11 @@ void TableView::_updateContentSize() { if (_direction == Direction::HORIZONTAL) { - this->setContentOffset(Vec2(0,0)); + this->setContentOffset(Vec2(0.0f,0.0f)); } else { - this->setContentOffset(Vec2(0,this->minContainerOffset().y)); + this->setContentOffset(Vec2(0.0f,this->minContainerOffset().y)); } _oldDirection = _direction; } diff --git a/extensions/Particle3D/CCParticle3DRender.cpp b/extensions/Particle3D/CCParticle3DRender.cpp index ec498822a0..e2942e8353 100755 --- a/extensions/Particle3D/CCParticle3DRender.cpp +++ b/extensions/Particle3D/CCParticle3DRender.cpp @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "extensions/Particle3D/CCParticleSystem3D.h" +#include // offsetof +#include "base/ccTypes.h" #include "extensions/Particle3D/CCParticle3DRender.h" #include "renderer/CCMeshCommand.h" #include "renderer/CCRenderer.h" @@ -194,13 +195,15 @@ bool Particle3DQuadRender::initQuadRender( const std::string& texFile ) if (tex) { _texture = tex; - _programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::PARTICLE_TEXTURE_3D); + _programState = new backend::ProgramState(program); } } if (!_programState) { - _programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::PARTICLE_COLOR_3D); + _programState = new backend::ProgramState(program); } auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor(); diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.cpp b/extensions/Particle3D/PU/CCPUBillboardChain.cpp index 17247197ee..8515820493 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.cpp +++ b/extensions/Particle3D/PU/CCPUBillboardChain.cpp @@ -23,8 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "extensions/Particle3D/PU/CCPUBillboardChain.h" +#include // offsetof +#include "base/ccTypes.h" #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h" #include "base/CCDirector.h" #include "renderer/ccShaders.h" @@ -655,13 +656,15 @@ void PUBillboardChain::init( const std::string &texFile ) if (tex) { _texture = tex; - _programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::PARTICLE_TEXTURE_3D); + _programState = new backend::ProgramState(program); } } if(!_programState) { - _programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::PARTICLE_COLOR_3D); + _programState = new backend::ProgramState(program); } auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor(); diff --git a/extensions/Particle3D/PU/CCPURender.cpp b/extensions/Particle3D/PU/CCPURender.cpp index 9c7cd87907..1b0dea701b 100644 --- a/extensions/Particle3D/PU/CCPURender.cpp +++ b/extensions/Particle3D/PU/CCPURender.cpp @@ -23,8 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #include "extensions/Particle3D/CCParticleSystem3D.h" +#include // offsetof +#include "base/ccTypes.h" #include "extensions/Particle3D/PU/CCPURender.h" #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h" #include "extensions/Particle3D/PU/CCPUUtil.h" @@ -592,13 +593,15 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile ) if (tex) { _texture = tex; - _programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleTexture_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::PARTICLE_TEXTURE_3D); + _programState = new backend::ProgramState(program); } } if (!_programState) { - _programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleColor_frag); + auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::PARTICLE_COLOR_3D); + _programState = new backend::ProgramState(program); } auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor(); diff --git a/external/config.json b/external/config.json index 255e47c604..507ce0d567 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version": "metal-support-15", + "version": "metal-support-22", "zip_file_size": "146254799", "repo_name": "cocos2d-x-3rd-party-libs-bin", "repo_parent": "https://github.com/cocos2d/", diff --git a/install-deps-linux.sh b/install-deps-linux.sh index cf6bab4dae..1de5606128 100755 --- a/install-deps-linux.sh +++ b/install-deps-linux.sh @@ -11,13 +11,19 @@ fi sudo apt-get update -DEPENDS='libx11-dev' +# run 32bit applicatio: needed for lua relase mode as luajit has 32bit version +# https://askubuntu.com/questions/454253/how-to-run-32-bit-app-in-ubuntu-64-bit +sudo dpkg --add-architecture i386 +DEPENDS='libc6:i386 libncurses5:i386 libstdc++6:i386' + + +DEPENDS+=' libx11-dev' DEPENDS+=' libxmu-dev' DEPENDS+=' libglu1-mesa-dev' DEPENDS+=' libgl2ps-dev' DEPENDS+=' libxi-dev' DEPENDS+=' libzip-dev' -DEPENDS+=' libpng12-dev' +DEPENDS+=' libpng-dev' DEPENDS+=' libcurl4-gnutls-dev' DEPENDS+=' libfontconfig1-dev' DEPENDS+=' libsqlite3-dev' diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 008e06e4c8..0d5a48b29d 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -27,8 +27,9 @@ "cmake/Modules/Findflatbuffers.cmake", "cmake/Modules/Findxxhash.cmake", "cmake/Modules/PreventInSourceBuilds.cmake", - "cmake/Modules/iOSBundleInfo.plist.in", "cmake/README.md", + "cmake/images/Xcode_Find_Setting_Name.png", + "cmake/images/Xcode_General_Page.png", "cocos/2d/CCAction.cpp", "cocos/2d/CCAction.h", "cocos/2d/CCActionCamera.cpp", @@ -929,8 +930,6 @@ "cocos/platform/apple/CCDevice-apple.mm", "cocos/platform/apple/CCFileUtils-apple.h", "cocos/platform/apple/CCFileUtils-apple.mm", - "cocos/platform/apple/CCLock-apple.cpp", - "cocos/platform/apple/CCLock-apple.h", "cocos/platform/desktop/CCGLViewImpl-desktop.cpp", "cocos/platform/desktop/CCGLViewImpl-desktop.h", "cocos/platform/ios/CCApplication-ios.h", @@ -941,13 +940,13 @@ "cocos/platform/ios/CCDirectorCaller-ios.mm", "cocos/platform/ios/CCEAGLView-ios.h", "cocos/platform/ios/CCEAGLView-ios.mm", - "cocos/platform/ios/CCGL-ios.h", "cocos/platform/ios/CCGLViewImpl-ios.h", "cocos/platform/ios/CCGLViewImpl-ios.mm", "cocos/platform/ios/CCImage-ios.mm", + "cocos/platform/ios/CCInputView-ios.h", + "cocos/platform/ios/CCInputView-ios.mm", "cocos/platform/ios/CCPlatformDefine-ios.h", "cocos/platform/ios/CCStdC-ios.h", - "cocos/platform/ios/OpenGL_Internal-ios.h", "cocos/platform/ios/cocos2d-prefix.pch", "cocos/platform/linux/CCApplication-linux.cpp", "cocos/platform/linux/CCApplication-linux.h", @@ -957,13 +956,11 @@ "cocos/platform/linux/CCFileUtils-linux.h", "cocos/platform/linux/CCGL-linux.h", "cocos/platform/linux/CCPlatformDefine-linux.h", - "cocos/platform/linux/CCStdC-linux.cpp", "cocos/platform/linux/CCStdC-linux.h", "cocos/platform/mac/CCApplication-mac.h", "cocos/platform/mac/CCApplication-mac.mm", "cocos/platform/mac/CCCommon-mac.mm", "cocos/platform/mac/CCDevice-mac.mm", - "cocos/platform/mac/CCGL-mac.h", "cocos/platform/mac/CCGLViewImpl-mac.h", "cocos/platform/mac/CCGLViewImpl-mac.mm", "cocos/platform/mac/CCPlatformDefine-mac.h", @@ -3808,12 +3805,6 @@ "cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_csloader_auto.cpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_csloader_auto.hpp", - "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp", - "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp", - "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp", - "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp", - "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.cpp", - "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_navmesh_auto.cpp", @@ -3828,6 +3819,10 @@ "cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp", + "cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.cpp", + "cocos/scripting/lua-bindings/auto/lua_cocos2dx_video_auto.hpp", + "cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.cpp", + "cocos/scripting/lua-bindings/auto/lua_cocos2dx_webview_auto.hpp", "cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp", "cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.h", "cocos/scripting/lua-bindings/manual/CCComponentLua.cpp", @@ -3851,8 +3846,6 @@ "cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.h", "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp", "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.h", - "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp", - "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.hpp", "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp", "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.hpp", "cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_physics_manual.cpp", @@ -3899,14 +3892,12 @@ "cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.hpp", "cocos/scripting/lua-bindings/manual/tolua_fix.cpp", "cocos/scripting/lua-bindings/manual/tolua_fix.h", - "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.cpp", - "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp", - "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.cpp", - "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.hpp", "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp", "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.hpp", - "cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.cpp", - "cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.hpp", + "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.cpp", + "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp", + "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.cpp", + "cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_webview_manual.hpp", "cocos/scripting/lua-bindings/proj.android/CMakeLists.txt", "cocos/scripting/lua-bindings/script/3d/3dConstants.lua", "cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua", @@ -3959,70 +3950,12 @@ "cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua", "cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua", "cocos/scripting/lua-bindings/script/ui/GuiConstants.lua", - "cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua", "external/lua/cjson/fpconv.c", "external/lua/cjson/fpconv.h", "external/lua/cjson/lua_cjson.c", "external/lua/cjson/lua_cjson.h", "external/lua/cjson/strbuf.c", "external/lua/cjson/strbuf.h", - "external/lua/lua/Android.mk", - "external/lua/lua/CMakeLists.txt", - "external/lua/lua/lapi.c", - "external/lua/lua/lapi.h", - "external/lua/lua/lauxlib.c", - "external/lua/lua/lauxlib.h", - "external/lua/lua/lbaselib.c", - "external/lua/lua/lcode.c", - "external/lua/lua/lcode.h", - "external/lua/lua/ldblib.c", - "external/lua/lua/ldebug.c", - "external/lua/lua/ldebug.h", - "external/lua/lua/ldo.c", - "external/lua/lua/ldo.h", - "external/lua/lua/ldump.c", - "external/lua/lua/lfunc.c", - "external/lua/lua/lfunc.h", - "external/lua/lua/lgc.c", - "external/lua/lua/lgc.h", - "external/lua/lua/linit.c", - "external/lua/lua/liolib.c", - "external/lua/lua/llex.c", - "external/lua/lua/llex.h", - "external/lua/lua/llimits.h", - "external/lua/lua/lmathlib.c", - "external/lua/lua/lmem.c", - "external/lua/lua/lmem.h", - "external/lua/lua/loadlib.c", - "external/lua/lua/lobject.c", - "external/lua/lua/lobject.h", - "external/lua/lua/lopcodes.c", - "external/lua/lua/lopcodes.h", - "external/lua/lua/loslib.c", - "external/lua/lua/lparser.c", - "external/lua/lua/lparser.h", - "external/lua/lua/lstate.c", - "external/lua/lua/lstate.h", - "external/lua/lua/lstring.c", - "external/lua/lua/lstring.h", - "external/lua/lua/lstrlib.c", - "external/lua/lua/ltable.c", - "external/lua/lua/ltable.h", - "external/lua/lua/ltablib.c", - "external/lua/lua/ltm.c", - "external/lua/lua/ltm.h", - "external/lua/lua/lua.c", - "external/lua/lua/lua.h", - "external/lua/lua/luaconf.h", - "external/lua/lua/lualib.h", - "external/lua/lua/lundump.c", - "external/lua/lua/lundump.h", - "external/lua/lua/lvm.c", - "external/lua/lua/lvm.h", - "external/lua/lua/lzio.c", - "external/lua/lua/lzio.h", - "external/lua/lua/prebuilt/ios/liblua.a", - "external/lua/lua/print.c", "external/lua/luajit/CMakeLists.txt", "external/lua/luajit/include/lauxlib.h", "external/lua/luajit/include/lua.h", @@ -4167,9 +4100,6 @@ "tools/tolua/cocos2dx_backend.ini", "tools/tolua/cocos2dx_controller.ini", "tools/tolua/cocos2dx_csloader.ini", - "tools/tolua/cocos2dx_experimental.ini", - "tools/tolua/cocos2dx_experimental_video.ini", - "tools/tolua/cocos2dx_experimental_webview.ini", "tools/tolua/cocos2dx_extension.ini", "tools/tolua/cocos2dx_navmesh.ini", "tools/tolua/cocos2dx_physics.ini", @@ -4177,6 +4107,8 @@ "tools/tolua/cocos2dx_spine.ini", "tools/tolua/cocos2dx_studio.ini", "tools/tolua/cocos2dx_ui.ini", + "tools/tolua/cocos2dx_video.ini", + "tools/tolua/cocos2dx_webview.ini", "tools/tolua/genbindings.py", "tools/tolua/userconf.ini" ] diff --git a/templates/cpp-template-default/CMakeLists.txt b/templates/cpp-template-default/CMakeLists.txt index 25416f543f..855de970b3 100644 --- a/templates/cpp-template-default/CMakeLists.txt +++ b/templates/cpp-template-default/CMakeLists.txt @@ -29,6 +29,12 @@ set(APP_NAME HelloCpp) project(${APP_NAME}) +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + if(NOT DEFINED BUILD_ENGINE_DONE) # to test HelloCpp into root project set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) @@ -133,16 +139,16 @@ target_include_directories(${APP_NAME} setup_cocos_app_config(${APP_NAME}) if(APPLE) set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}") + if(MACOSX) - set_target_properties(${APP_NAME} PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist" - ) + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist") elseif(IOS) - cocos_pak_xcode(${APP_NAME} INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist") + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon") - set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "") - set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer") endif() + + # For code-signing, set the DEVELOPMENT_TEAM: + #set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") elseif(WINDOWS) cocos_copy_target_dll(${APP_NAME}) endif() diff --git a/templates/cpp-template-default/proj.android/gradle.properties b/templates/cpp-template-default/proj.android/gradle.properties index 83d8774574..ebbe920606 100644 --- a/templates/cpp-template-default/proj.android/gradle.properties +++ b/templates/cpp-template-default/proj.android/gradle.properties @@ -37,4 +37,6 @@ PROP_APP_ABI=armeabi-v7a #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false diff --git a/templates/cpp-template-default/proj.ios_mac/ios/AppController.mm b/templates/cpp-template-default/proj.ios_mac/ios/AppController.mm index 18c90ebbfc..edcd92178a 100644 --- a/templates/cpp-template-default/proj.ios_mac/ios/AppController.mm +++ b/templates/cpp-template-default/proj.ios_mac/ios/AppController.mm @@ -73,6 +73,12 @@ static AppDelegate s_sharedApplication; [[UIApplication sharedApplication] setStatusBarHidden:true]; + //Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior. + if ( [[UIDevice currentDevice].systemVersion floatValue] >= 13.0f) + { + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"]; + } + // IMPORTANT: Setting the GLView should be done after creating the RootViewController cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView((__bridge void *)_viewController.view); cocos2d::Director::getInstance()->setOpenGLView(glview); diff --git a/templates/cpp-template-default/proj.ios_mac/ios/Info.plist b/templates/cpp-template-default/proj.ios_mac/ios/Info.plist index 8b4aea8f9b..739c1700a8 100644 --- a/templates/cpp-template-default/proj.ios_mac/ios/Info.plist +++ b/templates/cpp-template-default/proj.ios_mac/ios/Info.plist @@ -7,25 +7,23 @@ CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleIconFile Icon-57.png CFBundleIdentifier - org.cocos2dx.hellocpp + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} + ${PRODUCT_NAME} CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + 1.0 CFBundlePackageType APPL CFBundleSignature ???? CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + 1 LSRequiresIPhoneOS UIAppFonts @@ -42,6 +40,6 @@ UIInterfaceOrientationLandscapeLeft NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} + Copyright © 2019. All rights reserved. diff --git a/templates/lua-template-default/CMakeLists.txt b/templates/lua-template-default/CMakeLists.txt index a5c669fab1..4fdf2476b2 100644 --- a/templates/lua-template-default/CMakeLists.txt +++ b/templates/lua-template-default/CMakeLists.txt @@ -27,6 +27,12 @@ set(APP_NAME HelloLua) project(${APP_NAME}) +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + set(RUNTIME_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/runtime-src) set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/cocos2d-x) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) @@ -126,6 +132,9 @@ if(APPLE) set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${RUNTIME_SRC_ROOT}/proj.ios_mac/mac/Info.plist" ) + set_target_properties(${APP_NAME} PROPERTIES + LINK_FLAGS "-pagezero_size 10000 -image_base 100000000" + ) elseif(IOS) cocos_pak_xcode(${APP_NAME} INFO_PLIST "${RUNTIME_SRC_ROOT}/proj.ios_mac/ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon") diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/gradle.properties b/templates/lua-template-default/frameworks/runtime-src/proj.android/gradle.properties index 83d8774574..df277e6673 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/gradle.properties +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/gradle.properties @@ -37,4 +37,6 @@ PROP_APP_ABI=armeabi-v7a #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false \ No newline at end of file diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index 18c90ebbfc..8116adeba9 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -72,6 +72,12 @@ static AppDelegate s_sharedApplication; [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden:true]; + + //Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior. + if ( [[UIDevice currentDevice].systemVersion floatValue] >= 13.0f) + { + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"]; + } // IMPORTANT: Setting the GLView should be done after creating the RootViewController cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView((__bridge void *)_viewController.view); diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/Info.plist b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/Info.plist index 503a22c369..01667c8d0a 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/Info.plist +++ b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/ios/Info.plist @@ -7,21 +7,19 @@ CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleIconFile Icon-57.png CFBundleIdentifier - org.cocos2dx.hellolua + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + 1 CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} + ${PRODUCT_NAME} CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + 1.0 CFBundlePackageType APPL CFBundleSignature @@ -47,6 +45,6 @@ UIInterfaceOrientationLandscapeLeft NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} + Copyright © 2019. All rights reserved. diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index f72b36417b..7251aefce9 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile Icon CFBundleIdentifier - org.cocos2dx.hellolua + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,10 +24,8 @@ 1 LSApplicationCategoryType public.app-category.games - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright - Copyright © 2013. All rights reserved. + Copyright © 2019. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/tests/cpp-empty-test/CMakeLists.txt b/tests/cpp-empty-test/CMakeLists.txt index 92a5027e58..2628028508 100644 --- a/tests/cpp-empty-test/CMakeLists.txt +++ b/tests/cpp-empty-test/CMakeLists.txt @@ -27,6 +27,12 @@ set(APP_NAME cpp-empty-test) project(${APP_NAME}) +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + if(NOT DEFINED BUILD_ENGINE_DONE) set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) @@ -123,21 +129,19 @@ target_link_libraries(${APP_NAME} cocos2d) target_include_directories(${APP_NAME} PRIVATE Classes) -# mark app resources setup_cocos_app_config(${APP_NAME}) -if(APPLE) +if(XCODE) set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}") + if(MACOSX) - set_target_properties(${APP_NAME} PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.mac/Info.plist" - ) + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.mac/Info.plist") elseif(IOS) - cocos_pak_xcode(${APP_NAME} INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios/Info.plist") + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon-${APP_NAME}") - set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer") - set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "") - set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer") endif() + + # For code-signing, set the DEVELOPMENT_TEAM: + #set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") elseif(WINDOWS) cocos_copy_target_dll(${APP_NAME}) endif() diff --git a/tests/cpp-empty-test/Classes/HelloWorldScene.cpp b/tests/cpp-empty-test/Classes/HelloWorldScene.cpp index c781419915..912cd5b800 100644 --- a/tests/cpp-empty-test/Classes/HelloWorldScene.cpp +++ b/tests/cpp-empty-test/Classes/HelloWorldScene.cpp @@ -50,39 +50,35 @@ bool HelloWorld::init() // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. -// // add a "close" icon to exit the progress. it's an autorelease object -// auto closeItem = MenuItemImage::create( -// "CloseNormal.png", -// "CloseSelected.png", -// CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); -// -// closeItem->setPosition(origin + Vec2(visibleSize) - Vec2(closeItem->getContentSize() / 2)); -// -// // create menu, it's an autorelease object -// auto menu = Menu::create(closeItem, nullptr); -// menu->setPosition(Vec2::ZERO); -// this->addChild(menu, 1); -// -// ///////////////////////////// -// // 3. add your codes below... -// -// // add a label shows "Hello World" -// // create and initialize a label -// -// auto label = Label::createWithTTF("Hello World", "fonts/arial.ttf", TITLE_FONT_SIZE); - auto label = Label::createWithSystemFont("Hello World", "Arial", 20); -// -// // position the label on the center of the screen + // add a "close" icon to exit the progress. it's an autorelease object + auto closeItem = MenuItemImage::create( + "CloseNormal.png", + "CloseSelected.png", + CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); + + closeItem->setPosition(origin + Vec2(visibleSize) - Vec2(closeItem->getContentSize() / 2)); + + // create menu, it's an autorelease object + auto menu = Menu::create(closeItem, nullptr); + menu->setPosition(Vec2::ZERO); + this->addChild(menu, 1); + + ///////////////////////////// + // 3. add your codes below... + + // add a label shows "Hello World" + // create and initialize a label + + auto label = Label::createWithTTF("Hello World", "fonts/arial.ttf", TITLE_FONT_SIZE); + + // position the label on the center of the screen label->setPosition(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height); -// // add the label as a child to this layer + // add the label as a child to this layer this->addChild(label, 1); - label->runAction(MoveTo::create(10, Vec2(100, 100))); -// -// // add "HelloWorld" splash screen" -// SpriteFrameCache::getInstance()->addSpriteFramesWithFile("bugs/circle.plist"); -// auto sprite = Sprite::createWithSpriteFrameName("circle.png"); + + // add "HelloWorld" splash screen" auto sprite = Sprite::create("HelloWorld.png"); // position the sprite on the center of the screen @@ -90,22 +86,13 @@ bool HelloWorld::init() // add the sprite as a child to this layer this->addChild(sprite); - - auto s = Director::getInstance()->getWinSize(); - Size boxSize(100.0f, 100.0f); - auto box = LayerColor::create(Color4B(255,255,0,255)); - box->setAnchorPoint(Vec2(0.5,0.5)); - box->setContentSize( boxSize ); - box->setIgnoreAnchorPointForPosition(false); - box->setPosition(s.width/2, s.height - 100 - box->getContentSize().height/2); - this->addChild(box, 1); -// auto drawNode = DrawNode::create(); -// drawNode->setPosition(Vec2(0, 0)); -// addChild(drawNode); -// -// Rect safeArea = Director::getInstance()->getSafeAreaRect(); -// drawNode->drawRect(safeArea.origin, safeArea.origin + safeArea.size, Color4F::BLUE); + auto drawNode = DrawNode::create(); + drawNode->setPosition(Vec2(0, 0)); + addChild(drawNode); + + Rect safeArea = Director::getInstance()->getSafeAreaRect(); + drawNode->drawRect(safeArea.origin, safeArea.origin + safeArea.size, Color4F::BLUE); return true; } diff --git a/tests/cpp-empty-test/proj.android/gradle.properties b/tests/cpp-empty-test/proj.android/gradle.properties index 0994d0bdea..ebbe920606 100644 --- a/tests/cpp-empty-test/proj.android/gradle.properties +++ b/tests/cpp-empty-test/proj.android/gradle.properties @@ -31,10 +31,12 @@ PROP_TARGET_SDK_VERSION=28 # Available architextures (armeabi-v7a | arm64-v8a | x86) # To build for multiple architexture, use the `:` between them # Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86 -PROP_APP_ABI=x86 +PROP_APP_ABI=armeabi-v7a # uncomment it and fill in sign information for release mode #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false diff --git a/tests/cpp-empty-test/proj.ios/AppController.mm b/tests/cpp-empty-test/proj.ios/AppController.mm index af9ebfd785..6f3e9d813c 100644 --- a/tests/cpp-empty-test/proj.ios/AppController.mm +++ b/tests/cpp-empty-test/proj.ios/AppController.mm @@ -78,6 +78,12 @@ static AppDelegate s_sharedApplication; [[UIApplication sharedApplication] setStatusBarHidden: YES]; + //Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior. + if ( [[UIDevice currentDevice].systemVersion floatValue] >= 13.0f) + { + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"]; + } + // IMPORTANT: Setting the GLView should be done after creating the RootViewController cocos2d::GLViewImpl *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); cocos2d::Director::getInstance()->setOpenGLView(glview); diff --git a/tests/cpp-empty-test/proj.ios/Info.plist b/tests/cpp-empty-test/proj.ios/Info.plist index 935eac086d..c50ab342a5 100644 --- a/tests/cpp-empty-test/proj.ios/Info.plist +++ b/tests/cpp-empty-test/proj.ios/Info.plist @@ -7,7 +7,7 @@ CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleIconFile Icon-57.png CFBundleIconFiles @@ -24,19 +24,19 @@ CFBundleIcons~ipad CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} + ${PRODUCT_NAME} CFBundlePackageType APPL CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + 1.0 CFBundleSignature ???? CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + 1 LSRequiresIPhoneOS UILaunchStoryboardName @@ -50,6 +50,6 @@ UIInterfaceOrientationLandscapeRight NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} + Copyright © 2019. All rights reserved. diff --git a/tests/cpp-empty-test/proj.mac/Info.plist b/tests/cpp-empty-test/proj.mac/Info.plist index 608a82cdac..a1c1b9c2dc 100644 --- a/tests/cpp-empty-test/proj.mac/Info.plist +++ b/tests/cpp-empty-test/proj.mac/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile Icon CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -22,10 +22,8 @@ ???? CFBundleVersion 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright - Copyright © 2012. All rights reserved. + Copyright © 2019. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 052c886b7c..f3aeda703e 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -4,6 +4,12 @@ set(APP_NAME cpp-tests) project(${APP_NAME}) +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + if(NOT DEFINED BUILD_ENGINE_DONE) set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) @@ -204,6 +210,7 @@ list(APPEND GAME_HEADER Classes/OpenURLTest/OpenURLTest.h Classes/ConsoleTest/ConsoleTest.h Classes/MenuTest/MenuTest.h + Classes/ZipTest/ZipTests.h ) list(APPEND GAME_SOURCE @@ -325,6 +332,7 @@ list(APPEND GAME_SOURCE Classes/ZwoptexTest/ZwoptexTest.cpp Classes/SpriteFrameCacheTest/SpriteFrameCacheTest.cpp Classes/controller.cpp + Classes/ZipTest/ZipTests.cpp ) if(ANDROID OR IOS) @@ -349,70 +357,6 @@ if(WINDOWS OR MACOSX OR LINUX) ) endif() -list(APPEND GAME_HEADER - Classes/Box2DTest/Box2dTest.cpp - Classes/Box2DTestBed/Test.h - Classes/Box2DTestBed/Tests/Chain.h - Classes/Box2DTestBed/Tests/Confined.h - Classes/Box2DTestBed/Tests/PolyCollision.h - Classes/Box2DTestBed/Tests/EdgeTest.h - Classes/Box2DTestBed/Tests/ApplyForce.h - Classes/Box2DTestBed/Tests/Gears.h - Classes/Box2DTestBed/Tests/SliderCrank.h - Classes/Box2DTestBed/Tests/ContinuousTest.h - Classes/Box2DTestBed/Tests/Revolute.h - Classes/Box2DTestBed/Tests/TheoJansen.h - Classes/Box2DTestBed/Tests/Bridge.h - Classes/Box2DTestBed/Tests/CollisionProcessing.h - Classes/Box2DTestBed/Tests/DistanceTest.h - Classes/Box2DTestBed/Tests/PolyShapes.h - Classes/Box2DTestBed/Tests/TimeOfImpact.h - Classes/Box2DTestBed/Tests/ConveyorBelt.h - Classes/Box2DTestBed/Tests/Tiles.h - Classes/Box2DTestBed/Tests/BulletTest.h - Classes/Box2DTestBed/Tests/MotorJoint.h - Classes/Box2DTestBed/Tests/Car.h - Classes/Box2DTestBed/Tests/Mobile.h - Classes/Box2DTestBed/Tests/VaryingFriction.h - Classes/Box2DTestBed/Tests/Rope.h - Classes/Box2DTestBed/Tests/SensorTest.h - Classes/Box2DTestBed/Tests/Pyramid.h - Classes/Box2DTestBed/Tests/VaryingRestitution.h - Classes/Box2DTestBed/Tests/RopeJoint.h - Classes/Box2DTestBed/Tests/VerticalStack.h - Classes/Box2DTestBed/Tests/MobileBalanced.h - Classes/Box2DTestBed/Tests/CompoundShapes.h - Classes/Box2DTestBed/Tests/CollisionFiltering.h - Classes/Box2DTestBed/Tests/Pulleys.h - Classes/Box2DTestBed/Tests/Breakable.h - Classes/Box2DTestBed/Tests/BodyTypes.h - Classes/Box2DTestBed/Tests/DumpShell.h - Classes/Box2DTestBed/Tests/ShapeEditing.h - Classes/Box2DTestBed/Tests/SphereStack.h - Classes/Box2DTestBed/Tests/OneSidedPlatform.h - Classes/Box2DTestBed/Tests/AddPair.h - Classes/Box2DTestBed/Tests/Pinball.h - Classes/Box2DTestBed/Tests/Tumbler.h - Classes/Box2DTestBed/Tests/RayCast.h - Classes/Box2DTestBed/Tests/ConvexHull.h - Classes/Box2DTestBed/Tests/EdgeShapes.h - Classes/Box2DTestBed/Tests/Prismatic.h - Classes/Box2DTestBed/Tests/Dominos.h - Classes/Box2DTestBed/Tests/Web.h - Classes/Box2DTestBed/Tests/CharacterCollision.h - Classes/Box2DTestBed/Tests/DynamicTreeTest.h - Classes/Box2DTestBed/Tests/Cantilever.h - Classes/Box2DTestBed/Box2dView.h - Classes/Box2DTestBed/GLES-Render.h - ) -list(APPEND GAME_SOURCE - Classes/Box2DTest/Box2dTest.cpp - Classes/Box2DTestBed/Box2dView.cpp - Classes/Box2DTestBed/GLES-Render.cpp - Classes/Box2DTestBed/Test.cpp - Classes/Box2DTestBed/TestEntries.cpp - ) - list(APPEND GAME_HEADER Classes/Physics3DTest/Physics3DTest.h Classes/NavMeshTest/NavMeshTest.h @@ -459,17 +403,16 @@ target_include_directories(${APP_NAME} setup_cocos_app_config(${APP_NAME}) if(APPLE) set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}") + if(MACOSX) - set_target_properties(${APP_NAME} PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.mac/Info.plist" - ) + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.mac/Info.plist") elseif(IOS) - # set custom fonts - cocos_pak_xcode(${APP_NAME} INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios/Info.plist") + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon-${APP_NAME}") - set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "") - set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer") endif() + + # For code-signing, set the DEVELOPMENT_TEAM: + #set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") elseif(WINDOWS) # "too large PDB" error often occurs in cpp-tests when using default "/Zi" target_compile_options(${APP_NAME} PRIVATE /Z7) diff --git a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp index 2379f1114a..cfb1301096 100644 --- a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -127,7 +127,7 @@ void LogicTest::onEnter() grossini->setPosition(VisibleRect::center()); grossini->runAction( Sequence::create( - MoveBy::create(1, Vec2(150,0)), + MoveBy::create(1, Vec2(150.0f,0.0f)), CallFuncN::create(CC_CALLBACK_1(LogicTest::bugMe,this)), nullptr) ); @@ -171,7 +171,7 @@ void PauseTest::onEnter() addChild(grossini, 0, kTagGrossini); grossini->setPosition(VisibleRect::center() ); - auto action = MoveBy::create(1, Vec2(150,0)); + auto action = MoveBy::create(1, Vec2(150.0f,0.0f)); auto director = Director::getInstance(); director->getActionManager()->addAction(action, grossini, true); @@ -205,7 +205,7 @@ void StopActionTest::onEnter() addChild(l); l->setPosition(VisibleRect::center().x, VisibleRect::top().y - 75); - auto pMove = MoveBy::create(2, Vec2(200, 0)); + auto pMove = MoveBy::create(2, Vec2(200.0f, 0.0f)); auto pCallback = CallFunc::create(CC_CALLBACK_0(StopActionTest::stopAction,this)); auto pSequence = Sequence::create(pMove, pCallback, nullptr); pSequence->setTag(kTagSequence); @@ -241,8 +241,8 @@ void StopAllActionsTest::onEnter() addChild(l); l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 75) ); - auto pMove1 = MoveBy::create(2, Vec2(200, 0)); - auto pMove2 = MoveBy::create(2, Vec2(-200, 0)); + auto pMove1 = MoveBy::create(2, Vec2(200.0f, 0.0f)); + auto pMove2 = MoveBy::create(2, Vec2(-200.0f, 0.0f)); auto pSequenceMove = Sequence::createWithTwoActions(pMove1, pMove2); auto pRepeatMove = RepeatForever::create(pSequenceMove); pRepeatMove->setTag(kTagSequence); @@ -331,8 +331,8 @@ void StopActionsByFlagsTest::onEnter() addChild(l); l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 75) ); - auto pMove1 = MoveBy::create(2, Vec2(200, 0)); - auto pMove2 = MoveBy::create(2, Vec2(-200, 0)); + auto pMove1 = MoveBy::create(2, Vec2(200.0f, 0.0f)); + auto pMove2 = MoveBy::create(2, Vec2(-200.0f, 0.0f)); auto pSequenceMove = Sequence::createWithTwoActions(pMove1, pMove2); auto pRepeatMove = RepeatForever::create(pSequenceMove); pRepeatMove->setFlags(kMoveFlag | kRepeatForeverFlag); @@ -394,7 +394,7 @@ void Issue14050Test::onEnter() sprite->initWithFile("Images/grossini.png"); sprite->autorelease(); - auto move = MoveBy::create(2, Vec2(100, 100)); + auto move = MoveBy::create(2, Vec2(100.0f, 100.0f)); sprite->runAction(move); } diff --git a/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp index 62aa5a169e..29c9bc3d99 100644 --- a/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -82,7 +82,7 @@ void SpriteEase::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseIn::create(move->clone(), 2.5f); @@ -135,7 +135,7 @@ void SpriteEaseInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); // id move_back = move->reverse(); auto move_ease_inout1 = EaseInOut::create(move->clone(), 0.65f); @@ -174,7 +174,7 @@ void SpriteEaseExponential::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseExponentialIn::create(move->clone()); @@ -210,7 +210,7 @@ void SpriteEaseExponentialInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseExponentialInOut::create(move->clone() ); @@ -243,7 +243,7 @@ void SpriteEaseSine::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseSineIn::create(move->clone() ); @@ -280,7 +280,7 @@ void SpriteEaseSineInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseSineInOut::create(move->clone() ); @@ -312,7 +312,7 @@ void SpriteEaseElastic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseElasticIn::create(move->clone() ); @@ -348,7 +348,7 @@ void SpriteEaseElasticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_ease_inout1 = EaseElasticInOut::create(move->clone(), 0.3f); auto move_ease_inout_back1 = move_ease_inout1->reverse(); @@ -387,7 +387,7 @@ void SpriteEaseBounce::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseBounceIn::create(move->clone() ); @@ -424,7 +424,7 @@ void SpriteEaseBounceInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseBounceInOut::create(move->clone() ); @@ -457,7 +457,7 @@ void SpriteEaseBack::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseBackIn::create(move->clone()); @@ -493,7 +493,7 @@ void SpriteEaseBackInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseBackInOut::create(move->clone() ); @@ -537,13 +537,13 @@ void SpriteEaseBezier::onEnter() // sprite 1 ccBezierConfig bezier; - bezier.controlPoint_1 = Vec2(0, s.height/2); - bezier.controlPoint_2 = Vec2(300, -s.height/2); - bezier.endPosition = Vec2(300,100); + bezier.controlPoint_1 = Vec2(0.0f, s.height/2); + bezier.controlPoint_2 = Vec2(300.0f, -s.height/2); + bezier.endPosition = Vec2(300.0f,100.0f); auto bezierForward = BezierBy::create(3, bezier); auto bezierEaseForward = EaseBezierAction::create(bezierForward); - bezierEaseForward->setBezierParamer(0.5, 0.5, 1.0, 1.0); + bezierEaseForward->setBezierParamer(0.5f, 0.5f, 1.0f, 1.0f); auto bezierEaseBack = bezierEaseForward->reverse(); auto rep = RepeatForever::create(Sequence::create( bezierEaseForward, bezierEaseBack, nullptr)); @@ -552,19 +552,19 @@ void SpriteEaseBezier::onEnter() // sprite 2 _tamara->setPosition(80,160); ccBezierConfig bezier2; - bezier2.controlPoint_1 = Vec2(100, s.height/2); - bezier2.controlPoint_2 = Vec2(200, -s.height/2); - bezier2.endPosition = Vec2(240,160); + bezier2.controlPoint_1 = Vec2(100.0f, s.height/2); + bezier2.controlPoint_2 = Vec2(200.0f, -s.height/2); + bezier2.endPosition = Vec2(240.0f,160.0f); auto bezierTo1 = BezierTo::create(2, bezier2); auto bezierEaseTo1 = EaseBezierAction::create(bezierTo1); - bezierEaseTo1->setBezierParamer(0.5, 0.5, 1.0, 1.0); + bezierEaseTo1->setBezierParamer(0.5f, 0.5f, 1.0f, 1.0f); // sprite 3 - _kathia->setPosition(400,160); + _kathia->setPosition(400.0f,160.0f); auto bezierTo2 = BezierTo::create(2, bezier2); auto bezierEaseTo2 = EaseBezierAction::create(bezierTo2); - bezierEaseTo2->setBezierParamer(0.0, 0.5, -5.0, 1.0); + bezierEaseTo2->setBezierParamer(0.0f, 0.5f, -5.0f, 1.0f); _grossini->runAction( rep); @@ -588,7 +588,7 @@ void SpriteEaseQuadratic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseQuadraticActionIn::create(move->clone() ); @@ -623,7 +623,7 @@ void SpriteEaseQuadraticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseQuadraticActionInOut::create(move->clone() ); @@ -656,7 +656,7 @@ void SpriteEaseQuartic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseQuarticActionIn::create(move->clone() ); @@ -691,7 +691,7 @@ void SpriteEaseQuarticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseQuarticActionInOut::create(move->clone() ); @@ -723,7 +723,7 @@ void SpriteEaseQuintic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseQuinticActionIn::create(move->clone() ); @@ -759,7 +759,7 @@ void SpriteEaseQuinticInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseQuinticActionInOut::create(move->clone() ); @@ -791,7 +791,7 @@ void SpriteEaseCircle::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseCircleActionIn::create(move->clone() ); @@ -827,7 +827,7 @@ void SpriteEaseCircleInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseCircleActionInOut::create(move->clone() ); @@ -859,7 +859,7 @@ void SpriteEaseCubic::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease_in = EaseCubicActionIn::create(move->clone() ); @@ -895,7 +895,7 @@ void SpriteEaseCubicInOut::onEnter() { EaseSpriteDemo::onEnter(); - auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130, 0.0f)); auto move_back = move->reverse(); auto move_ease = EaseCubicActionInOut::create(move->clone() ); @@ -929,9 +929,9 @@ void SpeedTest::onEnter() auto s = Director::getInstance()->getWinSize(); // rotate and jump - auto jump1 = JumpBy::create(4, Vec2(-s.width+80, 0), 100, 4); + auto jump1 = JumpBy::create(4.0f, Vec2(-s.width+80, 0.0f), 100.0f, 4); auto jump2 = jump1->reverse(); - auto rot1 = RotateBy::create(4, 360*2); + auto rot1 = RotateBy::create(4.0f, 360*2.0f); auto rot2 = rot1->reverse(); auto seq3_1 = Sequence::create(jump2, jump1, nullptr); diff --git a/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp b/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp index 1d0cf458c6..f1f2f2cba0 100644 --- a/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/tests/cpp-tests/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -118,9 +118,9 @@ void SpriteProgressToHorizontal::onEnter() auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 0 for the x - left->setMidpoint(Vec2(0,0)); + left->setMidpoint(Vec2(0.0f,0.0f)); // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left->setBarChangeRate(Vec2(1, 0)); + left->setBarChangeRate(Vec2(1.0f, 0.0f)); addChild(left); left->setPosition(100, s.height/2); left->runAction( RepeatForever::create(to1)); @@ -128,9 +128,9 @@ void SpriteProgressToHorizontal::onEnter() auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 1 for the x - right->setMidpoint(Vec2(1, 0)); + right->setMidpoint(Vec2(1.0f, 0.0f)); // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right->setBarChangeRate(Vec2(1, 0)); + right->setBarChangeRate(Vec2(1.0f, 0.0f)); addChild(right); right->setPosition(s.width-100, s.height/2); right->runAction( RepeatForever::create(to2)); @@ -159,9 +159,9 @@ void SpriteProgressToVertical::onEnter() left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidpoint(Vec2(0,0)); + left->setMidpoint(Vec2(0.0f,0.0f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vec2(0, 1)); + left->setBarChangeRate(Vec2(0.0f, 1.0f)); addChild(left); left->setPosition(100, s.height/2); left->runAction( RepeatForever::create(to1)); @@ -245,7 +245,7 @@ void SpriteProgressBarVarious::onEnter() // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vec2(1, 0)); + left->setBarChangeRate(Vec2(1.0f, 0.0f)); addChild(left); left->setPosition(100, s.height/2); left->runAction(RepeatForever::create(to->clone())); @@ -302,7 +302,7 @@ void SpriteProgressBarTintAndFade::onEnter() // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vec2(1, 0)); + left->setBarChangeRate(Vec2(1.0f, 0.0f)); addChild(left); left->setPosition(100, s.height/2); left->runAction(RepeatForever::create(to->clone())); @@ -363,7 +363,7 @@ void SpriteProgressWithSpriteFrame::onEnter() // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Vec2(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Vec2(1, 0)); + left->setBarChangeRate(Vec2(1.0f, 0.0f)); addChild(left); left->setPosition(100, s.height/2); left->runAction(RepeatForever::create(to->clone())); diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp index e6508a8796..f492fb1c6a 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp @@ -202,12 +202,12 @@ void ActionMove::onEnter() auto s = Director::getInstance()->getWinSize(); auto actionTo = MoveTo::create(2, Vec2(s.width-40, s.height-40)); - auto actionBy = MoveBy::create(2, Vec2(80,80)); + auto actionBy = MoveBy::create(2, Vec2(80.0f,80.0f)); auto actionByBack = actionBy->reverse(); _tamara->runAction( actionTo); _grossini->runAction( Sequence::create(actionBy, actionByBack, nullptr)); - _kathia->runAction(MoveTo::create(1, Vec2(40,40))); + _kathia->runAction(MoveTo::create(1, Vec2(40.0f,40.0f))); } std::string ActionMove::subtitle() const @@ -228,16 +228,16 @@ void ActionMove3D::onEnter() auto s = Director::getInstance()->getWinSize(); - _tamara->setPosition3D(Vec3(s.width-40, s.height-40, 0)); - _kathia->setPosition3D(Vec3(40, 40, 0)); + _tamara->setPosition3D(Vec3(s.width-40, s.height-40, 0.0f)); + _kathia->setPosition3D(Vec3(40.0f, 40.0f, 0.0f)); - auto actionTo = MoveTo::create(2, Vec3(s.width-40, s.height-40, -100)); - auto actionBy = MoveBy::create(2, Vec3(80, 80, -100)); + auto actionTo = MoveTo::create(2, Vec3(s.width-40, s.height-40, -100.0f)); + auto actionBy = MoveBy::create(2, Vec3(80.0f, 80.0f, -100.0f)); auto actionByBack = actionBy->reverse(); _tamara->runAction(actionTo); _grossini->runAction(Sequence::create(actionBy, actionByBack, nullptr)); - _kathia->runAction(MoveTo::create(1, Vec3(40, 40, -100))); + _kathia->runAction(MoveTo::create(1, Vec3(40.0f, 40.0f, -100.0f))); } std::string ActionMove3D::subtitle() const @@ -339,7 +339,7 @@ void ActionRotationalSkewVSStandardSkew::onEnter() Size boxSize(100.0f, 100.0f); auto box = LayerColor::create(Color4B(255,255,0,255)); - box->setAnchorPoint(Vec2(0.5,0.5)); + box->setAnchorPoint(Vec2(0.5f,0.5f)); box->setContentSize( boxSize ); box->setIgnoreAnchorPointForPosition(false); box->setPosition(s.width/2, s.height - 100 - box->getContentSize().height/2); @@ -355,7 +355,7 @@ void ActionRotationalSkewVSStandardSkew::onEnter() box->runAction(Sequence::create(actionTo, actionToBack, nullptr)); box = LayerColor::create(Color4B(255,255,0,255)); - box->setAnchorPoint(Vec2(0.5,0.5)); + box->setAnchorPoint(Vec2(0.5f,0.5f)); box->setContentSize(boxSize); box->setIgnoreAnchorPointForPosition(false); box->setPosition(s.width/2, s.height - 250 - box->getContentSize().height/2); @@ -385,7 +385,7 @@ void ActionSkewRotateScale::onEnter() Size boxSize(100.0f, 100.0f); auto box = LayerColor::create(Color4B(255, 255, 0, 255)); - box->setAnchorPoint(Vec2(0, 0)); + box->setAnchorPoint(Vec2(0.0f, 0.0f)); box->setPosition(190, 110); box->setContentSize(boxSize); @@ -394,13 +394,13 @@ void ActionSkewRotateScale::onEnter() box->addChild(uL); uL->setContentSize(Size(markrside, markrside)); uL->setPosition(0.f, boxSize.height - markrside); - uL->setAnchorPoint(Vec2(0, 0)); + uL->setAnchorPoint(Vec2(0.0f, 0.0f)); auto uR = LayerColor::create(Color4B(0, 0, 255, 255)); box->addChild(uR); uR->setContentSize(Size(markrside, markrside)); uR->setPosition(boxSize.width - markrside, boxSize.height - markrside); - uR->setAnchorPoint(Vec2(0, 0)); + uR->setAnchorPoint(Vec2(0.0f, 0.0f)); addChild(box); auto actionTo = SkewTo::create(2, 0.f, 2.f); @@ -460,9 +460,9 @@ void ActionRotateBy3D::onEnter() centerSprites(3); - auto actionBy1 = RotateBy::create(4, Vec3(360, 0, 0)); - auto actionBy2 = RotateBy::create(4, Vec3(0, 360, 0)); - auto actionBy3 = RotateBy::create(4 ,Vec3(0, 0, 360)); + auto actionBy1 = RotateBy::create(4, Vec3(360.0f, 0.0f, 0.0f)); + auto actionBy2 = RotateBy::create(4, Vec3(0.0f, 360.0f, 0.0f)); + auto actionBy3 = RotateBy::create(4 ,Vec3(0.0f, 0.0f, 360.0f)); _tamara->runAction( Sequence::create(actionBy1, actionBy1->reverse(), nullptr)); _grossini->runAction( Sequence::create(actionBy2, actionBy2->reverse(), nullptr)); @@ -519,9 +519,9 @@ void ActionBezier::onEnter() // sprite 1 ccBezierConfig bezier; - bezier.controlPoint_1 = Vec2(0, s.height/2); - bezier.controlPoint_2 = Vec2(300, -s.height/2); - bezier.endPosition = Vec2(300,100); + bezier.controlPoint_1 = Vec2(0.0f, s.height/2); + bezier.controlPoint_2 = Vec2(300.0f, -s.height/2); + bezier.endPosition = Vec2(300.0f,100.0f); auto bezierForward = BezierBy::create(3, bezier); auto bezierBack = bezierForward->reverse(); @@ -531,9 +531,9 @@ void ActionBezier::onEnter() // sprite 2 _tamara->setPosition(80,160); ccBezierConfig bezier2; - bezier2.controlPoint_1 = Vec2(100, s.height/2); - bezier2.controlPoint_2 = Vec2(200, -s.height/2); - bezier2.endPosition = Vec2(240,160); + bezier2.controlPoint_1 = Vec2(100.0f, s.height/2); + bezier2.controlPoint_2 = Vec2(200.0f, -s.height/2); + bezier2.endPosition = Vec2(240.0f,160.0f); auto bezierTo1 = BezierTo::create(2, bezier2); @@ -718,7 +718,7 @@ void ActionSequence::onEnter() alignSpritesLeft(1); auto action = Sequence::create( - MoveBy::create( 2, Vec2(240,0)), + MoveBy::create( 2, Vec2(240.0f,0.0f)), RotateBy::create( 2, 540), nullptr); @@ -744,9 +744,9 @@ void ActionSequence2::onEnter() _grossini->setVisible(false); auto action = Sequence::create( - Place::create(Vec2(200,200)), + Place::create(Vec2(200.0f,200.0f)), Show::create(), - MoveBy::create(1, Vec2(100,0)), + MoveBy::create(1, Vec2(100.0f,0.0f)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback1,this)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback2,this,_grossini)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback3,this,_grossini,0xbebabeba)), @@ -799,7 +799,7 @@ void ActionSequence3::onEnter() alignSpritesLeft(1); // Uses Array API - auto action1 = MoveBy::create(2, Vec2(240,0)); + auto action1 = MoveBy::create(2, Vec2(240.0f,0.0f)); auto action2 = RotateBy::create(2, 540); auto action3 = action1->reverse(); auto action4 = action2->reverse(); @@ -830,7 +830,7 @@ void ActionCallFuncN::onEnter() centerSprites(1); auto action = Sequence::create( - MoveBy::create(2.0f, Vec2(150,0)), + MoveBy::create(2.0f, Vec2(150.0f,0.0f)), CallFuncN::create( CC_CALLBACK_1(ActionCallFuncN::callback, this)), nullptr); @@ -865,7 +865,7 @@ void ActionCallFuncND::onEnter() centerSprites(1); auto action = Sequence::create( - MoveBy::create(2.0f, Vec2(200,0)), + MoveBy::create(2.0f, Vec2(200.0f,0.0f)), CallFuncN::create( CC_CALLBACK_1(ActionCallFuncND::doRemoveFromParentAndCleanup, this, true)), nullptr); @@ -900,7 +900,7 @@ void ActionCallFunction::onEnter() auto action1 = Sequence::create( - MoveBy::create(2, Vec2(200,0)), + MoveBy::create(2, Vec2(200.0f,0.0f)), CallFunc::create( std::bind(&ActionCallFunction::callback1, this) ), CallFunc::create( // lambda @@ -1109,7 +1109,7 @@ void ActionDelayTime::onEnter() alignSpritesLeft(1); - auto move = MoveBy::create(1, Vec2(150,0)); + auto move = MoveBy::create(1, Vec2(150.0f,0.0f)); auto action = Sequence::create( move, DelayTime::create(2), move, nullptr); _grossini->runAction(action); @@ -1132,8 +1132,8 @@ void ActionReverseSequence::onEnter() alignSpritesLeft(1); - auto move1 = MoveBy::create(1, Vec2(250,0)); - auto move2 = MoveBy::create(1, Vec2(0,50)); + auto move1 = MoveBy::create(1, Vec2(250.0f,0.0f)); + auto move2 = MoveBy::create(1, Vec2(0.0f,50.0f)); auto seq = Sequence::create( move1, move2, move1->reverse(), nullptr); auto action = Sequence::create( seq, seq->reverse(), nullptr); @@ -1160,8 +1160,8 @@ void ActionReverseSequence2::onEnter() // Test: // Sequence should work both with IntervalAction and InstantActions - auto move1 = MoveBy::create(1, Vec2(250,0)); - auto move2 = MoveBy::create(1, Vec2(0,50)); + auto move1 = MoveBy::create(1, Vec2(250.0f,0.0f)); + auto move2 = MoveBy::create(1, Vec2(0.0f,50.0f)); auto tog1 = ToggleVisibility::create(); auto tog2 = ToggleVisibility::create(); auto seq = Sequence::create( move1, tog1, move2, tog2, move1->reverse(), nullptr); @@ -1172,8 +1172,8 @@ void ActionReverseSequence2::onEnter() // Also test that the reverse of Hide is Show, and vice-versa _kathia->runAction(action); - auto move_tamara = MoveBy::create(1, Vec2(100,0)); - auto move_tamara2 = MoveBy::create(1, Vec2(50,0)); + auto move_tamara = MoveBy::create(1, Vec2(100.0f,0.0f)); + auto move_tamara2 = MoveBy::create(1, Vec2(50.0f,0.0f)); auto hide = Hide::create(); auto seq_tamara = Sequence::create( move_tamara, hide, move_tamara2, nullptr); auto seq_back = seq_tamara->reverse(); @@ -1196,9 +1196,9 @@ void ActionRepeat::onEnter() alignSpritesLeft(2); - auto a1 = MoveBy::create(1, Vec2(150,0)); + auto a1 = MoveBy::create(1, Vec2(150.0f,0.0f)); auto action1 = Repeat::create( - Sequence::create( Place::create(Vec2(60,60)), a1, nullptr) , + Sequence::create( Place::create(Vec2(60.0f,60.0f)), a1, nullptr) , 3); auto action2 = RepeatForever::create( Sequence::create(a1->clone(), a1->reverse(), nullptr) @@ -1247,7 +1247,7 @@ void ActionOrbit::onEnter() _tamara->runAction(RepeatForever::create(action2)); _grossini->runAction(RepeatForever::create(action3)); - auto move = MoveBy::create(3, Vec2(100,-100)); + auto move = MoveBy::create(3, Vec2(100.0f,-100.0f)); auto move_back = move->reverse(); auto seq = Sequence::create(move, move_back, nullptr); auto rfe = RepeatForever::create(seq); @@ -1284,20 +1284,20 @@ void ActionFollow::onEnter() float x = s.width*2 - 100; float y = s.height; - Vec2 vertices[] = { Vec2(5,5), Vec2(x-5,5), Vec2(x-5,y-5), Vec2(5,y-5) }; - drawNode->drawPoly(vertices, 4, true, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + Vec2 vertices[] = { Vec2(5.0f,5.0f), Vec2(x-5,5.0f), Vec2(x-5,y-5), Vec2(5.0f,y-5) }; + drawNode->drawPoly(vertices, 4, true, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); this->addChild(drawNode); - _grossini->setPosition(-200, s.height / 2); - auto move = MoveBy::create(2, Vec2(s.width * 3, 0)); + _grossini->setPosition(-200.0f, s.height / 2); + auto move = MoveBy::create(2, Vec2(s.width * 3, 0.0f)); auto move_back = move->reverse(); auto seq = Sequence::create(move, move_back, nullptr); auto rep = RepeatForever::create(seq); _grossini->runAction(rep); - this->runAction(Follow::create(_grossini, Rect(0, 0, s.width * 2 - 100, s.height))); + this->runAction(Follow::create(_grossini, Rect(0.0f, 0.0f, s.width * 2 - 100, s.height))); } std::string ActionFollow::subtitle() const @@ -1321,13 +1321,13 @@ void ActionFollowWithOffset::onEnter() float x = s.width*2 - 100; float y = s.height; - Vec2 vertices[] = { Vec2(5,5), Vec2(x-5,5), Vec2(x-5,y-5), Vec2(5,y-5) }; - drawNode->drawPoly(vertices, 4, true, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + Vec2 vertices[] = { Vec2(5.0f,5.0f), Vec2(x-5,5.0f), Vec2(x-5,y-5), Vec2(5.0f,y-5) }; + drawNode->drawPoly(vertices, 4, true, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); this->addChild(drawNode); _grossini->setPosition(-200, s.height / 2); - auto move = MoveBy::create(2, Vec2(s.width * 3, 1)); + auto move = MoveBy::create(2, Vec2(s.width * 3, 1.0f)); auto move_back = move->reverse(); auto seq = Sequence::create(move, move_back, nullptr); auto rep = RepeatForever::create(seq); @@ -1337,7 +1337,7 @@ void ActionFollowWithOffset::onEnter() //sample offset values set float verticalOffset = -900; float horizontalOffset = 200; - this->runAction(Follow::createWithOffset(_grossini, horizontalOffset,verticalOffset,Rect(0, 0, s.width * 2 - 100, s.height))); + this->runAction(Follow::createWithOffset(_grossini, horizontalOffset,verticalOffset,Rect(0.0f, 0.0f, s.width * 2 - 100, s.height))); } std::string ActionFollowWithOffset::subtitle() const @@ -1425,12 +1425,13 @@ void ActionStacked::onEnter() void ActionStacked::addNewSpriteWithCoords(Vec2 p) { - int idx = CCRANDOM_0_1() * 1400 / 100; - int x = (idx%5) * 85; - int y = (idx/5) * 121; + int idx = static_cast(CCRANDOM_0_1() * 1400 / 100); + float w = 85.0f; + float h = 121.0f; + float x = (idx%5) * w; + float y = (idx/5) * h; - - auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(x,y,85,121)); + auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(x,y,w,h)); sprite->setPosition(p); this->addChild(sprite); @@ -1469,11 +1470,11 @@ void ActionMoveStacked::runActionsInSprite(Sprite *sprite) sprite->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vec2(10,10)), - MoveBy::create(0.05f, Vec2(-10,-10)), + MoveBy::create(0.05f, Vec2(10.0f,10.0f)), + MoveBy::create(0.05f, Vec2(-10.0f,-10.0f)), nullptr))); - auto action = MoveBy::create(2.0f, Vec2(400,0)); + auto action = MoveBy::create(2.0f, Vec2(400.0f,0.0f)); auto action_back = action->reverse(); sprite->runAction( @@ -1521,9 +1522,9 @@ void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) // sprite 1 ccBezierConfig bezier; - bezier.controlPoint_1 = Vec2(0, s.height/2); - bezier.controlPoint_2 = Vec2(300, -s.height/2); - bezier.endPosition = Vec2(300,100); + bezier.controlPoint_1 = Vec2(0.0f, s.height/2); + bezier.controlPoint_2 = Vec2(300.0f, -s.height/2); + bezier.endPosition = Vec2(300.0f,100.0f); auto bezierForward = BezierBy::create(3, bezier); auto bezierBack = bezierForward->reverse(); @@ -1534,8 +1535,8 @@ void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) sprite->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vec2(10,0)), - MoveBy::create(0.05f, Vec2(-10,0)), + MoveBy::create(0.05f, Vec2(10.0f,0.0f)), + MoveBy::create(0.05f, Vec2(-10.0f,0.0f)), nullptr))); } @@ -1566,12 +1567,12 @@ void ActionCatmullRomStacked::onEnter() auto array = PointArray::create(20); - array->addControlPoint(Vec2(0,0)); - array->addControlPoint(Vec2(80,80)); - array->addControlPoint(Vec2(s.width-80,80)); - array->addControlPoint(Vec2(s.width-80,s.height-80)); - array->addControlPoint(Vec2(80,s.height-80)); - array->addControlPoint(Vec2(80,80)); + array->addControlPoint(Vec2(0.0f,0.0f)); + array->addControlPoint(Vec2(80.0f,80.0f)); + array->addControlPoint(Vec2(s.width-80,80.0f)); + array->addControlPoint(Vec2(s.width-80,s.height-80.0f)); + array->addControlPoint(Vec2(80.0f,s.height-80.0f)); + array->addControlPoint(Vec2(80.0f,80.0f)); array->addControlPoint(Vec2(s.width/2, s.height/2)); auto action = CatmullRomBy::create(3, array); @@ -1584,13 +1585,13 @@ void ActionCatmullRomStacked::onEnter() _tamara->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vec2(10,0)), - MoveBy::create(0.05f, Vec2(-10,0)), + MoveBy::create(0.05f, Vec2(10.0f,0.0f)), + MoveBy::create(0.05f, Vec2(-10.0f,0.0f)), nullptr))); auto drawNode1 = DrawNode::create(); - drawNode1->setPosition(Vec2(50,50)); - drawNode1->drawCatmullRom(array, 50, Color4F(1.0, 1.0, 0.0, 0.5)); + drawNode1->setPosition(Vec2(50.0f,50.0f)); + drawNode1->drawCatmullRom(array, 50, Color4F(1.0f, 1.0f, 0.0f, 0.5f)); this->addChild(drawNode1); // @@ -1602,11 +1603,11 @@ void ActionCatmullRomStacked::onEnter() auto array2 = PointArray::create(20); - array2->addControlPoint(Vec2(s.width/2, 30)); - array2->addControlPoint(Vec2(s.width-80,30)); - array2->addControlPoint(Vec2(s.width-80,s.height-80)); - array2->addControlPoint(Vec2(s.width/2,s.height-80)); - array2->addControlPoint(Vec2(s.width/2, 30)); + array2->addControlPoint(Vec2(s.width/2, 30.0f)); + array2->addControlPoint(Vec2(s.width-80,30.0f)); + array2->addControlPoint(Vec2(s.width-80.0f,s.height-80.0f)); + array2->addControlPoint(Vec2(s.width/2,s.height-80.0f)); + array2->addControlPoint(Vec2(s.width/2, 30.0f)); auto action2 = CatmullRomTo::create(3, array2); auto reverse2 = action2->reverse(); @@ -1618,8 +1619,8 @@ void ActionCatmullRomStacked::onEnter() _kathia->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vec2(10,0)), - MoveBy::create(0.05f, Vec2(-10,0)), + MoveBy::create(0.05f, Vec2(10.0f,0.0f)), + MoveBy::create(0.05f, Vec2(-10.0f,0.0f)), nullptr))); auto drawNode2 = DrawNode::create(); @@ -1654,11 +1655,11 @@ void ActionCardinalSplineStacked::onEnter() auto array = PointArray::create(20); - array->addControlPoint(Vec2(0, 0)); - array->addControlPoint(Vec2(s.width/2-30,0)); - array->addControlPoint(Vec2(s.width/2-30,s.height-80)); - array->addControlPoint(Vec2(0, s.height-80)); - array->addControlPoint(Vec2(0, 0)); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(s.width/2-30,0.0f)); + array->addControlPoint(Vec2(s.width/2-30,s.height-80.0f)); + array->addControlPoint(Vec2(0.0f, s.height-80.0f)); + array->addControlPoint(Vec2(0.0f, 0.0f)); // @@ -1678,13 +1679,13 @@ void ActionCardinalSplineStacked::onEnter() _tamara->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vec2(10,0)), - MoveBy::create(0.05f, Vec2(-10,0)), + MoveBy::create(0.05f, Vec2(10.0f,0.0f)), + MoveBy::create(0.05f, Vec2(-10.0f,0.0f)), nullptr))); auto drawNode1 = DrawNode::create(); - drawNode1->setPosition(Vec2(50,50)); - drawNode1->drawCardinalSpline(array, 0, 100, Color4F(1.0, 0.0, 1.0, 1.0)); + drawNode1->setPosition(Vec2(50.0f,50.0f)); + drawNode1->drawCardinalSpline(array, 0, 100, Color4F(1.0f, 0.0f, 1.0f, 1.0f)); this->addChild(drawNode1); // @@ -1705,13 +1706,13 @@ void ActionCardinalSplineStacked::onEnter() _kathia->runAction( RepeatForever::create( Sequence::create( - MoveBy::create(0.05f, Vec2(10,0)), - MoveBy::create(0.05f, Vec2(-10,0)), + MoveBy::create(0.05f, Vec2(10.0f,0.0f)), + MoveBy::create(0.05f, Vec2(-10.0f,0.0f)), nullptr))); auto drawNode2 = DrawNode::create(); - drawNode2->setPosition(Vec2(s.width/2,50)); - drawNode2->drawCardinalSpline(array, 1, 100, Color4F(0.0, 0.0, 1.0, 1.0)); + drawNode2->setPosition(Vec2(s.width/2,50.0f)); + drawNode2->drawCardinalSpline(array, 1, 100, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); this->addChild(drawNode2); } @@ -1777,7 +1778,7 @@ void Issue1305_2::onEnter() spr->setPosition(200,200); addChild(spr); - auto act1 = MoveBy::create(2 ,Vec2(0, 100)); + auto act1 = MoveBy::create(2 ,Vec2(0.0f, 100.0f)); /* c++ can't support block, so we use CallFuncN instead. id act2 = [CallBlock actionWithBlock:^{ NSLog(@"1st block"); @@ -1797,11 +1798,11 @@ void Issue1305_2::onEnter() */ auto act2 = CallFunc::create( std::bind( &Issue1305_2::printLog1, this)); - auto act3 = MoveBy::create(2, Vec2(0, -100)); + auto act3 = MoveBy::create(2, Vec2(0.0f, -100.0f)); auto act4 = CallFunc::create( std::bind( &Issue1305_2::printLog2, this)); - auto act5 = MoveBy::create(2, Vec2(100, -100)); + auto act5 = MoveBy::create(2, Vec2(100.0f, -100.0f)); auto act6 = CallFunc::create( std::bind( &Issue1305_2::printLog3, this)); - auto act7 = MoveBy::create(2, Vec2(-100, 0)); + auto act7 = MoveBy::create(2, Vec2(-100.0f, 0.0f)); auto act8 = CallFunc::create( std::bind( &Issue1305_2::printLog4, this)); auto actF = Sequence::create(act1, act2, act3, act4, act5, act6, act7, act8, nullptr); @@ -1850,7 +1851,7 @@ void Issue1288::onEnter() spr->setPosition(100, 100); addChild(spr); - auto act1 = MoveBy::create(0.5, Vec2(100, 0)); + auto act1 = MoveBy::create(0.5, Vec2(100.0f, 0.0f)); auto act2 = act1->reverse(); auto act3 = Sequence::create(act1, act2, nullptr); auto act4 = Repeat::create(act3, 2); @@ -1877,7 +1878,7 @@ void Issue1288_2::onEnter() spr->setPosition(100, 100); addChild(spr); - auto act1 = MoveBy::create(0.5, Vec2(100, 0)); + auto act1 = MoveBy::create(0.5, Vec2(100.0f, 0.0f)); spr->runAction(Repeat::create(act1, 1)); } @@ -2027,12 +2028,12 @@ void ActionCatmullRom::onEnter() auto array = PointArray::create(20); - array->addControlPoint(Vec2(0, 0)); - array->addControlPoint(Vec2(80, 80)); - array->addControlPoint(Vec2(s.width - 80, 80)); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(s.width - 80, 80.0f)); array->addControlPoint(Vec2(s.width - 80, s.height - 80)); - array->addControlPoint(Vec2(80, s.height - 80)); - array->addControlPoint(Vec2(80, 80)); + array->addControlPoint(Vec2(80.0f, s.height - 80.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); array->addControlPoint(Vec2(s.width / 2, s.height / 2)); auto action = CatmullRomBy::create(3, array); @@ -2043,8 +2044,8 @@ void ActionCatmullRom::onEnter() _tamara->runAction(seq); auto drawNode1 = DrawNode::create(); - drawNode1->setPosition(Vec2(50,50)); - drawNode1->drawCatmullRom(array, 50, Color4F(1.0, 0.0, 1.0, 1.0)); + drawNode1->setPosition(Vec2(50.0f,50.0f)); + drawNode1->drawCatmullRom(array, 50, Color4F(1.0f, 0.0f, 1.0f, 1.0f)); this->addChild(drawNode1); // @@ -2056,11 +2057,11 @@ void ActionCatmullRom::onEnter() auto array2 = PointArray::create(20); - array2->addControlPoint(Vec2(s.width / 2, 30)); - array2->addControlPoint(Vec2(s.width -80, 30)); + array2->addControlPoint(Vec2(s.width / 2, 30.0f)); + array2->addControlPoint(Vec2(s.width -80, 30.0f)); array2->addControlPoint(Vec2(s.width - 80, s.height - 80)); array2->addControlPoint(Vec2(s.width / 2, s.height - 80)); - array2->addControlPoint(Vec2(s.width / 2, 30)); + array2->addControlPoint(Vec2(s.width / 2, 30.0f)); auto action2 = CatmullRomTo::create(3, array2); auto reverse2 = action2->reverse(); @@ -2070,7 +2071,7 @@ void ActionCatmullRom::onEnter() _kathia->runAction(seq2); auto drawNode2 = DrawNode::create(); - drawNode2->drawCatmullRom(array2, 50, Color4F(0.0, 1.0, 1.0, 1.0)); + drawNode2->drawCatmullRom(array2, 50, Color4F(0.0f, 1.0f, 1.0f, 1.0f)); this->addChild(drawNode2); } @@ -2100,11 +2101,11 @@ void ActionCardinalSpline::onEnter() auto array = PointArray::create(20); - array->addControlPoint(Vec2(0, 0)); - array->addControlPoint(Vec2(s.width/2-30, 0)); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(s.width/2-30, 0.0f)); array->addControlPoint(Vec2(s.width/2-30, s.height-80)); - array->addControlPoint(Vec2(0, s.height-80)); - array->addControlPoint(Vec2(0, 0)); + array->addControlPoint(Vec2(0.0f, s.height-80)); + array->addControlPoint(Vec2(0.0f, 0.0f)); // // sprite 1 (By) @@ -2121,8 +2122,8 @@ void ActionCardinalSpline::onEnter() _tamara->runAction(seq); auto drawNode1 = DrawNode::create(); - drawNode1->setPosition(Vec2(50,50)); - drawNode1->drawCardinalSpline(array, 0, 100, Color4F(1.0, 0.0, 1.0, 1.0)); + drawNode1->setPosition(Vec2(50.0f,50.0f)); + drawNode1->drawCardinalSpline(array, 0, 100, Color4F(1.0f, 0.0f, 1.0f, 1.0f)); this->addChild(drawNode1); // @@ -2140,8 +2141,8 @@ void ActionCardinalSpline::onEnter() _kathia->runAction(seq2); auto drawNode2 = DrawNode::create(); - drawNode2->setPosition(Vec2(s.width/2, 50)); - drawNode2->drawCardinalSpline(array, 1, 100, Color4F(1.0, 0.0, 1.0, 1.0)); + drawNode2->setPosition(Vec2(s.width/2, 50.0f)); + drawNode2->drawCardinalSpline(array, 1, 100, Color4F(1.0f, 0.0f, 1.0f, 1.0f)); this->addChild(drawNode2); } @@ -2178,9 +2179,9 @@ void PauseResumeActions::onEnter() this->centerSprites(3); - _tamara->runAction(RepeatForever::create(RotateBy::create(3, 360))); - _grossini->runAction(RepeatForever::create(RotateBy::create(3, -360))); - _kathia->runAction(RepeatForever::create(RotateBy::create(3, 360))); + _tamara->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); + _grossini->runAction(RepeatForever::create(RotateBy::create(3.0f, -360.0f))); + _kathia->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); this->schedule([&](float dt){ log("Pausing"); @@ -2237,15 +2238,15 @@ void ActionResize::onEnter() Vec2 offset(0.0f, 50.0f); ImageView* imageViewResize = ImageView::create("cocosui/buttonHighlighted.png"); imageViewResize->setScale9Enabled(true); - imageViewResize->setContentSize(Size(50, 40)); + imageViewResize->setContentSize(Size(50.0f, 40.0f)); imageViewResize->setPosition(Vec2((widgetSize.width / 2.0f) + offset.x, (widgetSize.height / 2.0f) + offset.y)); - auto resizeDown = cocos2d::ResizeTo::create(2.8f, Size(50, 40)); - auto resizeUp = cocos2d::ResizeTo::create(2.8f, Size(300, 40)); + auto resizeDown = cocos2d::ResizeTo::create(2.8f, Size(50.0f, 40.0f)); + auto resizeUp = cocos2d::ResizeTo::create(2.8f, Size(300.0f, 40.0f)); - auto resizeByDown = cocos2d::ResizeBy::create(1.8f, Size(0, -30)); - auto resizeByUp = cocos2d::ResizeBy::create(1.8f, Size(0, 30)); + auto resizeByDown = cocos2d::ResizeBy::create(1.8f, Size(0.0f, -30.0f)); + auto resizeByUp = cocos2d::ResizeBy::create(1.8f, Size(0.0f, 30.0f)); addChild(imageViewResize); auto rep = RepeatForever::create(Sequence::create(resizeUp, resizeDown, resizeByDown, resizeByUp, nullptr)); imageViewResize->runAction(rep); @@ -2253,7 +2254,7 @@ void ActionResize::onEnter() // Create another imageview that scale to see the difference ImageView* imageViewScale = ImageView::create("cocosui/buttonHighlighted.png"); imageViewScale->setScale9Enabled(true); - imageViewScale->setContentSize(Size(50, 40)); + imageViewScale->setContentSize(Size(50.0f, 40.0f)); imageViewScale->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); @@ -2284,7 +2285,7 @@ void ActionRemoveSelf::onEnter() alignSpritesLeft(1); auto action = Sequence::create( - MoveBy::create( 2, Vec2(240,0)), + MoveBy::create( 2, Vec2(240.0f,0.0f)), RotateBy::create( 2, 540), ScaleTo::create(1,0.1f), RemoveSelf::create(), @@ -2425,13 +2426,13 @@ void SequenceWithFinalInstant::onEnter() const auto action = cocos2d::Sequence::create - (cocos2d::DelayTime::create(0.05), + (cocos2d::DelayTime::create(0.05f), cocos2d::CallFunc::create(f), nullptr); _target->runAction(action); _manager->update(0); - _manager->update(0.05 - FLT_EPSILON); + _manager->update(0.05f - FLT_EPSILON); if ( action->isDone() && !called ) assert(false); diff --git a/tests/cpp-tests/Classes/BaseTest.h b/tests/cpp-tests/Classes/BaseTest.h index 2dd3dd9ed0..3982e6ee1c 100644 --- a/tests/cpp-tests/Classes/BaseTest.h +++ b/tests/cpp-tests/Classes/BaseTest.h @@ -91,6 +91,9 @@ public: void setTestCaseName(const std::string& name) { _testCaseName = name; } std::string getTestCaseName() const { return _testCaseName; } + const cocos2d::Label* getSubtitleLable() const { return _subtitleLabel; } + const cocos2d::MenuItemImage* getRestartTestItem() const { return _restartTestItem; } + virtual void onEnter() override; CC_CONSTRUCTOR_ACCESS: virtual bool init() override; diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp index d54a407efc..49b908ab22 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp @@ -49,12 +49,12 @@ BillBoardTests::BillBoardTests() BillBoardRotationTest::BillBoardRotationTest() { auto root = Sprite3D::create(); - root->setPositionNormalized(Vec2(.5,.25)); + root->setPositionNormalized(Vec2(0.5f,0.25f)); addChild(root); auto model = Sprite3D::create("Sprite3DTest/orc.c3b"); model->setScale(5); - model->setRotation3D(Vec3(0,180,0)); + model->setRotation3D(Vec3(0.0f,180.0f,0.0f)); root->addChild(model); auto bill = BillBoard::create(); @@ -66,19 +66,19 @@ BillBoardRotationTest::BillBoardRotationTest() bill->addChild(sp); auto lbl = Label::create(); - lbl->setPosition(0, 30); + lbl->setPosition(0.0f, 30.0f); lbl->setString("+100"); bill->addChild(lbl); - auto r = RotateBy::create(10, Vec3(0,360,0)); + auto r = RotateBy::create(10, Vec3(0.0f,360.0f,0.0f)); auto rp = RepeatForever::create(r); root->runAction(rp); - auto jump = JumpBy::create(1, Vec2(0, 0), 30, 1); + auto jump = JumpBy::create(1, Vec2(0.0f, 0.0f), 30, 1); auto scale = ScaleBy::create(2.f, 2.f, 2.f, 0.1f); auto seq = Sequence::create(jump,scale, NULL); - auto rot = RotateBy::create(2, Vec3(-90, 0, 0)); + auto rot = RotateBy::create(2, Vec3(-90.0f, 0.0f, 0.0f)); auto act = Spawn::create(seq, rot,NULL); auto scale2 = scale->reverse(); @@ -134,10 +134,10 @@ BillBoardTest::BillBoardTest() for (unsigned int i = 0; i < 4; ++i) { Layer *layer = Layer::create(); - auto billboard = BillBoard::create(imgs[(unsigned int)(CCRANDOM_0_1() * 1 + 0.5)]); + auto billboard = BillBoard::create(imgs[(unsigned int)(CCRANDOM_0_1() * 1 + 0.5f)]); billboard->setScale(0.5f); billboard->setPosition3D(Vec3(0.0f, 0.0f, CCRANDOM_MINUS1_1() * 150.0f)); - billboard->setOpacity(CCRANDOM_0_1() * 128 + 128); + billboard->setOpacity(static_cast(CCRANDOM_0_1() * 128 + 128)); _billboards.push_back(billboard); layer->addChild(billboard); _layerBillBoard->addChild(layer); @@ -162,20 +162,20 @@ BillBoardTest::BillBoardTest() _layerBillBoard->addChild(sprite3d); } - addNewBillBoardWithCoords(Vec3(20,5,0)); - addNewBillBoardWithCoords(Vec3(60,5,0)); - addNewBillBoardWithCoords(Vec3(100,5,0)); - addNewBillBoardWithCoords(Vec3(140,5,0)); - addNewBillBoardWithCoords(Vec3(180,5,0)); + addNewBillBoardWithCoords(Vec3(20.0f,5.0f,0.0f)); + addNewBillBoardWithCoords(Vec3(60.0f,5.0f,0.0f)); + addNewBillBoardWithCoords(Vec3(100.0f,5.0f,0.0f)); + addNewBillBoardWithCoords(Vec3(140.0f,5.0f,0.0f)); + addNewBillBoardWithCoords(Vec3(180.0f,5.0f,0.0f)); - addNewAniBillBoardWithCoords(Vec3(-20,0,0)); - addNewAniBillBoardWithCoords(Vec3(-60,0,0)); - addNewAniBillBoardWithCoords(Vec3(-100,0,0)); - addNewAniBillBoardWithCoords(Vec3(-140,0,0)); - addNewAniBillBoardWithCoords(Vec3(-180,0,0)); + addNewAniBillBoardWithCoords(Vec3(-20.0f,0.0f,0.0f)); + addNewAniBillBoardWithCoords(Vec3(-60.0f,0.0f,0.0f)); + addNewAniBillBoardWithCoords(Vec3(-100.0f,0.0f,0.0f)); + addNewAniBillBoardWithCoords(Vec3(-140.0f,0.0f,0.0f)); + addNewAniBillBoardWithCoords(Vec3(-180.0f,0.0f,0.0f)); - _camera->setPosition3D(Vec3(0, 100, 230)); - _camera->lookAt(Vec3(0,0,0), Vec3(0,1,0)); + _camera->setPosition3D(Vec3(0.0f, 100.0f, 230.0f)); + _camera->lookAt(Vec3(0,0,0), Vec3(0.0f,1.0f,0.0f)); TTFConfig ttfConfig("fonts/arial.ttf", 16); auto label1 = Label::createWithTTF(ttfConfig,"rotate+"); @@ -238,10 +238,10 @@ void BillBoardTest::addNewBillBoardWithCoords(Vec3 p) std::string imgs[3] = {"Images/Icon.png", "Images/r2.png"}; for (unsigned int i = 0; i < 10; ++i) { - auto billboard = BillBoard::create(imgs[(unsigned int)(CCRANDOM_0_1() * 1 + 0.5)]); + auto billboard = BillBoard::create(imgs[(unsigned int)(CCRANDOM_0_1() * 1 + 0.5f)]); billboard->setScale(0.5f); billboard->setPosition3D(Vec3(p.x, p.y, -150.0f + 30 * i)); - billboard->setOpacity(CCRANDOM_0_1() * 128 + 128); + billboard->setOpacity(static_cast(CCRANDOM_0_1() * 128 + 128)); _layerBillBoard->addChild(billboard); _billboards.push_back(billboard); @@ -269,7 +269,7 @@ void BillBoardTest::addNewAniBillBoardWithCoords(Vec3 p) auto action = Animate::create(animation); billboardAni->runAction(RepeatForever::create(action)); - billboardAni->setOpacity(CCRANDOM_0_1() * 128 + 128); + billboardAni->setOpacity(static_cast(CCRANDOM_0_1() * 128 + 128)); _billboards.push_back(billboardAni); } } diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp deleted file mode 100644 index ad3de2be54..0000000000 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "Box2dTest.h" -#include "../testResource.h" -#include "extensions/cocos-ext.h" -#include "renderer/CCRenderer.h" -#include "renderer/CCCustomCommand.h" - -USING_NS_CC; -USING_NS_CC_EXT; - -#define PTM_RATIO 32 - -enum { - kTagParentNode = 1, -}; - -Box2DTests::Box2DTests() -{ - ADD_TEST_CASE(Box2DTest); -} - -bool Box2DTest::init() -{ - if (!TestCase::init()) - { - return false; - } -#if CC_ENABLE_BOX2D_INTEGRATION - auto dispatcher = Director::getInstance()->getEventDispatcher(); - - auto touchListener = EventListenerTouchAllAtOnce::create(); - touchListener->onTouchesEnded = CC_CALLBACK_2(Box2DTest::onTouchesEnded, this); - dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - - // init physics - this->initPhysics(); - // create reset button - this->createResetButton(); - - //Set up sprite -#if 1 - // Use batch node. Faster - auto parent = SpriteBatchNode::create("Images/blocks.png", 100); - _spriteTexture = parent->getTexture(); -#else - // doesn't use batch node. Slower - _spriteTexture = Director::getInstance()->getTextureCache()->addImage("Images/blocks.png"); - auto parent = Node::create(); -#endif - addChild(parent, 0, kTagParentNode); - - - addNewSpriteAtPosition(VisibleRect::center()); - - auto label = Label::createWithTTF("Tap screen", "fonts/Marker Felt.ttf", 32.0f); - addChild(label, 0); - label->setColor(Color3B(0, 0, 255)); - label->setPosition(VisibleRect::center().x, VisibleRect::top().y - 50); - - scheduleUpdate(); -#else - auto label = Label::createWithTTF("Should define CC_ENABLE_BOX2D_INTEGRATION=1\n to run this test case", - "fonts/arial.ttf", - 18); - auto size = Director::getInstance()->getWinSize(); - label->setPosition(size.width / 2, size.height / 2); - - addChild(label); -#endif - - return true; -} - -#if CC_ENABLE_BOX2D_INTEGRATION -Box2DTest::Box2DTest() - : _spriteTexture(nullptr) - , world(nullptr) -{ - -} - -Box2DTest::~Box2DTest() -{ - CC_SAFE_DELETE(world); -} - -void Box2DTest::initPhysics() -{ - b2Vec2 gravity; - gravity.Set(0.0f, -10.0f); - world = new b2World(gravity); - - // Do we want to let bodies sleep? - world->SetAllowSleeping(true); - - world->SetContinuousPhysics(true); - - // Define the ground body. - b2BodyDef groundBodyDef; - groundBodyDef.position.Set(0, 0); // bottom-left corner - - // Call the body factory which allocates memory for the ground body - // from a pool and creates the ground box shape (also from a pool). - // The body is also added to the world. - b2Body* groundBody = world->CreateBody(&groundBodyDef); - - // Define the ground box shape. - b2EdgeShape groundBox; - - // bottom - groundBox.Set(b2Vec2(VisibleRect::leftBottom().x/PTM_RATIO,VisibleRect::leftBottom().y/PTM_RATIO), b2Vec2(VisibleRect::rightBottom().x/PTM_RATIO,VisibleRect::rightBottom().y/PTM_RATIO)); - groundBody->CreateFixture(&groundBox,0); - - // top - groundBox.Set(b2Vec2(VisibleRect::leftTop().x/PTM_RATIO,VisibleRect::leftTop().y/PTM_RATIO), b2Vec2(VisibleRect::rightTop().x/PTM_RATIO,VisibleRect::rightTop().y/PTM_RATIO)); - groundBody->CreateFixture(&groundBox,0); - - // left - groundBox.Set(b2Vec2(VisibleRect::leftTop().x/PTM_RATIO,VisibleRect::leftTop().y/PTM_RATIO), b2Vec2(VisibleRect::leftBottom().x/PTM_RATIO,VisibleRect::leftBottom().y/PTM_RATIO)); - groundBody->CreateFixture(&groundBox,0); - - // right - groundBox.Set(b2Vec2(VisibleRect::rightBottom().x/PTM_RATIO,VisibleRect::rightBottom().y/PTM_RATIO), b2Vec2(VisibleRect::rightTop().x/PTM_RATIO,VisibleRect::rightTop().y/PTM_RATIO)); - groundBody->CreateFixture(&groundBox,0); -} - -void Box2DTest::createResetButton() -{ - auto reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", [&](Ref *sender) { - getTestSuite()->restartCurrTest(); - }); - - auto menu = Menu::create(reset, nullptr); - - menu->setPosition(VisibleRect::bottom().x, VisibleRect::bottom().y + 30); - this->addChild(menu, -1); - -} - -void Box2DTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) -{ - // - // IMPORTANT: - // This is only for debug purposes - // It is recommend to disable it - // - Scene::draw(renderer, transform, flags); - - GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when setting matrix stack"); - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - - _modelViewMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - - _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(Box2DTest::onDraw, this); - renderer->addCommand(&_customCommand); - - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); -} - -void Box2DTest::onDraw() -{ - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when setting matrix stack"); - - auto oldMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV); - world->DrawDebugData(); - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, oldMV); -} - - -void Box2DTest::addNewSpriteAtPosition(Vec2 p) -{ - CCLOG("Add sprite %0.2f x %02.f",p.x,p.y); - - // Define the dynamic body. - //Set up a 1m squared box in the physics world - b2BodyDef bodyDef; - bodyDef.type = b2_dynamicBody; - bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO); - - b2Body *body = world->CreateBody(&bodyDef); - - // Define another box shape for our dynamic body. - b2PolygonShape dynamicBox; - dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box - - // Define the dynamic body fixture. - b2FixtureDef fixtureDef; - fixtureDef.shape = &dynamicBox; - fixtureDef.density = 1.0f; - fixtureDef.friction = 0.3f; - body->CreateFixture(&fixtureDef); - -#if CC_ENABLE_BOX2D_INTEGRATION - auto parent = this->getChildByTag(kTagParentNode); - - //We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is - //just randomly picking one of the images - int idx = (CCRANDOM_0_1() > .5 ? 0:1); - int idy = (CCRANDOM_0_1() > .5 ? 0:1); - auto sprite = PhysicsSprite::createWithTexture(_spriteTexture,Rect(32 * idx,32 * idy,32,32)); - parent->addChild(sprite); - sprite->setB2Body(body); - sprite->setPTMRatio(PTM_RATIO); - sprite->setPosition(cocos2d::Vec2(p.x, p.y)); -#endif -} - -void Box2DTest::update(float dt) -{ - //It is recommended that a fixed time step is used with Box2D for stability - //of the simulation, however, we are using a variable time step here. - //You need to make an informed choice, the following URL is useful - //http://gafferongames.com/game-physics/fix-your-timestep/ - - int velocityIterations = 8; - int positionIterations = 1; - - // Instruct the world to perform a single step of simulation. It is - // generally best to keep the time step and iterations fixed. - world->Step(dt, velocityIterations, positionIterations); -} - -void Box2DTest::onTouchesEnded(const std::vector& touches, Event* event) -{ - //Add a new body/atlas sprite at the touched location - - for (auto& touch : touches) - { - if(!touch) - break; - - auto location = touch->getLocation(); - - addNewSpriteAtPosition( location ); - } -} - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h deleted file mode 100644 index 36837befb4..0000000000 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef _BOX2D_TEST_H_ -#define _BOX2D_TEST_H_ - -#include "cocos2d.h" -#include "Box2D/Box2D.h" -#include "../BaseTest.h" - -DEFINE_TEST_SUITE(Box2DTests); - -class Box2DTest : public TestCase -{ -public: - CREATE_FUNC(Box2DTest); - - virtual bool init() override; - -#if CC_ENABLE_BOX2D_INTEGRATION - Box2DTest(); - ~Box2DTest(); - - void initPhysics(); - void createResetButton(); - virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override; - - void addNewSpriteAtPosition(cocos2d::Vec2 p); - void update(float dt) override; - void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); - -private: - cocos2d::Mat4 _modelViewMV; - void onDraw(); - cocos2d::CustomCommand _customCommand; - cocos2d::Texture2D* _spriteTexture; - b2World* world; -#endif -} ; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp deleted file mode 100644 index 418229ed53..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "Box2dView.h" -#include "GLES-Render.h" -#include "Test.h" -#include "renderer/CCRenderer.h" - -USING_NS_CC; - -#define kAccelerometerFrequency 30 -#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10 - -extern int g_totalEntries; - -Settings settings; - -enum -{ - kTagBox2DNode, -}; - -Box2dTestBedSuite::Box2dTestBedSuite() -{ - for (int entryId = 0; entryId < g_totalEntries; ++entryId) - { - addTestCase(g_testEntries[entryId].name, [entryId](){ - return Box2dTestBed::createWithEntryID(entryId); - }); - } -} - -//------------------------------------------------------------------ -// -// Box2dTestBed -// -//------------------------------------------------------------------ - -Box2dTestBed::Box2dTestBed() -{ -} - -Box2dTestBed::~Box2dTestBed() -{ - _eventDispatcher->removeEventListener(_touchListener); -} - -Box2dTestBed* Box2dTestBed::createWithEntryID(int entryId) -{ - auto layer = new (std::nothrow) Box2dTestBed(); - layer->initWithEntryID(entryId); - layer->autorelease(); - - return layer; -} - -bool Box2dTestBed::initWithEntryID(int entryId) -{ - if (!TestCase::init()) - { - return false; - } - auto director = Director::getInstance(); - Vec2 visibleOrigin = director->getVisibleOrigin(); - Size visibleSize = director->getVisibleSize(); - - m_entryID = entryId; - - Box2DView* view = Box2DView::viewWithEntryID( entryId ); - addChild(view, 0, kTagBox2DNode); - view->setScale(15); - view->setAnchorPoint( Vec2(0,0) ); - view->setPosition(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3); - auto label = Label::createWithTTF(view->title().c_str(), "fonts/arial.ttf", 28); - addChild(label, 1); - label->setPosition(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50); - - // Adds touch event listener - auto listener = EventListenerTouchOneByOne::create(); - listener->setSwallowTouches(true); - - listener->onTouchBegan = CC_CALLBACK_2(Box2dTestBed::onTouchBegan, this); - listener->onTouchMoved = CC_CALLBACK_2(Box2dTestBed::onTouchMoved, this); - - _eventDispatcher->addEventListenerWithFixedPriority(listener, 1); - - _touchListener = listener; - - return true; -} - -bool Box2dTestBed::onTouchBegan(Touch* touch, Event* event) -{ - return true; -} - -void Box2dTestBed::onTouchMoved(Touch* touch, Event* event) -{ - auto diff = touch->getDelta(); - auto node = getChildByTag( kTagBox2DNode ); - auto currentPos = node->getPosition(); - node->setPosition(currentPos + diff); -} - -//------------------------------------------------------------------ -// -// Box2DView -// -//------------------------------------------------------------------ -Box2DView::Box2DView() -{ -} - -Box2DView* Box2DView::viewWithEntryID(int entryId) -{ - Box2DView* pView = new (std::nothrow) Box2DView(); - pView->initWithEntryID(entryId); - pView->autorelease(); - - return pView; -} - -bool Box2DView::initWithEntryID(int entryId) -{ - m_entry = g_testEntries + entryId; - m_test = m_entry->createFcn(); - - - // Adds Touch Event Listener - auto listener = EventListenerTouchOneByOne::create(); - listener->setSwallowTouches(true); - - listener->onTouchBegan = CC_CALLBACK_2(Box2DView::onTouchBegan, this); - listener->onTouchMoved = CC_CALLBACK_2(Box2DView::onTouchMoved, this); - listener->onTouchEnded = CC_CALLBACK_2(Box2DView::onTouchEnded, this); - - _eventDispatcher->addEventListenerWithFixedPriority(listener, -10); - _touchListener = listener; - - auto keyboardListener = EventListenerKeyboard::create(); - keyboardListener->onKeyPressed = CC_CALLBACK_2(Box2DView::onKeyPressed, this); - keyboardListener->onKeyReleased = CC_CALLBACK_2(Box2DView::onKeyReleased, this); - _eventDispatcher->addEventListenerWithFixedPriority(keyboardListener, -11); - _keyboardListener = keyboardListener; - - return true; -} - -std::string Box2DView::title() const -{ - return std::string(m_entry->name); -} - -void Box2DView::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) -{ - Layer::draw(renderer, transform, flags); - - _customCmd.init(_globalZOrder, transform, flags); - _customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this, transform, flags); - renderer->addCommand(&_customCmd); -} - -void Box2DView::onDraw(const Mat4 &transform, uint32_t flags) -{ - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when setting matrix stack"); - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); - -// glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - m_test->Step(&settings); - m_test->m_world->DrawDebugData(); - - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); -} - -Box2DView::~Box2DView() -{ - // Removes Touch Event Listener - _eventDispatcher->removeEventListener(_touchListener); - _eventDispatcher->removeEventListener(_keyboardListener); - delete m_test; -} - -bool Box2DView::onTouchBegan(Touch* touch, Event* event) -{ - auto touchLocation = touch->getLocation(); - - auto nodePosition = convertToNodeSpace( touchLocation ); - log("Box2DView::onTouchBegan, pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); - - return m_test->MouseDown(b2Vec2(nodePosition.x,nodePosition.y)); -} - -void Box2DView::onTouchMoved(Touch* touch, Event* event) -{ - auto touchLocation = touch->getLocation(); - auto nodePosition = convertToNodeSpace( touchLocation ); - - log("Box2DView::onTouchMoved, pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); - - m_test->MouseMove(b2Vec2(nodePosition.x,nodePosition.y)); -} - -void Box2DView::onTouchEnded(Touch* touch, Event* event) -{ - auto touchLocation = touch->getLocation(); - auto nodePosition = convertToNodeSpace( touchLocation ); - - log("Box2DView::onTouchEnded, pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); - - m_test->MouseUp(b2Vec2(nodePosition.x,nodePosition.y)); -} - -void Box2DView::onKeyPressed(EventKeyboard::KeyCode code, Event* event) -{ - log("Box2dView:onKeyPressed, keycode: %d", static_cast(code)); - m_test->Keyboard(static_cast(code)); -} - -void Box2DView::onKeyReleased(EventKeyboard::KeyCode code, Event* event) -{ - log("onKeyReleased, keycode: %d", static_cast(code)); - m_test->KeyboardUp(static_cast(code)); -} diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h deleted file mode 100644 index b5f26d329d..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef _BOX2D_VIEW_H_ -#define _BOX2D_VIEW_H_ - -#include "../BaseTest.h" -#include "renderer/CCCustomCommand.h" - -DEFINE_TEST_SUITE(Box2dTestBedSuite); - -class Box2dTestBed : public TestCase -{ -public: - static Box2dTestBed* createWithEntryID(int entryId); - - Box2dTestBed(); - virtual ~Box2dTestBed(); - - bool initWithEntryID(int entryId); - - bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event); - void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event); -private: - int m_entryID; - cocos2d::EventListenerTouchOneByOne* _touchListener; -}; - -struct TestEntry; -class Test; -class Box2DView : public cocos2d::Layer -{ - cocos2d::EventListenerTouchOneByOne* _touchListener; - cocos2d::EventListenerKeyboard* _keyboardListener; - TestEntry* m_entry; - Test* m_test; - int m_entryID; -public: - Box2DView(); - virtual ~Box2DView(); - - bool initWithEntryID(int entryId); - std::string title() const; - virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override; - -// virtual void registerWithTouchDispatcher(); - bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event)override; - void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event)override; - void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event)override; - - void onKeyPressed(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event)override; - void onKeyReleased(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event)override; - //virtual void accelerometer(UIAccelerometer* accelerometer, cocos2d::Acceleration* acceleration); - - static Box2DView* viewWithEntryID(int entryId); -protected: - void onDraw(const cocos2d::Mat4& transform, uint32_t flags); - - cocos2d::CustomCommand _customCmd; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp b/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp deleted file mode 100644 index 25c4baa5be..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com - * - * iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - */ - - //TODO minggo - -#include "GLES-Render.h" -#include "cocos2d.h" -#include -#include -#include - -USING_NS_CC; - -GLESDebugDraw::GLESDebugDraw() - : mRatio( 1.0f ) -{ - this->initShader(); -} - -GLESDebugDraw::GLESDebugDraw( float32 ratio ) - : mRatio( ratio ) -{ - this->initShader(); -} - -void GLESDebugDraw::initShader( void ) -{ -// mShaderProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); -// -// mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color"); -} - -void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); -// - b2Vec2* vertices = new b2Vec2[vertexCount]; - for( int i=0;isetUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); -// -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); -// glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -// -// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,vertexCount); -// -// -// CHECK_GL_ERROR_DEBUG(); - - delete[] vertices; -} - -void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); - - b2Vec2* vertices = new b2Vec2[vertexCount]; - for( int i=0;isetUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); -// -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); -// -// glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); -// -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); -// glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -// -// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(2,vertexCount*2); -// -// CHECK_GL_ERROR_DEBUG(); - - delete[] vertices; -} - -void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); - - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - float* glVertices = new (std::nothrow) float[vertexCount*2]; - for (int i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x * mRatio; - glVertices[i*2+1]=v.y * mRatio; - theta += k_increment; - } - -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); - -// glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -// -// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,vertexCount); -// -// CHECK_GL_ERROR_DEBUG(); - - delete[] glVertices; -} - -void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); - - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - float* glVertices = new (std::nothrow) float[vertexCount*2]; - for (int i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x * mRatio; - glVertices[i*2+1]=v.y * mRatio; - theta += k_increment; - } - -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); -// glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); -// -// -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); -// glDrawArrays(GL_LINE_LOOP, 0, vertexCount); - - // Draw the axis line - DrawSegment(center,center+radius*axis,color); - - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(2,vertexCount*2); - -// CHECK_GL_ERROR_DEBUG(); - - delete[] glVertices; -} - -void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); -// -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); - -// GLfloat glVertices[] = -// { -// p1.x * mRatio, p1.y * mRatio, -// p2.x * mRatio, p2.y * mRatio -// }; -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); - -// glDrawArrays(GL_LINES, 0, 2); -// -// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2); -// -// CHECK_GL_ERROR_DEBUG(); -} - -void GLESDebugDraw::DrawTransform(const b2Transform& xf) -{ - b2Vec2 p1 = xf.p, p2; - const float32 k_axisScale = 0.4f; - p2 = p1 + k_axisScale * xf.q.GetXAxis(); - DrawSegment(p1, p2, b2Color(1,0,0)); - - p2 = p1 + k_axisScale * xf.q.GetYAxis(); - DrawSegment(p1,p2,b2Color(0,1,0)); -} - -void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); -// -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); -// -// // glPointSize(size); -// -// GLfloat glVertices[] = { -// p.x * mRatio, p.y * mRatio -// }; -// -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); - -// glDrawArrays(GL_POINTS, 0, 1); -// // glPointSize(1.0f); -// -// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,1); -// -// CHECK_GL_ERROR_DEBUG(); -} - -void GLESDebugDraw::DrawString(int x, int y, const char *string, ...) -{ -// NSLog(@"DrawString: unsupported: %s", string); - //printf(string); - /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ -} - -void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color) -{ -// mShaderProgram->use(); -// mShaderProgram->setUniformsForBuiltins(); -// -// mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); - -// GLfloat glVertices[] = { -// aabb->lowerBound.x * mRatio, aabb->lowerBound.y * mRatio, -// aabb->upperBound.x * mRatio, aabb->lowerBound.y * mRatio, -// aabb->upperBound.x * mRatio, aabb->upperBound.y * mRatio, -// aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio -// }; - -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); -// glDrawArrays(GL_LINE_LOOP, 0, 4); -// -// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4); -// -// CHECK_GL_ERROR_DEBUG(); -} diff --git a/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.h b/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.h deleted file mode 100644 index a679946004..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef RENDER_H -#define RENDER_H - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -struct b2AABB; - -// This class implements debug drawing callbacks that are invoked -// inside b2World::Step. -class GLESDebugDraw : public b2Draw -{ - float32 mRatio; - int mColorLocation; - - void initShader( void ); -public: - GLESDebugDraw(); - - GLESDebugDraw( float32 ratio ); - - virtual void DrawPolygon(const b2Vec2* vertices, int vertexCount, const b2Color& color); - - virtual void DrawSolidPolygon(const b2Vec2* vertices, int vertexCount, const b2Color& color); - - virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); - - virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); - - virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); - - virtual void DrawTransform(const b2Transform& xf); - - virtual void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); - - virtual void DrawString(int x, int y, const char* string, ...); - - virtual void DrawAABB(b2AABB* aabb, const b2Color& color); -}; - - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp b/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp deleted file mode 100644 index 556ab4f9a3..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp +++ /dev/null @@ -1,460 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "Test.h" -#include "GLES-Render.h" - -#include - -void DestructionListener::SayGoodbye(b2Joint* joint) -{ - if (test->m_mouseJoint == joint) - { - test->m_mouseJoint = nullptr; - } - else - { - test->JointDestroyed(joint); - } -} - -Test::Test() -{ - b2Vec2 gravity; - gravity.Set(0.0f, -10.0f); - m_world = new b2World(gravity); - m_bomb = nullptr; - m_textLine = 30; - m_mouseJoint = nullptr; - m_pointCount = 0; - - m_destructionListener.test = this; - m_world->SetDestructionListener(&m_destructionListener); - m_world->SetContactListener(this); - m_world->SetDebugDraw(&m_debugDraw); - - m_bombSpawning = false; - - m_stepCount = 0; - - b2BodyDef bodyDef; - m_groundBody = m_world->CreateBody(&bodyDef); - - memset(&m_maxProfile, 0, sizeof(b2Profile)); - memset(&m_totalProfile, 0, sizeof(b2Profile)); -} - -Test::~Test() -{ - // By deleting the world, we delete the bomb, mouse joint, etc. - delete m_world; - m_world = nullptr; -} - -void Test::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) -{ - const b2Manifold* manifold = contact->GetManifold(); - - if (manifold->pointCount == 0) - { - return; - } - - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - b2PointState state1[b2_maxManifoldPoints], state2[b2_maxManifoldPoints]; - b2GetPointStates(state1, state2, oldManifold, manifold); - - b2WorldManifold worldManifold; - contact->GetWorldManifold(&worldManifold); - - for (int32 i = 0; i < manifold->pointCount && m_pointCount < k_maxContactPoints; ++i) - { - ContactPoint* cp = m_points + m_pointCount; - cp->fixtureA = fixtureA; - cp->fixtureB = fixtureB; - cp->position = worldManifold.points[i]; - cp->normal = worldManifold.normal; - cp->state = state2[i]; - cp->normalImpulse = manifold->points[i].normalImpulse; - cp->tangentImpulse = manifold->points[i].tangentImpulse; - cp->separation = worldManifold.separations[i]; - ++m_pointCount; - } -} - -void Test::DrawTitle(const char *string) -{ - m_debugDraw.DrawString(5, DRAW_STRING_NEW_LINE, string); - m_textLine = 2 * DRAW_STRING_NEW_LINE; -} - -class QueryCallback : public b2QueryCallback -{ -public: - QueryCallback(const b2Vec2& point) - { - m_point = point; - m_fixture = nullptr; - } - - bool ReportFixture(b2Fixture* fixture) - { - b2Body* body = fixture->GetBody(); - if (body->GetType() == b2_dynamicBody) - { - bool inside = fixture->TestPoint(m_point); - if (inside) - { - m_fixture = fixture; - - // We are done, terminate the query. - return false; - } - } - - // Continue the query. - return true; - } - - b2Vec2 m_point; - b2Fixture* m_fixture; -}; - -bool Test::MouseDown(const b2Vec2& p) -{ - m_mouseWorld = p; - - if (m_mouseJoint != nullptr) - { - return false; - } - - // Make a small box. - b2AABB aabb; - b2Vec2 d; - d.Set(0.001f, 0.001f); - aabb.lowerBound = p - d; - aabb.upperBound = p + d; - - // Query the world for overlapping shapes. - QueryCallback callback(p); - m_world->QueryAABB(&callback, aabb); - - if (callback.m_fixture) - { - b2Body* body = callback.m_fixture->GetBody(); - b2MouseJointDef md; - md.bodyA = m_groundBody; - md.bodyB = body; - md.target = p; - md.maxForce = 1000.0f * body->GetMass(); - m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md); - body->SetAwake(true); - return true; - } - - return false; -} - -void Test::SpawnBomb(const b2Vec2& worldPt) -{ - m_bombSpawnPoint = worldPt; - m_bombSpawning = true; -} - -void Test::CompleteBombSpawn(const b2Vec2& p) -{ - if (m_bombSpawning == false) - { - return; - } - - const float multiplier = 30.0f; - b2Vec2 vel = m_bombSpawnPoint - p; - vel *= multiplier; - LaunchBomb(m_bombSpawnPoint,vel); - m_bombSpawning = false; -} - -void Test::ShiftMouseDown(const b2Vec2& p) -{ - m_mouseWorld = p; - - if (m_mouseJoint != nullptr) - { - return; - } - - SpawnBomb(p); -} - -void Test::MouseUp(const b2Vec2& p) -{ - if (m_mouseJoint) - { - m_world->DestroyJoint(m_mouseJoint); - m_mouseJoint = nullptr; - } - - if (m_bombSpawning) - { - CompleteBombSpawn(p); - } -} - -void Test::MouseMove(const b2Vec2& p) -{ - m_mouseWorld = p; - - if (m_mouseJoint) - { - m_mouseJoint->SetTarget(p); - } -} - -void Test::LaunchBomb() -{ - b2Vec2 p(RandomFloat(-15.0f, 15.0f), 30.0f); - b2Vec2 v = -5.0f * p; - LaunchBomb(p, v); -} - -void Test::LaunchBomb(const b2Vec2& position, const b2Vec2& velocity) -{ - if (m_bomb) - { - m_world->DestroyBody(m_bomb); - m_bomb = nullptr; - } - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = position; - bd.bullet = true; - m_bomb = m_world->CreateBody(&bd); - m_bomb->SetLinearVelocity(velocity); - - b2CircleShape circle; - circle.m_radius = 0.3f; - - b2FixtureDef fd; - fd.shape = &circle; - fd.density = 20.0f; - fd.restitution = 0.0f; - - b2Vec2 minV = position - b2Vec2(0.3f,0.3f); - b2Vec2 maxV = position + b2Vec2(0.3f,0.3f); - - b2AABB aabb; - aabb.lowerBound = minV; - aabb.upperBound = maxV; - - m_bomb->CreateFixture(&fd); -} - -void Test::Step(Settings* settings) -{ - float32 timeStep = settings->hz > 0.0f ? 1.0f / settings->hz : float32(0.0f); - - if (settings->pause) - { - if (settings->singleStep) - { - settings->singleStep = 0; - } - else - { - timeStep = 0.0f; - } - - m_debugDraw.DrawString(5, m_textLine, "****PAUSED****"); - m_textLine += DRAW_STRING_NEW_LINE; - } - - uint32 flags = 0; - flags += settings->drawShapes * b2Draw::e_shapeBit; - flags += settings->drawJoints * b2Draw::e_jointBit; - flags += settings->drawAABBs * b2Draw::e_aabbBit; - flags += settings->drawCOMs * b2Draw::e_centerOfMassBit; - m_debugDraw.SetFlags(flags); - - m_world->SetAllowSleeping(settings->enableSleep > 0); - m_world->SetWarmStarting(settings->enableWarmStarting > 0); - m_world->SetContinuousPhysics(settings->enableContinuous > 0); - m_world->SetSubStepping(settings->enableSubStepping > 0); - - m_pointCount = 0; - - m_world->Step(timeStep, settings->velocityIterations, settings->positionIterations); - - m_world->DrawDebugData(); - - if (timeStep > 0.0f) - { - ++m_stepCount; - } - - if (settings->drawStats) - { - int32 bodyCount = m_world->GetBodyCount(); - int32 contactCount = m_world->GetContactCount(); - int32 jointCount = m_world->GetJointCount(); - m_debugDraw.DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", bodyCount, contactCount, jointCount); - m_textLine += DRAW_STRING_NEW_LINE; - - int32 proxyCount = m_world->GetProxyCount(); - int32 height = m_world->GetTreeHeight(); - int32 balance = m_world->GetTreeBalance(); - float32 quality = m_world->GetTreeQuality(); - m_debugDraw.DrawString(5, m_textLine, "proxies/height/balance/quality = %d/%d/%d/%g", proxyCount, height, balance, quality); - m_textLine += DRAW_STRING_NEW_LINE; - } - - // Track maximum profile times - { - const b2Profile& p = m_world->GetProfile(); - m_maxProfile.step = b2Max(m_maxProfile.step, p.step); - m_maxProfile.collide = b2Max(m_maxProfile.collide, p.collide); - m_maxProfile.solve = b2Max(m_maxProfile.solve, p.solve); - m_maxProfile.solveInit = b2Max(m_maxProfile.solveInit, p.solveInit); - m_maxProfile.solveVelocity = b2Max(m_maxProfile.solveVelocity, p.solveVelocity); - m_maxProfile.solvePosition = b2Max(m_maxProfile.solvePosition, p.solvePosition); - m_maxProfile.solveTOI = b2Max(m_maxProfile.solveTOI, p.solveTOI); - m_maxProfile.broadphase = b2Max(m_maxProfile.broadphase, p.broadphase); - - m_totalProfile.step += p.step; - m_totalProfile.collide += p.collide; - m_totalProfile.solve += p.solve; - m_totalProfile.solveInit += p.solveInit; - m_totalProfile.solveVelocity += p.solveVelocity; - m_totalProfile.solvePosition += p.solvePosition; - m_totalProfile.solveTOI += p.solveTOI; - m_totalProfile.broadphase += p.broadphase; - } - - if (settings->drawProfile) - { - const b2Profile& p = m_world->GetProfile(); - - b2Profile aveProfile; - memset(&aveProfile, 0, sizeof(b2Profile)); - if (m_stepCount > 0) - { - float32 scale = 1.0f / m_stepCount; - aveProfile.step = scale * m_totalProfile.step; - aveProfile.collide = scale * m_totalProfile.collide; - aveProfile.solve = scale * m_totalProfile.solve; - aveProfile.solveInit = scale * m_totalProfile.solveInit; - aveProfile.solveVelocity = scale * m_totalProfile.solveVelocity; - aveProfile.solvePosition = scale * m_totalProfile.solvePosition; - aveProfile.solveTOI = scale * m_totalProfile.solveTOI; - aveProfile.broadphase = scale * m_totalProfile.broadphase; - } - - m_debugDraw.DrawString(5, m_textLine, "step [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.step, aveProfile.step, m_maxProfile.step); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "collide [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.collide, aveProfile.collide, m_maxProfile.collide); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "solve [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solve, aveProfile.solve, m_maxProfile.solve); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "solve init [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveInit, aveProfile.solveInit, m_maxProfile.solveInit); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "solve velocity [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveVelocity, aveProfile.solveVelocity, m_maxProfile.solveVelocity); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "solve position [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solvePosition, aveProfile.solvePosition, m_maxProfile.solvePosition); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "solveTOI [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveTOI, aveProfile.solveTOI, m_maxProfile.solveTOI); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "broad-phase [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.broadphase, aveProfile.broadphase, m_maxProfile.broadphase); - m_textLine += DRAW_STRING_NEW_LINE; - } - - if (m_mouseJoint) - { - b2Vec2 p1 = m_mouseJoint->GetAnchorB(); - b2Vec2 p2 = m_mouseJoint->GetTarget(); - - b2Color c; - c.Set(0.0f, 1.0f, 0.0f); - m_debugDraw.DrawPoint(p1, 4.0f, c); - m_debugDraw.DrawPoint(p2, 4.0f, c); - - c.Set(0.8f, 0.8f, 0.8f); - m_debugDraw.DrawSegment(p1, p2, c); - } - - if (m_bombSpawning) - { - b2Color c; - c.Set(0.0f, 0.0f, 1.0f); - m_debugDraw.DrawPoint(m_bombSpawnPoint, 4.0f, c); - - c.Set(0.8f, 0.8f, 0.8f); - m_debugDraw.DrawSegment(m_mouseWorld, m_bombSpawnPoint, c); - } - - if (settings->drawContactPoints) - { - const float32 k_impulseScale = 0.1f; - const float32 k_axisScale = 0.3f; - - for (int32 i = 0; i < m_pointCount; ++i) - { - ContactPoint* point = m_points + i; - - if (point->state == b2_addState) - { - // Add - m_debugDraw.DrawPoint(point->position, 10.0f, b2Color(0.3f, 0.95f, 0.3f)); - } - else if (point->state == b2_persistState) - { - // Persist - m_debugDraw.DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f)); - } - - if (settings->drawContactNormals == 1) - { - b2Vec2 p1 = point->position; - b2Vec2 p2 = p1 + k_axisScale * point->normal; - m_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.9f)); - } - else if (settings->drawContactImpulse == 1) - { - b2Vec2 p1 = point->position; - b2Vec2 p2 = p1 + k_impulseScale * point->normalImpulse * point->normal; - m_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); - } - - if (settings->drawFrictionImpulse == 1) - { - b2Vec2 tangent = b2Cross(point->normal, 1.0f); - b2Vec2 p1 = point->position; - b2Vec2 p2 = p1 + k_impulseScale * point->tangentImpulse * tangent; - m_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); - } - } - } -} - -void Test::ShiftOrigin(const b2Vec2& newOrigin) -{ - m_world->ShiftOrigin(newOrigin); -} diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Test.h b/tests/cpp-tests/Classes/Box2DTestBed/Test.h deleted file mode 100644 index 7ec5b1c9f5..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Test.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TEST_H -#define TEST_H - -#include -#include "GLES-Render.h" - -#include - -class Test; -struct Settings; - -typedef Test* TestCreateFcn(); - -#define RAND_LIMIT 32767 -#define DRAW_STRING_NEW_LINE 25 - -/// Random number in range [-1,1] -inline float32 RandomFloat() -{ - float32 r = (float32)(std::rand() & (RAND_LIMIT)); - r /= RAND_LIMIT; - r = 2.0f * r - 1.0f; - return r; -} - -/// Random floating point number in range [lo, hi] -inline float32 RandomFloat(float32 lo, float32 hi) -{ - float32 r = (float32)(std::rand() & (RAND_LIMIT)); - r /= RAND_LIMIT; - r = (hi - lo) * r + lo; - return r; -} - -/// Test settings. Some can be controlled in the GUI. -struct Settings -{ - Settings() - { - viewCenter.Set(0.0f, 20.0f); - hz = 60.0f; - velocityIterations = 8; - positionIterations = 3; - drawShapes = 1; - drawJoints = 1; - drawAABBs = 0; - drawContactPoints = 0; - drawContactNormals = 0; - drawContactImpulse = 0; - drawFrictionImpulse = 0; - drawCOMs = 0; - drawStats = 0; - drawProfile = 0; - enableWarmStarting = 1; - enableContinuous = 1; - enableSubStepping = 0; - enableSleep = 1; - pause = 0; - singleStep = 0; - } - - b2Vec2 viewCenter; - float32 hz; - int32 velocityIterations; - int32 positionIterations; - int32 drawShapes; - int32 drawJoints; - int32 drawAABBs; - int32 drawContactPoints; - int32 drawContactNormals; - int32 drawContactImpulse; - int32 drawFrictionImpulse; - int32 drawCOMs; - int32 drawStats; - int32 drawProfile; - int32 enableWarmStarting; - int32 enableContinuous; - int32 enableSubStepping; - int32 enableSleep; - int32 pause; - int32 singleStep; -}; - -struct TestEntry -{ - const char *name; - TestCreateFcn *createFcn; -}; - -extern TestEntry g_testEntries[]; -// This is called when a joint in the world is implicitly destroyed -// because an attached body is destroyed. This gives us a chance to -// nullify the mouse joint. -class DestructionListener : public b2DestructionListener -{ -public: - void SayGoodbye(b2Fixture* fixture) { B2_NOT_USED(fixture); } - void SayGoodbye(b2Joint* joint); - - Test* test; -}; - -const int32 k_maxContactPoints = 2048; - -struct ContactPoint -{ - b2Fixture* fixtureA; - b2Fixture* fixtureB; - b2Vec2 normal; - b2Vec2 position; - b2PointState state; - float32 normalImpulse; - float32 tangentImpulse; - float32 separation; -}; - -class Test : public b2ContactListener -{ -public: - - Test(); - virtual ~Test(); - - void DrawTitle(const char *string); - virtual void Step(Settings* settings); - virtual void Keyboard(unsigned char key) { B2_NOT_USED(key); } - virtual void KeyboardUp(unsigned char key) { B2_NOT_USED(key); } - void ShiftMouseDown(const b2Vec2& p); - virtual bool MouseDown(const b2Vec2& p); - virtual void MouseUp(const b2Vec2& p); - void MouseMove(const b2Vec2& p); - void LaunchBomb(); - void LaunchBomb(const b2Vec2& position, const b2Vec2& velocity); - - void SpawnBomb(const b2Vec2& worldPt); - void CompleteBombSpawn(const b2Vec2& p); - - // Let derived tests know that a joint was destroyed. - virtual void JointDestroyed(b2Joint* joint) { B2_NOT_USED(joint); } - - // Callbacks for derived classes. - virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); } - virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); } - virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold); - virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) - { - B2_NOT_USED(contact); - B2_NOT_USED(impulse); - } - - void ShiftOrigin(const b2Vec2& newOrigin); - -protected: - friend class DestructionListener; - friend class BoundaryListener; - friend class ContactListener; - friend class Box2DView; - - b2Body* m_groundBody; - b2AABB m_worldAABB; - ContactPoint m_points[k_maxContactPoints]; - int32 m_pointCount; - DestructionListener m_destructionListener; - GLESDebugDraw m_debugDraw; - int32 m_textLine; - b2World* m_world; - b2Body* m_bomb; - b2MouseJoint* m_mouseJoint; - b2Vec2 m_bombSpawnPoint; - bool m_bombSpawning; - b2Vec2 m_mouseWorld; - int32 m_stepCount; - - b2Profile m_maxProfile; - b2Profile m_totalProfile; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/TestEntries.cpp b/tests/cpp-tests/Classes/Box2DTestBed/TestEntries.cpp deleted file mode 100644 index 57d437a92b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/TestEntries.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -#include -using namespace std; - -#include "Test.h" -#include "Tests/AddPair.h" -#include "Tests/ApplyForce.h" -#include "Tests/BodyTypes.h" -#include "Tests/Breakable.h" -#include "Tests/Bridge.h" -#include "Tests/BulletTest.h" -#include "Tests/Cantilever.h" -#include "Tests/Car.h" -#include "Tests/ContinuousTest.h" -#include "Tests/Chain.h" -#include "Tests/CharacterCollision.h" -#include "Tests/CollisionFiltering.h" -#include "Tests/CollisionProcessing.h" -#include "Tests/CompoundShapes.h" -#include "Tests/Confined.h" -#include "Tests/ConvexHull.h" -#include "Tests/ConveyorBelt.h" -#include "Tests/DistanceTest.h" -#include "Tests/Dominos.h" -#include "Tests/DumpShell.h" -#include "Tests/DynamicTreeTest.h" -#include "Tests/EdgeShapes.h" -#include "Tests/EdgeTest.h" -#include "Tests/Gears.h" -#include "Tests/Mobile.h" -#include "Tests/MobileBalanced.h" -#include "Tests/MotorJoint.h" -#include "Tests/OneSidedPlatform.h" -#include "Tests/Pinball.h" -#include "Tests/PolyCollision.h" -#include "Tests/PolyShapes.h" -#include "Tests/Prismatic.h" -#include "Tests/Pulleys.h" -#include "Tests/Pyramid.h" -#include "Tests/RayCast.h" -#include "Tests/Revolute.h" -#include "Tests/RopeJoint.h" -#include "Tests/SensorTest.h" -#include "Tests/ShapeEditing.h" -#include "Tests/SliderCrank.h" -#include "Tests/SphereStack.h" -#include "Tests/TheoJansen.h" -#include "Tests/Tiles.h" -#include "Tests/TimeOfImpact.h" -#include "Tests/Tumbler.h" -#include "Tests/VaryingFriction.h" -#include "Tests/VaryingRestitution.h" -#include "Tests/VerticalStack.h" -#include "Tests/Web.h" - -TestEntry g_testEntries[] = -{ - {"Ray-Cast", RayCast::Create}, - {"Dump Shell", DumpShell::Create}, - {"Convex Hull", ConvexHull::Create}, - {"Apply Force", ApplyForce::Create}, - {"Continuous Test", ContinuousTest::Create}, - // {"Time of Impact", TimeOfImpact::Create}, - {"Motor Joint", MotorJoint::Create}, - {"One-Sided Platform", OneSidedPlatform::Create}, - {"Mobile", Mobile::Create}, - {"MobileBalanced", MobileBalanced::Create}, - {"Conveyor Belt", ConveyorBelt::Create}, - {"Gears", Gears::Create}, - {"Varying Restitution", VaryingRestitution::Create}, - {"Tumbler", Tumbler::Create}, - {"Tiles", Tiles::Create}, - {"Cantilever", Cantilever::Create}, - {"Character Collision", CharacterCollision::Create}, - {"Edge Test", EdgeTest::Create}, - {"Body Types", BodyTypes::Create}, - {"Shape Editing", ShapeEditing::Create}, - {"Car", Car::Create}, - {"Prismatic", Prismatic::Create}, - {"Vertical Stack", VerticalStack::Create}, - {"SphereStack", SphereStack::Create}, - {"Revolute", Revolute::Create}, - {"Pulleys", Pulleys::Create}, - {"Polygon Shapes", PolyShapes::Create}, - {"Web", Web::Create}, - {"RopeJoint", RopeJoint::Create}, - {"Pinball", Pinball::Create}, - {"Bullet Test", BulletTest::Create}, - {"Confined", Confined::Create}, - {"Pyramid", Pyramid::Create}, - {"Theo Jansen's Walker", TheoJansen::Create}, - {"Edge Shapes", EdgeShapes::Create}, - {"PolyCollision", PolyCollision::Create}, - {"Bridge", Bridge::Create}, - {"Breakable", Breakable::Create}, - {"Chain", Chain::Create}, - {"Collision Filtering", CollisionFiltering::Create}, - {"Collision Processing", CollisionProcessing::Create}, - {"Compound Shapes", CompoundShapes::Create}, - {"Distance Test", DistanceTest::Create}, - {"Dominos", Dominos::Create}, - {"Dynamic Tree", DynamicTreeTest::Create}, - {"Sensor Test", SensorTest::Create}, - {"Slider Crank", SliderCrank::Create}, - {"Varying Friction", VaryingFriction::Create}, - {"Add Pair Stress Test", AddPair::Create}, -}; - -int g_totalEntries = sizeof(g_testEntries) / sizeof(g_testEntries[0]); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/AddPair.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/AddPair.h deleted file mode 100644 index 6f995e0ce8..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/AddPair.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright (c) 2006-2012 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef AddPair_H -#define AddPair_H - -class AddPair : public Test -{ -public: - - AddPair() - { - m_world->SetGravity(b2Vec2(0.0f,0.0f)); - { - b2CircleShape shape; - shape.m_p.SetZero(); - shape.m_radius = 0.1f; - - float minX = -6.0f; - float maxX = 0.0f; - float minY = 4.0f; - float maxY = 6.0f; - - for (int32 i = 0; i < 400; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = b2Vec2(RandomFloat(minX,maxX),RandomFloat(minY,maxY)); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 0.01f); - } - } - - { - b2PolygonShape shape; - shape.SetAsBox(1.5f, 1.5f); - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-40.0f,5.0f); - bd.bullet = true; - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 1.0f); - body->SetLinearVelocity(b2Vec2(150.0f, 0.0f)); - } - } - - static Test* Create() - { - return new AddPair; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ApplyForce.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/ApplyForce.h deleted file mode 100644 index b4bd10f425..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ApplyForce.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef APPLY_FORCE_H -#define APPLY_FORCE_H - -class ApplyForce : public Test -{ -public: - ApplyForce() - { - m_world->SetGravity(b2Vec2(0.0f, 0.0f)); - - const float32 k_restitution = 0.4f; - - b2Body* ground; - { - b2BodyDef bd; - bd.position.Set(0.0f, 20.0f); - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - - b2FixtureDef sd; - sd.shape = &shape; - sd.density = 0.0f; - sd.restitution = k_restitution; - - // Left vertical - shape.Set(b2Vec2(-20.0f, -20.0f), b2Vec2(-20.0f, 20.0f)); - ground->CreateFixture(&sd); - - // Right vertical - shape.Set(b2Vec2(20.0f, -20.0f), b2Vec2(20.0f, 20.0f)); - ground->CreateFixture(&sd); - - // Top horizontal - shape.Set(b2Vec2(-20.0f, 20.0f), b2Vec2(20.0f, 20.0f)); - ground->CreateFixture(&sd); - - // Bottom horizontal - shape.Set(b2Vec2(-20.0f, -20.0f), b2Vec2(20.0f, -20.0f)); - ground->CreateFixture(&sd); - } - - { - b2Transform xf1; - xf1.q.Set(0.3524f * b2_pi); - xf1.p = xf1.q.GetXAxis(); - - b2Vec2 vertices[3]; - vertices[0] = b2Mul(xf1, b2Vec2(-1.0f, 0.0f)); - vertices[1] = b2Mul(xf1, b2Vec2(1.0f, 0.0f)); - vertices[2] = b2Mul(xf1, b2Vec2(0.0f, 0.5f)); - - b2PolygonShape poly1; - poly1.Set(vertices, 3); - - b2FixtureDef sd1; - sd1.shape = &poly1; - sd1.density = 4.0f; - - b2Transform xf2; - xf2.q.Set(-0.3524f * b2_pi); - xf2.p = -xf2.q.GetXAxis(); - - vertices[0] = b2Mul(xf2, b2Vec2(-1.0f, 0.0f)); - vertices[1] = b2Mul(xf2, b2Vec2(1.0f, 0.0f)); - vertices[2] = b2Mul(xf2, b2Vec2(0.0f, 0.5f)); - - b2PolygonShape poly2; - poly2.Set(vertices, 3); - - b2FixtureDef sd2; - sd2.shape = &poly2; - sd2.density = 2.0f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.angularDamping = 2.0f; - bd.linearDamping = 0.5f; - - bd.position.Set(0.0f, 2.0); - bd.angle = b2_pi; - bd.allowSleep = false; - m_body = m_world->CreateBody(&bd); - m_body->CreateFixture(&sd1); - m_body->CreateFixture(&sd2); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - fd.friction = 0.3f; - - for (int i = 0; i < 10; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - - bd.position.Set(0.0f, 5.0f + 1.54f * i); - b2Body* body = m_world->CreateBody(&bd); - - body->CreateFixture(&fd); - - float32 gravity = 10.0f; - float32 I = body->GetInertia(); - float32 mass = body->GetMass(); - - // For a circle: I = 0.5 * m * r * r ==> r = sqrt(2 * I / m) - float32 radius = b2Sqrt(2.0f * I / mass); - - b2FrictionJointDef jd; - jd.localAnchorA.SetZero(); - jd.localAnchorB.SetZero(); - jd.bodyA = ground; - jd.bodyB = body; - jd.collideConnected = true; - jd.maxForce = mass * gravity; - jd.maxTorque = mass * radius * gravity; - - m_world->CreateJoint(&jd); - } - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'w': - { - b2Vec2 f = m_body->GetWorldVector(b2Vec2(0.0f, -200.0f)); - b2Vec2 p = m_body->GetWorldPoint(b2Vec2(0.0f, 2.0f)); - m_body->ApplyForce(f, p, true); - } - break; - - case 'a': - { - m_body->ApplyTorque(50.0f, true); - } - break; - - case 'd': - { - m_body->ApplyTorque(-50.0f, true); - } - break; - } - } - - static Test* Create() - { - return new ApplyForce; - } - - b2Body* m_body; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/BodyTypes.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/BodyTypes.h deleted file mode 100644 index 050b611aca..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/BodyTypes.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BODY_TYPES_H -#define BODY_TYPES_H - -class BodyTypes : public Test -{ -public: - BodyTypes() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); - - b2FixtureDef fd; - fd.shape = &shape; - - ground->CreateFixture(&fd); - } - - // Define attachment - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 3.0f); - m_attachment = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.5f, 2.0f); - m_attachment->CreateFixture(&shape, 2.0f); - } - - // Define platform - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-4.0f, 5.0f); - m_platform = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.5f, 4.0f, b2Vec2(4.0f, 0.0f), 0.5f * b2_pi); - - b2FixtureDef fd; - fd.shape = &shape; - fd.friction = 0.6f; - fd.density = 2.0f; - m_platform->CreateFixture(&fd); - - b2RevoluteJointDef rjd; - rjd.Initialize(m_attachment, m_platform, b2Vec2(0.0f, 5.0f)); - rjd.maxMotorTorque = 50.0f; - rjd.enableMotor = true; - m_world->CreateJoint(&rjd); - - b2PrismaticJointDef pjd; - pjd.Initialize(ground, m_platform, b2Vec2(0.0f, 5.0f), b2Vec2(1.0f, 0.0f)); - - pjd.maxMotorForce = 1000.0f; - pjd.enableMotor = true; - pjd.lowerTranslation = -10.0f; - pjd.upperTranslation = 10.0f; - pjd.enableLimit = true; - - m_world->CreateJoint(&pjd); - - m_speed = 3.0f; - } - - // Create a payload - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 8.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.75f, 0.75f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.friction = 0.6f; - fd.density = 2.0f; - - body->CreateFixture(&fd); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'd': - m_platform->SetType(b2_dynamicBody); - break; - - case 's': - m_platform->SetType(b2_staticBody); - break; - - case 'k': - m_platform->SetType(b2_kinematicBody); - m_platform->SetLinearVelocity(b2Vec2(-m_speed, 0.0f)); - m_platform->SetAngularVelocity(0.0f); - break; - } - } - - void Step(Settings* settings) - { - // Drive the kinematic body. - if (m_platform->GetType() == b2_kinematicBody) - { - b2Vec2 p = m_platform->GetTransform().p; - b2Vec2 v = m_platform->GetLinearVelocity(); - - if ((p.x < -10.0f && v.x < 0.0f) || - (p.x > 10.0f && v.x > 0.0f)) - { - v.x = -v.x; - m_platform->SetLinearVelocity(v); - } - } - - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Keys: (d) dynamic, (s) static, (k) kinematic"); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new BodyTypes; - } - - b2Body* m_attachment; - b2Body* m_platform; - float32 m_speed; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Breakable.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Breakable.h deleted file mode 100644 index 521ae7a090..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Breakable.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -* Copyright (c) 2008-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BREAKABLE_TEST_H -#define BREAKABLE_TEST_H - -// This is used to test sensor shapes. -class Breakable : public Test -{ -public: - - enum - { - e_count = 7 - }; - - Breakable() - { - // Ground body - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - // Breakable dynamic body - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 40.0f); - bd.angle = 0.25f * b2_pi; - m_body1 = m_world->CreateBody(&bd); - - m_shape1.SetAsBox(0.5f, 0.5f, b2Vec2(-0.5f, 0.0f), 0.0f); - m_piece1 = m_body1->CreateFixture(&m_shape1, 1.0f); - - m_shape2.SetAsBox(0.5f, 0.5f, b2Vec2(0.5f, 0.0f), 0.0f); - m_piece2 = m_body1->CreateFixture(&m_shape2, 1.0f); - } - - m_break = false; - m_broke = false; - } - - void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) - { - if (m_broke) - { - // The body already broke. - return; - } - - // Should the body break? - int32 count = contact->GetManifold()->pointCount; - - float32 maxImpulse = 0.0f; - for (int32 i = 0; i < count; ++i) - { - maxImpulse = b2Max(maxImpulse, impulse->normalImpulses[i]); - } - - if (maxImpulse > 40.0f) - { - // Flag the body for breaking. - m_break = true; - } - } - - void Break() - { - // Create two bodies from one. - b2Body* body1 = m_piece1->GetBody(); - b2Vec2 center = body1->GetWorldCenter(); - - body1->DestroyFixture(m_piece2); - m_piece2 = NULL; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = body1->GetPosition(); - bd.angle = body1->GetAngle(); - - b2Body* body2 = m_world->CreateBody(&bd); - m_piece2 = body2->CreateFixture(&m_shape2, 1.0f); - - // Compute consistent velocities for new bodies based on - // cached velocity. - b2Vec2 center1 = body1->GetWorldCenter(); - b2Vec2 center2 = body2->GetWorldCenter(); - - b2Vec2 velocity1 = m_velocity + b2Cross(m_angularVelocity, center1 - center); - b2Vec2 velocity2 = m_velocity + b2Cross(m_angularVelocity, center2 - center); - - body1->SetAngularVelocity(m_angularVelocity); - body1->SetLinearVelocity(velocity1); - - body2->SetAngularVelocity(m_angularVelocity); - body2->SetLinearVelocity(velocity2); - } - - void Step(Settings* settings) - { - if (m_break) - { - Break(); - m_broke = true; - m_break = false; - } - - // Cache velocities to improve movement on breakage. - if (m_broke == false) - { - m_velocity = m_body1->GetLinearVelocity(); - m_angularVelocity = m_body1->GetAngularVelocity(); - } - - Test::Step(settings); - } - - static Test* Create() - { - return new Breakable; - } - - b2Body* m_body1; - b2Vec2 m_velocity; - float32 m_angularVelocity; - b2PolygonShape m_shape1; - b2PolygonShape m_shape2; - b2Fixture* m_piece1; - b2Fixture* m_piece2; - - bool m_broke; - bool m_break; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Bridge.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Bridge.h deleted file mode 100644 index 25492ce4cb..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Bridge.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BRIDGE_H -#define BRIDGE_H - -class Bridge : public Test -{ -public: - - enum - { - e_count = 30 - }; - - Bridge() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - fd.friction = 0.2f; - - b2RevoluteJointDef jd; - - b2Body* prevBody = ground; - for (int32 i = 0; i < e_count; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-14.5f + 1.0f * i, 5.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - b2Vec2 anchor(-15.0f + 1.0f * i, 5.0f); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - - if (i == (e_count >> 1)) - { - m_middle = body; - } - prevBody = body; - } - - b2Vec2 anchor(-15.0f + 1.0f * e_count, 5.0f); - jd.Initialize(prevBody, ground, anchor); - m_world->CreateJoint(&jd); - } - - for (int32 i = 0; i < 2; ++i) - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.5f, 0.0f); - vertices[1].Set(0.5f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - - b2PolygonShape shape; - shape.Set(vertices, 3); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-8.0f + 8.0f * i, 12.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - } - - for (int32 i = 0; i < 3; ++i) - { - b2CircleShape shape; - shape.m_radius = 0.5f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-6.0f + 6.0f * i, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - } - } - - static Test* Create() - { - return new Bridge; - } - - b2Body* m_middle; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/BulletTest.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/BulletTest.h deleted file mode 100644 index 6f246090c8..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/BulletTest.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BULLET_TEST_H -#define BULLET_TEST_H - -class BulletTest : public Test -{ -public: - - BulletTest() - { - { - b2BodyDef bd; - bd.position.Set(0.0f, 0.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2EdgeShape edge; - - edge.Set(b2Vec2(-10.0f, 0.0f), b2Vec2(10.0f, 0.0f)); - body->CreateFixture(&edge, 0.0f); - - b2PolygonShape shape; - shape.SetAsBox(0.2f, 1.0f, b2Vec2(0.5f, 1.0f), 0.0f); - body->CreateFixture(&shape, 0.0f); - } - - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 4.0f); - - b2PolygonShape box; - box.SetAsBox(2.0f, 0.1f); - - m_body = m_world->CreateBody(&bd); - m_body->CreateFixture(&box, 1.0f); - - box.SetAsBox(0.25f, 0.25f); - - //m_x = RandomFloat(-1.0f, 1.0f); - m_x = 0.20352793f; - bd.position.Set(m_x, 10.0f); - bd.bullet = true; - - m_bullet = m_world->CreateBody(&bd); - m_bullet->CreateFixture(&box, 100.0f); - - m_bullet->SetLinearVelocity(b2Vec2(0.0f, -50.0f)); - } - } - - void Launch() - { - m_body->SetTransform(b2Vec2(0.0f, 4.0f), 0.0f); - m_body->SetLinearVelocity(b2Vec2_zero); - m_body->SetAngularVelocity(0.0f); - - m_x = RandomFloat(-1.0f, 1.0f); - m_bullet->SetTransform(b2Vec2(m_x, 10.0f), 0.0f); - m_bullet->SetLinearVelocity(b2Vec2(0.0f, -50.0f)); - m_bullet->SetAngularVelocity(0.0f); - - extern int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters; - extern int32 b2_toiCalls, b2_toiIters, b2_toiMaxIters; - extern int32 b2_toiRootIters, b2_toiMaxRootIters; - - b2_gjkCalls = 0; - b2_gjkIters = 0; - b2_gjkMaxIters = 0; - - b2_toiCalls = 0; - b2_toiIters = 0; - b2_toiMaxIters = 0; - b2_toiRootIters = 0; - b2_toiMaxRootIters = 0; - } - - void Step(Settings* settings) - { - Test::Step(settings); - - extern int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters; - extern int32 b2_toiCalls, b2_toiIters; - extern int32 b2_toiRootIters, b2_toiMaxRootIters; - - if (b2_gjkCalls > 0) - { - m_debugDraw.DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d", - b2_gjkCalls, b2_gjkIters / float32(b2_gjkCalls), b2_gjkMaxIters); - m_textLine += DRAW_STRING_NEW_LINE; - } - - if (b2_toiCalls > 0) - { - m_debugDraw.DrawString(5, m_textLine, "toi calls = %d, ave toi iters = %3.1f, max toi iters = %d", - b2_toiCalls, b2_toiIters / float32(b2_toiCalls), b2_toiMaxRootIters); - m_textLine += DRAW_STRING_NEW_LINE; - - m_debugDraw.DrawString(5, m_textLine, "ave toi root iters = %3.1f, max toi root iters = %d", - b2_toiRootIters / float32(b2_toiCalls), b2_toiMaxRootIters); - m_textLine += DRAW_STRING_NEW_LINE; - } - - if (m_stepCount % 60 == 0) - { - Launch(); - } - } - - static Test* Create() - { - return new BulletTest; - } - - b2Body* m_body; - b2Body* m_bullet; - float32 m_x; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Cantilever.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Cantilever.h deleted file mode 100644 index 5a0767984b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Cantilever.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CANTILEVER_H -#define CANTILEVER_H - -// It is difficult to make a cantilever made of links completely rigid with weld joints. -// You will have to use a high number of iterations to make them stiff. -// So why not go ahead and use soft weld joints? They behave like a revolute -// joint with a rotational spring. -class Cantilever : public Test -{ -public: - - enum - { - e_count = 8 - }; - - Cantilever() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - - b2WeldJointDef jd; - - b2Body* prevBody = ground; - for (int32 i = 0; i < e_count; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-14.5f + 1.0f * i, 5.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - b2Vec2 anchor(-15.0f + 1.0f * i, 5.0f); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - - prevBody = body; - } - } - - { - b2PolygonShape shape; - shape.SetAsBox(1.0f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - - b2WeldJointDef jd; - jd.frequencyHz = 5.0f; - jd.dampingRatio = 0.7f; - - b2Body* prevBody = ground; - for (int32 i = 0; i < 3; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-14.0f + 2.0f * i, 15.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - b2Vec2 anchor(-15.0f + 2.0f * i, 15.0f); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - - prevBody = body; - } - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - - b2WeldJointDef jd; - - b2Body* prevBody = ground; - for (int32 i = 0; i < e_count; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-4.5f + 1.0f * i, 5.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - if (i > 0) - { - b2Vec2 anchor(-5.0f + 1.0f * i, 5.0f); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - } - - prevBody = body; - } - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - - b2WeldJointDef jd; - jd.frequencyHz = 8.0f; - jd.dampingRatio = 0.7f; - - b2Body* prevBody = ground; - for (int32 i = 0; i < e_count; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(5.5f + 1.0f * i, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - if (i > 0) - { - b2Vec2 anchor(5.0f + 1.0f * i, 10.0f); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - } - - prevBody = body; - } - } - - for (int32 i = 0; i < 2; ++i) - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.5f, 0.0f); - vertices[1].Set(0.5f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - - b2PolygonShape shape; - shape.Set(vertices, 3); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-8.0f + 8.0f * i, 12.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - } - - for (int32 i = 0; i < 2; ++i) - { - b2CircleShape shape; - shape.m_radius = 0.5f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-6.0f + 6.0f * i, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - } - } - - static Test* Create() - { - return new Cantilever; - } - - b2Body* m_middle; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Car.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Car.h deleted file mode 100644 index f4d038232f..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Car.h +++ /dev/null @@ -1,286 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CAR_H -#define CAR_H - -// This is a fun demo that shows off the wheel joint -class Car : public Test -{ -public: - Car() - { - m_hz = 4.0f; - m_zeta = 0.7f; - m_speed = 50.0f; - - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 0.0f; - fd.friction = 0.6f; - - shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); - ground->CreateFixture(&fd); - - float32 hs[10] = {0.25f, 1.0f, 4.0f, 0.0f, 0.0f, -1.0f, -2.0f, -2.0f, -1.25f, 0.0f}; - - float32 x = 20.0f, y1 = 0.0f, dx = 5.0f; - - for (int32 i = 0; i < 10; ++i) - { - float32 y2 = hs[i]; - shape.Set(b2Vec2(x, y1), b2Vec2(x + dx, y2)); - ground->CreateFixture(&fd); - y1 = y2; - x += dx; - } - - for (int32 i = 0; i < 10; ++i) - { - float32 y2 = hs[i]; - shape.Set(b2Vec2(x, y1), b2Vec2(x + dx, y2)); - ground->CreateFixture(&fd); - y1 = y2; - x += dx; - } - - shape.Set(b2Vec2(x, 0.0f), b2Vec2(x + 40.0f, 0.0f)); - ground->CreateFixture(&fd); - - x += 80.0f; - shape.Set(b2Vec2(x, 0.0f), b2Vec2(x + 40.0f, 0.0f)); - ground->CreateFixture(&fd); - - x += 40.0f; - shape.Set(b2Vec2(x, 0.0f), b2Vec2(x + 10.0f, 5.0f)); - ground->CreateFixture(&fd); - - x += 20.0f; - shape.Set(b2Vec2(x, 0.0f), b2Vec2(x + 40.0f, 0.0f)); - ground->CreateFixture(&fd); - - x += 40.0f; - shape.Set(b2Vec2(x, 0.0f), b2Vec2(x, 20.0f)); - ground->CreateFixture(&fd); - } - - // Teeter - { - b2BodyDef bd; - bd.position.Set(140.0f, 1.0f); - bd.type = b2_dynamicBody; - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape box; - box.SetAsBox(10.0f, 0.25f); - body->CreateFixture(&box, 1.0f); - - b2RevoluteJointDef jd; - jd.Initialize(ground, body, body->GetPosition()); - jd.lowerAngle = -8.0f * b2_pi / 180.0f; - jd.upperAngle = 8.0f * b2_pi / 180.0f; - jd.enableLimit = true; - m_world->CreateJoint(&jd); - - body->ApplyAngularImpulse(100.0f, true); - } - - // Bridge - { - int32 N = 20; - b2PolygonShape shape; - shape.SetAsBox(1.0f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - fd.friction = 0.6f; - - b2RevoluteJointDef jd; - - b2Body* prevBody = ground; - for (int32 i = 0; i < N; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(161.0f + 2.0f * i, -0.125f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - b2Vec2 anchor(160.0f + 2.0f * i, -0.125f); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - - prevBody = body; - } - - b2Vec2 anchor(160.0f + 2.0f * N, -0.125f); - jd.Initialize(prevBody, ground, anchor); - m_world->CreateJoint(&jd); - } - - // Boxes - { - b2PolygonShape box; - box.SetAsBox(0.5f, 0.5f); - - b2Body* body = NULL; - b2BodyDef bd; - bd.type = b2_dynamicBody; - - bd.position.Set(230.0f, 0.5f); - body = m_world->CreateBody(&bd); - body->CreateFixture(&box, 0.5f); - - bd.position.Set(230.0f, 1.5f); - body = m_world->CreateBody(&bd); - body->CreateFixture(&box, 0.5f); - - bd.position.Set(230.0f, 2.5f); - body = m_world->CreateBody(&bd); - body->CreateFixture(&box, 0.5f); - - bd.position.Set(230.0f, 3.5f); - body = m_world->CreateBody(&bd); - body->CreateFixture(&box, 0.5f); - - bd.position.Set(230.0f, 4.5f); - body = m_world->CreateBody(&bd); - body->CreateFixture(&box, 0.5f); - } - - // Car - { - b2PolygonShape chassis; - b2Vec2 vertices[8]; - vertices[0].Set(-1.5f, -0.5f); - vertices[1].Set(1.5f, -0.5f); - vertices[2].Set(1.5f, 0.0f); - vertices[3].Set(0.0f, 0.9f); - vertices[4].Set(-1.15f, 0.9f); - vertices[5].Set(-1.5f, 0.2f); - chassis.Set(vertices, 6); - - b2CircleShape circle; - circle.m_radius = 0.4f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 1.0f); - m_car = m_world->CreateBody(&bd); - m_car->CreateFixture(&chassis, 1.0f); - - b2FixtureDef fd; - fd.shape = &circle; - fd.density = 1.0f; - fd.friction = 0.9f; - - bd.position.Set(-1.0f, 0.35f); - m_wheel1 = m_world->CreateBody(&bd); - m_wheel1->CreateFixture(&fd); - - bd.position.Set(1.0f, 0.4f); - m_wheel2 = m_world->CreateBody(&bd); - m_wheel2->CreateFixture(&fd); - - b2WheelJointDef jd; - b2Vec2 axis(0.0f, 1.0f); - - jd.Initialize(m_car, m_wheel1, m_wheel1->GetPosition(), axis); - jd.motorSpeed = 0.0f; - jd.maxMotorTorque = 20.0f; - jd.enableMotor = true; - jd.frequencyHz = m_hz; - jd.dampingRatio = m_zeta; - m_spring1 = (b2WheelJoint*)m_world->CreateJoint(&jd); - - jd.Initialize(m_car, m_wheel2, m_wheel2->GetPosition(), axis); - jd.motorSpeed = 0.0f; - jd.maxMotorTorque = 10.0f; - jd.enableMotor = false; - jd.frequencyHz = m_hz; - jd.dampingRatio = m_zeta; - m_spring2 = (b2WheelJoint*)m_world->CreateJoint(&jd); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - m_spring1->SetMotorSpeed(m_speed); - break; - - case 's': - m_spring1->SetMotorSpeed(0.0f); - break; - - case 'd': - m_spring1->SetMotorSpeed(-m_speed); - break; - - case 'q': - m_hz = b2Max(0.0f, m_hz - 1.0f); - m_spring1->SetSpringFrequencyHz(m_hz); - m_spring2->SetSpringFrequencyHz(m_hz); - break; - - case 'e': - m_hz += 1.0f; - m_spring1->SetSpringFrequencyHz(m_hz); - m_spring2->SetSpringFrequencyHz(m_hz); - break; - } - } - - void Step(Settings* settings) - { - m_debugDraw.DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, hz down = q, hz up = e"); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "frequency = %g hz, damping ratio = %g", m_hz, m_zeta); - m_textLine += DRAW_STRING_NEW_LINE; - - settings->viewCenter.x = m_car->GetPosition().x; - Test::Step(settings); - } - - static Test* Create() - { - return new Car; - } - - b2Body* m_car; - b2Body* m_wheel1; - b2Body* m_wheel2; - - float32 m_hz; - float32 m_zeta; - float32 m_speed; - b2WheelJoint* m_spring1; - b2WheelJoint* m_spring2; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Chain.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Chain.h deleted file mode 100644 index de4414f849..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Chain.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CHAIN_H -#define CHAIN_H - -class Chain : public Test -{ -public: - Chain() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.6f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - fd.friction = 0.2f; - - b2RevoluteJointDef jd; - jd.collideConnected = false; - - const float32 y = 25.0f; - b2Body* prevBody = ground; - for (int32 i = 0; i < 30; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.5f + i, y); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - - b2Vec2 anchor(float32(i), y); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - - prevBody = body; - } - } - } - - static Test* Create() - { - return new Chain; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CharacterCollision.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/CharacterCollision.h deleted file mode 100644 index 541c84f516..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CharacterCollision.h +++ /dev/null @@ -1,253 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CHARACTER_COLLISION_H -#define CHARACTER_COLLISION_H - -/// This is a test of typical character collision scenarios. This does not -/// show how you should implement a character in your application. -/// Instead this is used to test smooth collision on edge chains. -class CharacterCollision : public Test -{ -public: - CharacterCollision() - { - // Ground body - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - // Collinear edges with no adjacency information. - // This shows the problematic case where a box shape can hit - // an internal vertex. - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-8.0f, 1.0f), b2Vec2(-6.0f, 1.0f)); - ground->CreateFixture(&shape, 0.0f); - shape.Set(b2Vec2(-6.0f, 1.0f), b2Vec2(-4.0f, 1.0f)); - ground->CreateFixture(&shape, 0.0f); - shape.Set(b2Vec2(-4.0f, 1.0f), b2Vec2(-2.0f, 1.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - // Chain shape - { - b2BodyDef bd; - bd.angle = 0.25f * b2_pi; - b2Body* ground = m_world->CreateBody(&bd); - - b2Vec2 vs[4]; - vs[0].Set(5.0f, 7.0f); - vs[1].Set(6.0f, 8.0f); - vs[2].Set(7.0f, 8.0f); - vs[3].Set(8.0f, 7.0f); - b2ChainShape shape; - shape.CreateChain(vs, 4); - ground->CreateFixture(&shape, 0.0f); - } - - // Square tiles. This shows that adjacency shapes may - // have non-smooth collision. There is no solution - // to this problem. - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(1.0f, 1.0f, b2Vec2(4.0f, 3.0f), 0.0f); - ground->CreateFixture(&shape, 0.0f); - shape.SetAsBox(1.0f, 1.0f, b2Vec2(6.0f, 3.0f), 0.0f); - ground->CreateFixture(&shape, 0.0f); - shape.SetAsBox(1.0f, 1.0f, b2Vec2(8.0f, 3.0f), 0.0f); - ground->CreateFixture(&shape, 0.0f); - } - - // Square made from an edge loop. Collision should be smooth. - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2Vec2 vs[4]; - vs[0].Set(-1.0f, 3.0f); - vs[1].Set(1.0f, 3.0f); - vs[2].Set(1.0f, 5.0f); - vs[3].Set(-1.0f, 5.0f); - b2ChainShape shape; - shape.CreateLoop(vs, 4); - ground->CreateFixture(&shape, 0.0f); - } - - // Edge loop. Collision should be smooth. - { - b2BodyDef bd; - bd.position.Set(-10.0f, 4.0f); - b2Body* ground = m_world->CreateBody(&bd); - - b2Vec2 vs[10]; - vs[0].Set(0.0f, 0.0f); - vs[1].Set(6.0f, 0.0f); - vs[2].Set(6.0f, 2.0f); - vs[3].Set(4.0f, 1.0f); - vs[4].Set(2.0f, 2.0f); - vs[5].Set(0.0f, 2.0f); - vs[6].Set(-2.0f, 2.0f); - vs[7].Set(-4.0f, 3.0f); - vs[8].Set(-6.0f, 2.0f); - vs[9].Set(-6.0f, 0.0f); - b2ChainShape shape; - shape.CreateLoop(vs, 10); - ground->CreateFixture(&shape, 0.0f); - } - - // Square character 1 - { - b2BodyDef bd; - bd.position.Set(-3.0f, 8.0f); - bd.type = b2_dynamicBody; - bd.fixedRotation = true; - bd.allowSleep = false; - - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - body->CreateFixture(&fd); - } - - // Square character 2 - { - b2BodyDef bd; - bd.position.Set(-5.0f, 5.0f); - bd.type = b2_dynamicBody; - bd.fixedRotation = true; - bd.allowSleep = false; - - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.25f, 0.25f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - body->CreateFixture(&fd); - } - - // Hexagon character - { - b2BodyDef bd; - bd.position.Set(-5.0f, 8.0f); - bd.type = b2_dynamicBody; - bd.fixedRotation = true; - bd.allowSleep = false; - - b2Body* body = m_world->CreateBody(&bd); - - float32 angle = 0.0f; - float32 delta = b2_pi / 3.0f; - b2Vec2 vertices[6]; - for (int32 i = 0; i < 6; ++i) - { - vertices[i].Set(0.5f * cosf(angle), 0.5f * sinf(angle)); - angle += delta; - } - - b2PolygonShape shape; - shape.Set(vertices, 6); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - body->CreateFixture(&fd); - } - - // Circle character - { - b2BodyDef bd; - bd.position.Set(3.0f, 5.0f); - bd.type = b2_dynamicBody; - bd.fixedRotation = true; - bd.allowSleep = false; - - b2Body* body = m_world->CreateBody(&bd); - - b2CircleShape shape; - shape.m_radius = 0.5f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - body->CreateFixture(&fd); - } - - // Circle character - { - b2BodyDef bd; - bd.position.Set(-7.0f, 6.0f); - bd.type = b2_dynamicBody; - bd.allowSleep = false; - - m_character = m_world->CreateBody(&bd); - - b2CircleShape shape; - shape.m_radius = 0.25f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - fd.friction = 1.0f; - m_character->CreateFixture(&fd); - } - } - - void Step(Settings* settings) - { - b2Vec2 v = m_character->GetLinearVelocity(); - v.x = -5.0f; - m_character->SetLinearVelocity(v); - - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "This tests various character collision shapes."); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "Limitation: square and hexagon can snag on aligned boxes."); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "Feature: edge chains have smooth collision inside and out."); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new CharacterCollision; - } - - b2Body* m_character; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CollisionFiltering.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/CollisionFiltering.h deleted file mode 100644 index 8a11dc195f..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CollisionFiltering.h +++ /dev/null @@ -1,177 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_FILTERING_H -#define COLLISION_FILTERING_H - -// This is a test of collision filtering. -// There is a triangle, a box, and a circle. -// There are 6 shapes. 3 large and 3 small. -// The 3 small ones always collide. -// The 3 large ones never collide. -// The boxes don't collide with triangles (except if both are small). -const int16 k_smallGroup = 1; -const int16 k_largeGroup = -1; - -const uint16 k_defaultCategory = 0x0001; -const uint16 k_triangleCategory = 0x0002; -const uint16 k_boxCategory = 0x0004; -const uint16 k_circleCategory = 0x0008; - -const uint16 k_triangleMask = 0xFFFF; -const uint16 k_boxMask = 0xFFFF ^ k_triangleCategory; -const uint16 k_circleMask = 0xFFFF; - -class CollisionFiltering : public Test -{ -public: - CollisionFiltering() - { - // Ground body - { - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - - b2FixtureDef sd; - sd.shape = &shape; - sd.friction = 0.3f; - - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&sd); - } - - // Small triangle - b2Vec2 vertices[3]; - vertices[0].Set(-1.0f, 0.0f); - vertices[1].Set(1.0f, 0.0f); - vertices[2].Set(0.0f, 2.0f); - b2PolygonShape polygon; - polygon.Set(vertices, 3); - - b2FixtureDef triangleShapeDef; - triangleShapeDef.shape = &polygon; - triangleShapeDef.density = 1.0f; - - triangleShapeDef.filter.groupIndex = k_smallGroup; - triangleShapeDef.filter.categoryBits = k_triangleCategory; - triangleShapeDef.filter.maskBits = k_triangleMask; - - b2BodyDef triangleBodyDef; - triangleBodyDef.type = b2_dynamicBody; - triangleBodyDef.position.Set(-5.0f, 2.0f); - - b2Body* body1 = m_world->CreateBody(&triangleBodyDef); - body1->CreateFixture(&triangleShapeDef); - - // Large triangle (recycle definitions) - vertices[0] *= 2.0f; - vertices[1] *= 2.0f; - vertices[2] *= 2.0f; - polygon.Set(vertices, 3); - triangleShapeDef.filter.groupIndex = k_largeGroup; - triangleBodyDef.position.Set(-5.0f, 6.0f); - triangleBodyDef.fixedRotation = true; // look at me! - - b2Body* body2 = m_world->CreateBody(&triangleBodyDef); - body2->CreateFixture(&triangleShapeDef); - - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-5.0f, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape p; - p.SetAsBox(0.5f, 1.0f); - body->CreateFixture(&p, 1.0f); - - b2PrismaticJointDef jd; - jd.bodyA = body2; - jd.bodyB = body; - jd.enableLimit = true; - jd.localAnchorA.Set(0.0f, 4.0f); - jd.localAnchorB.SetZero(); - jd.localAxisA.Set(0.0f, 1.0f); - jd.lowerTranslation = -1.0f; - jd.upperTranslation = 1.0f; - - m_world->CreateJoint(&jd); - } - - // Small box - polygon.SetAsBox(1.0f, 0.5f); - b2FixtureDef boxShapeDef; - boxShapeDef.shape = &polygon; - boxShapeDef.density = 1.0f; - boxShapeDef.restitution = 0.1f; - - boxShapeDef.filter.groupIndex = k_smallGroup; - boxShapeDef.filter.categoryBits = k_boxCategory; - boxShapeDef.filter.maskBits = k_boxMask; - - b2BodyDef boxBodyDef; - boxBodyDef.type = b2_dynamicBody; - boxBodyDef.position.Set(0.0f, 2.0f); - - b2Body* body3 = m_world->CreateBody(&boxBodyDef); - body3->CreateFixture(&boxShapeDef); - - // Large box (recycle definitions) - polygon.SetAsBox(2.0f, 1.0f); - boxShapeDef.filter.groupIndex = k_largeGroup; - boxBodyDef.position.Set(0.0f, 6.0f); - - b2Body* body4 = m_world->CreateBody(&boxBodyDef); - body4->CreateFixture(&boxShapeDef); - - // Small circle - b2CircleShape circle; - circle.m_radius = 1.0f; - - b2FixtureDef circleShapeDef; - circleShapeDef.shape = &circle; - circleShapeDef.density = 1.0f; - - circleShapeDef.filter.groupIndex = k_smallGroup; - circleShapeDef.filter.categoryBits = k_circleCategory; - circleShapeDef.filter.maskBits = k_circleMask; - - b2BodyDef circleBodyDef; - circleBodyDef.type = b2_dynamicBody; - circleBodyDef.position.Set(5.0f, 2.0f); - - b2Body* body5 = m_world->CreateBody(&circleBodyDef); - body5->CreateFixture(&circleShapeDef); - - // Large circle - circle.m_radius *= 2.0f; - circleShapeDef.filter.groupIndex = k_largeGroup; - circleBodyDef.position.Set(5.0f, 6.0f); - - b2Body* body6 = m_world->CreateBody(&circleBodyDef); - body6->CreateFixture(&circleShapeDef); - } - - static Test* Create() - { - return new CollisionFiltering; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CollisionProcessing.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/CollisionProcessing.h deleted file mode 100644 index 96d4b2bdf2..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CollisionProcessing.h +++ /dev/null @@ -1,188 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_PROCESSING_H -#define COLLISION_PROCESSING_H - -#include - -// This test shows collision processing and tests -// deferred body destruction. -class CollisionProcessing : public Test -{ -public: - CollisionProcessing() - { - // Ground body - { - b2EdgeShape shape; - shape.Set(b2Vec2(-50.0f, 0.0f), b2Vec2(50.0f, 0.0f)); - - b2FixtureDef sd; - sd.shape = &shape; - - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&sd); - } - - float32 xLo = -5.0f, xHi = 5.0f; - float32 yLo = 2.0f, yHi = 35.0f; - - // Small triangle - b2Vec2 vertices[3]; - vertices[0].Set(-1.0f, 0.0f); - vertices[1].Set(1.0f, 0.0f); - vertices[2].Set(0.0f, 2.0f); - - b2PolygonShape polygon; - polygon.Set(vertices, 3); - - b2FixtureDef triangleShapeDef; - triangleShapeDef.shape = &polygon; - triangleShapeDef.density = 1.0f; - - b2BodyDef triangleBodyDef; - triangleBodyDef.type = b2_dynamicBody; - triangleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi)); - - b2Body* body1 = m_world->CreateBody(&triangleBodyDef); - body1->CreateFixture(&triangleShapeDef); - - // Large triangle (recycle definitions) - vertices[0] *= 2.0f; - vertices[1] *= 2.0f; - vertices[2] *= 2.0f; - polygon.Set(vertices, 3); - - triangleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi)); - - b2Body* body2 = m_world->CreateBody(&triangleBodyDef); - body2->CreateFixture(&triangleShapeDef); - - // Small box - polygon.SetAsBox(1.0f, 0.5f); - - b2FixtureDef boxShapeDef; - boxShapeDef.shape = &polygon; - boxShapeDef.density = 1.0f; - - b2BodyDef boxBodyDef; - boxBodyDef.type = b2_dynamicBody; - boxBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi)); - - b2Body* body3 = m_world->CreateBody(&boxBodyDef); - body3->CreateFixture(&boxShapeDef); - - // Large box (recycle definitions) - polygon.SetAsBox(2.0f, 1.0f); - boxBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi)); - - b2Body* body4 = m_world->CreateBody(&boxBodyDef); - body4->CreateFixture(&boxShapeDef); - - // Small circle - b2CircleShape circle; - circle.m_radius = 1.0f; - - b2FixtureDef circleShapeDef; - circleShapeDef.shape = &circle; - circleShapeDef.density = 1.0f; - - b2BodyDef circleBodyDef; - circleBodyDef.type = b2_dynamicBody; - circleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi)); - - b2Body* body5 = m_world->CreateBody(&circleBodyDef); - body5->CreateFixture(&circleShapeDef); - - // Large circle - circle.m_radius *= 2.0f; - circleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi)); - - b2Body* body6 = m_world->CreateBody(&circleBodyDef); - body6->CreateFixture(&circleShapeDef); - } - - void Step(Settings* settings) - { - Test::Step(settings); - - // We are going to destroy some bodies according to contact - // points. We must buffer the bodies that should be destroyed - // because they may belong to multiple contact points. - const int32 k_maxNuke = 6; - b2Body* nuke[k_maxNuke]; - int32 nukeCount = 0; - - // Traverse the contact results. Destroy bodies that - // are touching heavier bodies. - for (int32 i = 0; i < m_pointCount; ++i) - { - ContactPoint* point = m_points + i; - - b2Body* body1 = point->fixtureA->GetBody(); - b2Body* body2 = point->fixtureB->GetBody(); - float32 mass1 = body1->GetMass(); - float32 mass2 = body2->GetMass(); - - if (mass1 > 0.0f && mass2 > 0.0f) - { - if (mass2 > mass1) - { - nuke[nukeCount++] = body1; - } - else - { - nuke[nukeCount++] = body2; - } - - if (nukeCount == k_maxNuke) - { - break; - } - } - } - - // Sort the nuke array to group duplicates. - std::sort(nuke, nuke + nukeCount); - - // Destroy the bodies, skipping duplicates. - int32 i = 0; - while (i < nukeCount) - { - b2Body* b = nuke[i++]; - while (i < nukeCount && nuke[i] == b) - { - ++i; - } - - if (b != m_bomb) - { - m_world->DestroyBody(b); - } - } - } - - static Test* Create() - { - return new CollisionProcessing; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CompoundShapes.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/CompoundShapes.h deleted file mode 100644 index bdba8a60d5..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/CompoundShapes.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COMPOUND_SHAPES_H -#define COMPOUND_SHAPES_H - -// TODO_ERIN test joints on compounds. -class CompoundShapes : public Test -{ -public: - CompoundShapes() - { - { - b2BodyDef bd; - bd.position.Set(0.0f, 0.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(50.0f, 0.0f), b2Vec2(-50.0f, 0.0f)); - - body->CreateFixture(&shape, 0.0f); - } - - { - b2CircleShape circle1; - circle1.m_radius = 0.5f; - circle1.m_p.Set(-0.5f, 0.5f); - - b2CircleShape circle2; - circle2.m_radius = 0.5f; - circle2.m_p.Set(0.5f, 0.5f); - - for (int i = 0; i < 10; ++i) - { - float32 x = RandomFloat(-0.1f, 0.1f); - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(x + 5.0f, 1.05f + 2.5f * i); - bd.angle = RandomFloat(-b2_pi, b2_pi); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&circle1, 2.0f); - body->CreateFixture(&circle2, 0.0f); - } - } - - { - b2PolygonShape polygon1; - polygon1.SetAsBox(0.25f, 0.5f); - - b2PolygonShape polygon2; - polygon2.SetAsBox(0.25f, 0.5f, b2Vec2(0.0f, -0.5f), 0.5f * b2_pi); - - for (int i = 0; i < 10; ++i) - { - float32 x = RandomFloat(-0.1f, 0.1f); - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(x - 5.0f, 1.05f + 2.5f * i); - bd.angle = RandomFloat(-b2_pi, b2_pi); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&polygon1, 2.0f); - body->CreateFixture(&polygon2, 2.0f); - } - } - - { - b2Transform xf1; - xf1.q.Set(0.3524f * b2_pi); - xf1.p = xf1.q.GetXAxis(); - - b2Vec2 vertices[3]; - - b2PolygonShape triangle1; - vertices[0] = b2Mul(xf1, b2Vec2(-1.0f, 0.0f)); - vertices[1] = b2Mul(xf1, b2Vec2(1.0f, 0.0f)); - vertices[2] = b2Mul(xf1, b2Vec2(0.0f, 0.5f)); - triangle1.Set(vertices, 3); - - b2Transform xf2; - xf2.q.Set(-0.3524f * b2_pi); - xf2.p = -xf2.q.GetXAxis(); - - b2PolygonShape triangle2; - vertices[0] = b2Mul(xf2, b2Vec2(-1.0f, 0.0f)); - vertices[1] = b2Mul(xf2, b2Vec2(1.0f, 0.0f)); - vertices[2] = b2Mul(xf2, b2Vec2(0.0f, 0.5f)); - triangle2.Set(vertices, 3); - - for (int32 i = 0; i < 10; ++i) - { - float32 x = RandomFloat(-0.1f, 0.1f); - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(x, 2.05f + 2.5f * i); - bd.angle = 0.0f; - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&triangle1, 2.0f); - body->CreateFixture(&triangle2, 2.0f); - } - } - - { - b2PolygonShape bottom; - bottom.SetAsBox( 1.5f, 0.15f ); - - b2PolygonShape left; - left.SetAsBox(0.15f, 2.7f, b2Vec2(-1.45f, 2.35f), 0.2f); - - b2PolygonShape right; - right.SetAsBox(0.15f, 2.7f, b2Vec2(1.45f, 2.35f), -0.2f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set( 0.0f, 2.0f ); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&bottom, 4.0f); - body->CreateFixture(&left, 4.0f); - body->CreateFixture(&right, 4.0f); - } - } - - static Test* Create() - { - return new CompoundShapes; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Confined.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Confined.h deleted file mode 100644 index 6f7aefaec2..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Confined.h +++ /dev/null @@ -1,167 +0,0 @@ -/* -* Copyright (c) 2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONFINED_H -#define CONFINED_H - -class Confined : public Test -{ -public: - - enum - { - e_columnCount = 20, - e_rowCount = 10 - }; - - Confined() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - - // Floor - shape.Set(b2Vec2(-10.0f, 0.0f), b2Vec2(10.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - - // Left wall - shape.Set(b2Vec2(-10.0f, 0.0f), b2Vec2(-10.0f, 20.0f)); - ground->CreateFixture(&shape, 0.0f); - - // Right wall - shape.Set(b2Vec2(10.0f, 0.0f), b2Vec2(10.0f, 20.0f)); - ground->CreateFixture(&shape, 0.0f); - - // Roof - shape.Set(b2Vec2(-10.0f, 20.0f), b2Vec2(10.0f, 20.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - float32 radius = 0.5f; - b2CircleShape shape; - shape.m_p.SetZero(); - shape.m_radius = radius; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - fd.friction = 0.1f; - - for (int32 j = 0; j < e_columnCount; ++j) - { - for (int i = 0; i < e_rowCount; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-10.0f + (2.1f * j + 1.0f + 0.01f * i) * radius, (2.0f * i + 1.0f) * radius); - b2Body* body = m_world->CreateBody(&bd); - - body->CreateFixture(&fd); - } - } - - m_world->SetGravity(b2Vec2(0.0f, 0.0f)); - } - - void CreateCircle() - { - float32 radius = 2.0f; - b2CircleShape shape; - shape.m_p.SetZero(); - shape.m_radius = radius; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - fd.friction = 0.0f; - - b2Vec2 p(RandomFloat(), 3.0f + RandomFloat()); - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = p; - //bd.allowSleep = false; - b2Body* body = m_world->CreateBody(&bd); - - body->CreateFixture(&fd); - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'c': - CreateCircle(); - break; - } - } - - void Step(Settings* settings) - { - bool sleeping = true; - for (b2Body* b = m_world->GetBodyList(); b; b = b->GetNext()) - { - if (b->GetType() != b2_dynamicBody) - { - continue; - } - - if (b->IsAwake()) - { - sleeping = false; - } - } - - if (m_stepCount == 180) - { - m_stepCount += 0; - } - - //if (sleeping) - //{ - // CreateCircle(); - //} - - Test::Step(settings); - - for (b2Body* b = m_world->GetBodyList(); b; b = b->GetNext()) - { - if (b->GetType() != b2_dynamicBody) - { - continue; - } - - b2Vec2 p = b->GetPosition(); - if (p.x <= -10.0f || 10.0f <= p.x || p.y <= 0.0f || 20.0f <= p.y) - { - p.x += 0.0f; - } - } - - m_debugDraw.DrawString(5, m_textLine, "Press 'c' to create a circle."); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new Confined; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ContinuousTest.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/ContinuousTest.h deleted file mode 100644 index 7165aac374..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ContinuousTest.h +++ /dev/null @@ -1,157 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONTINUOUS_TEST_H -#define CONTINUOUS_TEST_H - -class ContinuousTest : public Test -{ -public: - - ContinuousTest() - { - { - b2BodyDef bd; - bd.position.Set(0.0f, 0.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2EdgeShape edge; - - edge.Set(b2Vec2(-10.0f, 0.0f), b2Vec2(10.0f, 0.0f)); - body->CreateFixture(&edge, 0.0f); - - b2PolygonShape shape; - shape.SetAsBox(0.2f, 1.0f, b2Vec2(0.5f, 1.0f), 0.0f); - body->CreateFixture(&shape, 0.0f); - } - -#if 1 - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 20.0f); - //bd.angle = 0.1f; - - b2PolygonShape shape; - shape.SetAsBox(2.0f, 0.1f); - - m_body = m_world->CreateBody(&bd); - m_body->CreateFixture(&shape, 1.0f); - - m_angularVelocity = RandomFloat(-50.0f, 50.0f); - //m_angularVelocity = 46.661274f; - m_body->SetLinearVelocity(b2Vec2(0.0f, -100.0f)); - m_body->SetAngularVelocity(m_angularVelocity); - } -#else - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 2.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2CircleShape shape; - shape.m_p.SetZero(); - shape.m_radius = 0.5f; - body->CreateFixture(&shape, 1.0f); - - bd.bullet = true; - bd.position.Set(0.0f, 10.0f); - body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 1.0f); - body->SetLinearVelocity(b2Vec2(0.0f, -100.0f)); - } -#endif - - extern int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters; - extern int32 b2_toiCalls, b2_toiIters; - extern int32 b2_toiRootIters, b2_toiMaxRootIters; - extern float32 b2_toiTime, b2_toiMaxTime; - - b2_gjkCalls = 0; b2_gjkIters = 0; b2_gjkMaxIters = 0; - b2_toiCalls = 0; b2_toiIters = 0; - b2_toiRootIters = 0; b2_toiMaxRootIters = 0; - b2_toiTime = 0.0f; b2_toiMaxTime = 0.0f; - } - - void Launch() - { - extern int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters; - extern int32 b2_toiCalls, b2_toiIters; - extern int32 b2_toiRootIters, b2_toiMaxRootIters; - extern float32 b2_toiTime, b2_toiMaxTime; - - b2_gjkCalls = 0; b2_gjkIters = 0; b2_gjkMaxIters = 0; - b2_toiCalls = 0; b2_toiIters = 0; - b2_toiRootIters = 0; b2_toiMaxRootIters = 0; - b2_toiTime = 0.0f; b2_toiMaxTime = 0.0f; - - m_body->SetTransform(b2Vec2(0.0f, 20.0f), 0.0f); - m_angularVelocity = RandomFloat(-50.0f, 50.0f); - m_body->SetLinearVelocity(b2Vec2(0.0f, -100.0f)); - m_body->SetAngularVelocity(m_angularVelocity); - } - - void Step(Settings* settings) - { - Test::Step(settings); - - extern int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters; - - if (b2_gjkCalls > 0) - { - m_debugDraw.DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d", - b2_gjkCalls, b2_gjkIters / float32(b2_gjkCalls), b2_gjkMaxIters); - m_textLine += DRAW_STRING_NEW_LINE; - } - - extern int32 b2_toiCalls, b2_toiIters; - extern int32 b2_toiRootIters, b2_toiMaxRootIters; - extern float32 b2_toiTime, b2_toiMaxTime; - - if (b2_toiCalls > 0) - { - m_debugDraw.DrawString(5, m_textLine, "toi calls = %d, ave [max] toi iters = %3.1f [%d]", - b2_toiCalls, b2_toiIters / float32(b2_toiCalls), b2_toiMaxRootIters); - m_textLine += DRAW_STRING_NEW_LINE; - - m_debugDraw.DrawString(5, m_textLine, "ave [max] toi root iters = %3.1f [%d]", - b2_toiRootIters / float32(b2_toiCalls), b2_toiMaxRootIters); - m_textLine += DRAW_STRING_NEW_LINE; - - m_debugDraw.DrawString(5, m_textLine, "ave [max] toi time = %.1f [%.1f] (microseconds)", - 1000.0f * b2_toiTime / float32(b2_toiCalls), 1000.0f * b2_toiMaxTime); - m_textLine += DRAW_STRING_NEW_LINE; - } - - if (m_stepCount % 60 == 0) - { - //Launch(); - } - } - - static Test* Create() - { - return new ContinuousTest; - } - - b2Body* m_body; - float32 m_angularVelocity; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ConvexHull.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/ConvexHull.h deleted file mode 100644 index fc5742892b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ConvexHull.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_HULL_H -#define CONVEX_HULL_H - -class ConvexHull : public Test -{ -public: - enum - { - e_count = b2_maxPolygonVertices - }; - - ConvexHull() - { - Generate(); - m_auto = false; - } - - void Generate() - { - b2Vec2 lowerBound(-8.0f, -8.0f); - b2Vec2 upperBound(8.0f, 8.0f); - - for (int32 i = 0; i < e_count; ++i) - { - float32 x = 10.0f * RandomFloat(); - float32 y = 10.0f * RandomFloat(); - - // Clamp onto a square to help create collinearities. - // This will stress the convex hull algorithm. - b2Vec2 v(x, y); - v = b2Clamp(v, lowerBound, upperBound); - m_points[i] = v; - } - - m_count = e_count; - - m_points[0].Set( -1.70082211f, -1.43221712f ); - m_points[1].Set( 0.5f, -0.5f ); - m_points[2].Set( 0.104992867f, 0.97400856f ); - m_points[3].Set( -0.658002853f, 0.926608086f ); - m_points[4].Set( -0.994554818f, 0.165337861f ); - m_count = 5; - } - - static Test* Create() - { - return new ConvexHull; - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - m_auto = !m_auto; - break; - - case 'g': - Generate(); - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - b2PolygonShape shape; - shape.Set(m_points, m_count); - - m_debugDraw.DrawString(5, m_textLine, "Press g to generate a new random convex hull"); - m_textLine += DRAW_STRING_NEW_LINE; - - m_debugDraw.DrawPolygon(shape.m_vertices, shape.m_count, b2Color(0.9f, 0.9f, 0.9f)); - - for (int32 i = 0; i < m_count; ++i) - { - m_debugDraw.DrawPoint(m_points[i], 2.0f, b2Color(0.9f, 0.5f, 0.5f)); - //m_debugDraw.DrawString(m_points[i] + b2Vec2(0.05f, 0.05f), "%d", i); - } - - if (shape.Validate() == false) - { - m_textLine += 0; - } - - if (m_auto) - { - Generate(); - } - } - - b2Vec2 m_points[b2_maxPolygonVertices]; - int32 m_count; - bool m_auto; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ConveyorBelt.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/ConveyorBelt.h deleted file mode 100644 index 01ddc94043..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ConveyorBelt.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEYOR_BELT_H -#define CONVEYOR_BELT_H - -class ConveyorBelt : public Test -{ -public: - - ConveyorBelt() - { - // Ground - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - // Platform - { - b2BodyDef bd; - bd.position.Set(-5.0f, 5.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(10.0f, 0.5f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.friction = 0.8f; - m_platform = body->CreateFixture(&fd); - } - - // Boxes - for (int32 i = 0; i < 5; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-10.0f + 2.0f * i, 7.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - body->CreateFixture(&shape, 20.0f); - } - } - - void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) - { - Test::PreSolve(contact, oldManifold); - - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - if (fixtureA == m_platform) - { - contact->SetTangentSpeed(5.0f); - } - - if (fixtureB == m_platform) - { - contact->SetTangentSpeed(-5.0f); - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - } - - static Test* Create() - { - return new ConveyorBelt; - } - - b2Fixture* m_platform; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/DistanceTest.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/DistanceTest.h deleted file mode 100644 index de8c720a3d..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/DistanceTest.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef DISTANCE_TEST_H -#define DISTANCE_TEST_H - -class DistanceTest : public Test -{ -public: - DistanceTest() - { - { - m_transformA.SetIdentity(); - m_transformA.p.Set(0.0f, -0.2f); - m_polygonA.SetAsBox(10.0f, 0.2f); - } - - { - m_positionB.Set(12.017401f, 0.13678508f); - m_angleB = -0.0109265f; - m_transformB.Set(m_positionB, m_angleB); - - m_polygonB.SetAsBox(2.0f, 0.1f); - } - } - - static Test* Create() - { - return new DistanceTest; - } - - void Step(Settings* settings) - { - Test::Step(settings); - - b2DistanceInput input; - input.proxyA.Set(&m_polygonA, 0); - input.proxyB.Set(&m_polygonB, 0); - input.transformA = m_transformA; - input.transformB = m_transformB; - input.useRadii = true; - b2SimplexCache cache; - cache.count = 0; - b2DistanceOutput output; - b2Distance(&output, &cache, &input); - - m_debugDraw.DrawString(5, m_textLine, "distance = %g", output.distance); - m_textLine += DRAW_STRING_NEW_LINE; - - m_debugDraw.DrawString(5, m_textLine, "iterations = %d", output.iterations); - m_textLine += DRAW_STRING_NEW_LINE; - - { - b2Color color(0.9f, 0.9f, 0.9f); - b2Vec2 v[b2_maxPolygonVertices]; - for (int32 i = 0; i < m_polygonA.m_count; ++i) - { - v[i] = b2Mul(m_transformA, m_polygonA.m_vertices[i]); - } - m_debugDraw.DrawPolygon(v, m_polygonA.m_count, color); - - for (int32 i = 0; i < m_polygonB.m_count; ++i) - { - v[i] = b2Mul(m_transformB, m_polygonB.m_vertices[i]); - } - m_debugDraw.DrawPolygon(v, m_polygonB.m_count, color); - } - - b2Vec2 x1 = output.pointA; - b2Vec2 x2 = output.pointB; - - b2Color c1(1.0f, 0.0f, 0.0f); - m_debugDraw.DrawPoint(x1, 4.0f, c1); - - b2Color c2(1.0f, 1.0f, 0.0f); - m_debugDraw.DrawPoint(x2, 4.0f, c2); - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - m_positionB.x -= 0.1f; - break; - - case 'd': - m_positionB.x += 0.1f; - break; - - case 's': - m_positionB.y -= 0.1f; - break; - - case 'w': - m_positionB.y += 0.1f; - break; - - case 'q': - m_angleB += 0.1f * b2_pi; - break; - - case 'e': - m_angleB -= 0.1f * b2_pi; - break; - } - - m_transformB.Set(m_positionB, m_angleB); - } - - b2Vec2 m_positionB; - float32 m_angleB; - - b2Transform m_transformA; - b2Transform m_transformB; - b2PolygonShape m_polygonA; - b2PolygonShape m_polygonB; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Dominos.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Dominos.h deleted file mode 100644 index 2d9b310cf3..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Dominos.h +++ /dev/null @@ -1,215 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef DOMINOS_H -#define DOMINOS_H - -class Dominos : public Test -{ -public: - - Dominos() - { - b2Body* b1; - { - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - - b2BodyDef bd; - b1 = m_world->CreateBody(&bd); - b1->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(6.0f, 0.25f); - - b2BodyDef bd; - bd.position.Set(-1.5f, 10.0f); - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.1f, 1.0f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - fd.friction = 0.1f; - - for (int i = 0; i < 10; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-6.0f + 1.0f * i, 11.25f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&fd); - } - } - - { - b2PolygonShape shape; - shape.SetAsBox(7.0f, 0.25f, b2Vec2_zero, 0.3f); - - b2BodyDef bd; - bd.position.Set(1.0f, 6.0f); - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - b2Body* b2; - { - b2PolygonShape shape; - shape.SetAsBox(0.25f, 1.5f); - - b2BodyDef bd; - bd.position.Set(-7.0f, 4.0f); - b2 = m_world->CreateBody(&bd); - b2->CreateFixture(&shape, 0.0f); - } - - b2Body* b3; - { - b2PolygonShape shape; - shape.SetAsBox(6.0f, 0.125f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-0.9f, 1.0f); - bd.angle = -0.15f; - - b3 = m_world->CreateBody(&bd); - b3->CreateFixture(&shape, 10.0f); - } - - b2RevoluteJointDef jd; - b2Vec2 anchor; - - anchor.Set(-2.0f, 1.0f); - jd.Initialize(b1, b3, anchor); - jd.collideConnected = true; - m_world->CreateJoint(&jd); - - b2Body* b4; - { - b2PolygonShape shape; - shape.SetAsBox(0.25f, 0.25f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-10.0f, 15.0f); - b4 = m_world->CreateBody(&bd); - b4->CreateFixture(&shape, 10.0f); - } - - anchor.Set(-7.0f, 15.0f); - jd.Initialize(b2, b4, anchor); - m_world->CreateJoint(&jd); - - b2Body* b5; - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(6.5f, 3.0f); - b5 = m_world->CreateBody(&bd); - - b2PolygonShape shape; - b2FixtureDef fd; - - fd.shape = &shape; - fd.density = 10.0f; - fd.friction = 0.1f; - - shape.SetAsBox(1.0f, 0.1f, b2Vec2(0.0f, -0.9f), 0.0f); - b5->CreateFixture(&fd); - - shape.SetAsBox(0.1f, 1.0f, b2Vec2(-0.9f, 0.0f), 0.0f); - b5->CreateFixture(&fd); - - shape.SetAsBox(0.1f, 1.0f, b2Vec2(0.9f, 0.0f), 0.0f); - b5->CreateFixture(&fd); - } - - anchor.Set(6.0f, 2.0f); - jd.Initialize(b1, b5, anchor); - m_world->CreateJoint(&jd); - - b2Body* b6; - { - b2PolygonShape shape; - shape.SetAsBox(1.0f, 0.1f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(6.5f, 4.1f); - b6 = m_world->CreateBody(&bd); - b6->CreateFixture(&shape, 30.0f); - } - - anchor.Set(7.5f, 4.0f); - jd.Initialize(b5, b6, anchor); - m_world->CreateJoint(&jd); - - b2Body* b7; - { - b2PolygonShape shape; - shape.SetAsBox(0.1f, 1.0f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(7.4f, 1.0f); - - b7 = m_world->CreateBody(&bd); - b7->CreateFixture(&shape, 10.0f); - } - - b2DistanceJointDef djd; - djd.bodyA = b3; - djd.bodyB = b7; - djd.localAnchorA.Set(6.0f, 0.0f); - djd.localAnchorB.Set(0.0f, -1.0f); - b2Vec2 d = djd.bodyB->GetWorldPoint(djd.localAnchorB) - djd.bodyA->GetWorldPoint(djd.localAnchorA); - djd.length = d.Length(); - m_world->CreateJoint(&djd); - - { - float32 radius = 0.2f; - - b2CircleShape shape; - shape.m_radius = radius; - - for (int32 i = 0; i < 4; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(5.9f + 2.0f * radius * i, 2.4f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 10.0f); - } - } - } - - static Test* Create() - { - return new Dominos; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/DumpShell.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/DumpShell.h deleted file mode 100644 index 0ea705d3ee..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/DumpShell.h +++ /dev/null @@ -1,175 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef DUMP_SHELL_H -#define DUMP_SHELL_H - -// This test holds worlds dumped using b2World::Dump. -class DumpShell : public Test -{ -public: - - DumpShell() - { - //Source code dump of Box2D scene: issue304-minimal-case.rube - // - // Created by R.U.B.E 1.3.0 - // Using Box2D version 2.3.0 - // Wed April 3 2013 04:33:28 - // - // This code is originally intended for use in the Box2D testbed, - // but you can easily use it in other applications by providing - // a b2World for use as the 'm_world' variable in the code below. - - b2Vec2 g(0.000000000000000e+00f, -1.000000000000000e+01f); - m_world->SetGravity(g); - b2Body** bodies = (b2Body**)b2Alloc(3 * sizeof(b2Body*)); - b2Joint** joints = (b2Joint**)b2Alloc(0 * sizeof(b2Joint*)); - { - b2BodyDef bd; - bd.type = b2BodyType(0); - bd.position.Set(2.587699890136719e-02f, 5.515012264251709e+00f); - bd.angle = 0.000000000000000e+00f; - bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f); - bd.angularVelocity = 0.000000000000000e+00f; - bd.linearDamping = 0.000000000000000e+00f; - bd.angularDamping = 0.000000000000000e+00f; - bd.allowSleep = bool(4); - bd.awake = bool(2); - bd.fixedRotation = bool(0); - bd.bullet = bool(0); - bd.active = bool(32); - bd.gravityScale = 1.000000000000000e+00f; - bodies[0] = m_world->CreateBody(&bd); - - { - b2FixtureDef fd; - fd.friction = 2.000000029802322e-01f; - fd.restitution = 0.000000000000000e+00f; - fd.density = 1.000000000000000e+00f; - fd.isSensor = bool(0); - fd.filter.categoryBits = uint16(1); - fd.filter.maskBits = uint16(65535); - fd.filter.groupIndex = int16(0); - b2PolygonShape shape; - b2Vec2 vs[8]; - vs[0].Set(7.733039855957031e-01f, -1.497260034084320e-01f); - vs[1].Set(-4.487270116806030e-01f, 1.138330027461052e-01f); - vs[2].Set(-1.880589962005615e+00f, -1.365900039672852e-01f); - vs[3].Set(3.972740173339844e-01f, -3.897832870483398e+00f); - shape.Set(vs, 4); - - fd.shape = &shape; - - bodies[0]->CreateFixture(&fd); - } - } - { - b2BodyDef bd; - bd.type = b2BodyType(2); - bd.position.Set(-3.122138977050781e-02f, 7.535382270812988e+00f); - bd.angle = -1.313644275069237e-02f; - bd.linearVelocity.Set(8.230687379837036e-01f, 7.775862514972687e-02f); - bd.angularVelocity = 3.705333173274994e-02f; - bd.linearDamping = 0.000000000000000e+00f; - bd.angularDamping = 0.000000000000000e+00f; - bd.allowSleep = bool(4); - bd.awake = bool(2); - bd.fixedRotation = bool(0); - bd.bullet = bool(0); - bd.active = bool(32); - bd.gravityScale = 1.000000000000000e+00f; - bodies[1] = m_world->CreateBody(&bd); - - { - b2FixtureDef fd; - fd.friction = 5.000000000000000e-01f; - fd.restitution = 0.000000000000000e+00f; - fd.density = 5.000000000000000e+00f; - fd.isSensor = bool(0); - fd.filter.categoryBits = uint16(1); - fd.filter.maskBits = uint16(65535); - fd.filter.groupIndex = int16(0); - b2PolygonShape shape; - b2Vec2 vs[8]; - vs[0].Set(3.473900079727173e+00f, -2.009889930486679e-01f); - vs[1].Set(3.457079887390137e+00f, 3.694039955735207e-02f); - vs[2].Set(-3.116359949111938e+00f, 2.348500071093440e-03f); - vs[3].Set(-3.109960079193115e+00f, -3.581250011920929e-01f); - vs[4].Set(-2.590820074081421e+00f, -5.472509860992432e-01f); - vs[5].Set(2.819370031356812e+00f, -5.402340292930603e-01f); - shape.Set(vs, 6); - - fd.shape = &shape; - - bodies[1]->CreateFixture(&fd); - } - } - { - b2BodyDef bd; - bd.type = b2BodyType(2); - bd.position.Set(-7.438077926635742e-01f, 6.626811981201172e+00f); - bd.angle = -1.884713363647461e+01f; - bd.linearVelocity.Set(1.785794943571091e-01f, 3.799796104431152e-07f); - bd.angularVelocity = -5.908820639888290e-06f; - bd.linearDamping = 0.000000000000000e+00f; - bd.angularDamping = 0.000000000000000e+00f; - bd.allowSleep = bool(4); - bd.awake = bool(2); - bd.fixedRotation = bool(0); - bd.bullet = bool(0); - bd.active = bool(32); - bd.gravityScale = 1.000000000000000e+00f; - bodies[2] = m_world->CreateBody(&bd); - - { - b2FixtureDef fd; - fd.friction = 9.499999880790710e-01f; - fd.restitution = 0.000000000000000e+00f; - fd.density = 1.000000000000000e+01f; - fd.isSensor = bool(0); - fd.filter.categoryBits = uint16(1); - fd.filter.maskBits = uint16(65535); - fd.filter.groupIndex = int16(-3); - b2PolygonShape shape; - b2Vec2 vs[8]; - vs[0].Set(1.639146506786346e-01f, 4.428443685173988e-02f); - vs[1].Set(-1.639146655797958e-01f, 4.428443685173988e-02f); - vs[2].Set(-1.639146655797958e-01f, -4.428443312644958e-02f); - vs[3].Set(1.639146357774734e-01f, -4.428444057703018e-02f); - shape.Set(vs, 4); - - fd.shape = &shape; - - bodies[2]->CreateFixture(&fd); - } - } - b2Free(joints); - b2Free(bodies); - joints = NULL; - bodies = NULL; - - } - - static Test* Create() - { - return new DumpShell; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/DynamicTreeTest.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/DynamicTreeTest.h deleted file mode 100644 index 4531630d4b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/DynamicTreeTest.h +++ /dev/null @@ -1,357 +0,0 @@ -/* -* Copyright (c) 2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef DYNAMIC_TREE_TEST_H -#define DYNAMIC_TREE_TEST_H - -class DynamicTreeTest : public Test -{ -public: - - enum - { - e_actorCount = 128 - }; - - DynamicTreeTest() - { - m_worldExtent = 15.0f; - m_proxyExtent = 0.5f; - - std::srand(888); - - for (int32 i = 0; i < e_actorCount; ++i) - { - Actor* actor = m_actors + i; - GetRandomAABB(&actor->aabb); - actor->proxyId = m_tree.CreateProxy(actor->aabb, actor); - } - - m_stepCount = 0; - - float32 h = m_worldExtent; - m_queryAABB.lowerBound.Set(-3.0f, -4.0f + h); - m_queryAABB.upperBound.Set(5.0f, 6.0f + h); - - m_rayCastInput.p1.Set(-5.0, 5.0f + h); - m_rayCastInput.p2.Set(7.0f, -4.0f + h); - //m_rayCastInput.p1.Set(0.0f, 2.0f + h); - //m_rayCastInput.p2.Set(0.0f, -2.0f + h); - m_rayCastInput.maxFraction = 1.0f; - - m_automated = false; - } - - static Test* Create() - { - return new DynamicTreeTest; - } - - void Step(Settings* settings) - { - B2_NOT_USED(settings); - - m_rayActor = NULL; - for (int32 i = 0; i < e_actorCount; ++i) - { - m_actors[i].fraction = 1.0f; - m_actors[i].overlap = false; - } - - if (m_automated == true) - { - int32 actionCount = b2Max(1, e_actorCount >> 2); - - for (int32 i = 0; i < actionCount; ++i) - { - Action(); - } - } - - Query(); - RayCast(); - - for (int32 i = 0; i < e_actorCount; ++i) - { - Actor* actor = m_actors + i; - if (actor->proxyId == b2_nullNode) - continue; - - b2Color c(0.9f, 0.9f, 0.9f); - if (actor == m_rayActor && actor->overlap) - { - c.Set(0.9f, 0.6f, 0.6f); - } - else if (actor == m_rayActor) - { - c.Set(0.6f, 0.9f, 0.6f); - } - else if (actor->overlap) - { - c.Set(0.6f, 0.6f, 0.9f); - } - - m_debugDraw.DrawAABB(&actor->aabb, c); - } - - b2Color c(0.7f, 0.7f, 0.7f); - m_debugDraw.DrawAABB(&m_queryAABB, c); - - m_debugDraw.DrawSegment(m_rayCastInput.p1, m_rayCastInput.p2, c); - - b2Color c1(0.2f, 0.9f, 0.2f); - b2Color c2(0.9f, 0.2f, 0.2f); - m_debugDraw.DrawPoint(m_rayCastInput.p1, 6.0f, c1); - m_debugDraw.DrawPoint(m_rayCastInput.p2, 6.0f, c2); - - if (m_rayActor) - { - b2Color cr(0.2f, 0.2f, 0.9f); - b2Vec2 p = m_rayCastInput.p1 + m_rayActor->fraction * (m_rayCastInput.p2 - m_rayCastInput.p1); - m_debugDraw.DrawPoint(p, 6.0f, cr); - } - - { - int32 height = m_tree.GetHeight(); - m_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d", height); - m_textLine += DRAW_STRING_NEW_LINE; - } - - ++m_stepCount; - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - m_automated = !m_automated; - break; - - case 'c': - CreateProxy(); - break; - - case 'd': - DestroyProxy(); - break; - - case 'm': - MoveProxy(); - break; - } - } - - bool QueryCallback(int32 proxyId) - { - Actor* actor = (Actor*)m_tree.GetUserData(proxyId); - actor->overlap = b2TestOverlap(m_queryAABB, actor->aabb); - return true; - } - - float32 RayCastCallback(const b2RayCastInput& input, int32 proxyId) - { - Actor* actor = (Actor*)m_tree.GetUserData(proxyId); - - b2RayCastOutput output; - bool hit = actor->aabb.RayCast(&output, input); - - if (hit) - { - m_rayCastOutput = output; - m_rayActor = actor; - m_rayActor->fraction = output.fraction; - return output.fraction; - } - - return input.maxFraction; - } - -private: - - struct Actor - { - b2AABB aabb; - float32 fraction; - bool overlap; - int32 proxyId; - }; - - void GetRandomAABB(b2AABB* aabb) - { - b2Vec2 w; w.Set(2.0f * m_proxyExtent, 2.0f * m_proxyExtent); - //aabb->lowerBound.x = -m_proxyExtent; - //aabb->lowerBound.y = -m_proxyExtent + m_worldExtent; - aabb->lowerBound.x = RandomFloat(-m_worldExtent, m_worldExtent); - aabb->lowerBound.y = RandomFloat(0.0f, 2.0f * m_worldExtent); - aabb->upperBound = aabb->lowerBound + w; - } - - void MoveAABB(b2AABB* aabb) - { - b2Vec2 d; - d.x = RandomFloat(-0.5f, 0.5f); - d.y = RandomFloat(-0.5f, 0.5f); - //d.x = 2.0f; - //d.y = 0.0f; - aabb->lowerBound += d; - aabb->upperBound += d; - - b2Vec2 c0 = 0.5f * (aabb->lowerBound + aabb->upperBound); - b2Vec2 min; min.Set(-m_worldExtent, 0.0f); - b2Vec2 max; max.Set(m_worldExtent, 2.0f * m_worldExtent); - b2Vec2 c = b2Clamp(c0, min, max); - - aabb->lowerBound += c - c0; - aabb->upperBound += c - c0; - } - - void CreateProxy() - { - for (int32 i = 0; i < e_actorCount; ++i) - { - int32 j = rand() % e_actorCount; - Actor* actor = m_actors + j; - if (actor->proxyId == b2_nullNode) - { - GetRandomAABB(&actor->aabb); - actor->proxyId = m_tree.CreateProxy(actor->aabb, actor); - return; - } - } - } - - void DestroyProxy() - { - for (int32 i = 0; i < e_actorCount; ++i) - { - int32 j = rand() % e_actorCount; - Actor* actor = m_actors + j; - if (actor->proxyId != b2_nullNode) - { - m_tree.DestroyProxy(actor->proxyId); - actor->proxyId = b2_nullNode; - return; - } - } - } - - void MoveProxy() - { - for (int32 i = 0; i < e_actorCount; ++i) - { - int32 j = rand() % e_actorCount; - Actor* actor = m_actors + j; - if (actor->proxyId == b2_nullNode) - { - continue; - } - - b2AABB aabb0 = actor->aabb; - MoveAABB(&actor->aabb); - b2Vec2 displacement = actor->aabb.GetCenter() - aabb0.GetCenter(); - m_tree.MoveProxy(actor->proxyId, actor->aabb, displacement); - return; - } - } - - void Action() - { - int32 choice = rand() % 20; - - switch (choice) - { - case 0: - CreateProxy(); - break; - - case 1: - DestroyProxy(); - break; - - default: - MoveProxy(); - } - } - - void Query() - { - m_tree.Query(this, m_queryAABB); - - for (int32 i = 0; i < e_actorCount; ++i) - { - if (m_actors[i].proxyId == b2_nullNode) - { - continue; - } - - bool overlap = b2TestOverlap(m_queryAABB, m_actors[i].aabb); - B2_NOT_USED(overlap); - b2Assert(overlap == m_actors[i].overlap); - } - } - - void RayCast() - { - m_rayActor = NULL; - - b2RayCastInput input = m_rayCastInput; - - // Ray cast against the dynamic tree. - m_tree.RayCast(this, input); - - // Brute force ray cast. - Actor* bruteActor = NULL; - b2RayCastOutput bruteOutput; - for (int32 i = 0; i < e_actorCount; ++i) - { - if (m_actors[i].proxyId == b2_nullNode) - { - continue; - } - - b2RayCastOutput output; - bool hit = m_actors[i].aabb.RayCast(&output, input); - if (hit) - { - bruteActor = m_actors + i; - bruteOutput = output; - input.maxFraction = output.fraction; - } - } - - if (bruteActor != NULL) - { - b2Assert(bruteOutput.fraction == m_rayCastOutput.fraction); - } - } - - float32 m_worldExtent; - float32 m_proxyExtent; - - b2DynamicTree m_tree; - b2AABB m_queryAABB; - b2RayCastInput m_rayCastInput; - b2RayCastOutput m_rayCastOutput; - Actor* m_rayActor; - Actor m_actors[e_actorCount]; - int32 m_stepCount; - bool m_automated; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/EdgeShapes.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/EdgeShapes.h deleted file mode 100644 index 09fd2061e7..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/EdgeShapes.h +++ /dev/null @@ -1,249 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef EDGE_SHAPES_H -#define EDGE_SHAPES_H - -class EdgeShapesCallback : public b2RayCastCallback -{ -public: - EdgeShapesCallback() - { - m_fixture = NULL; - } - - float32 ReportFixture( b2Fixture* fixture, const b2Vec2& point, - const b2Vec2& normal, float32 fraction) - { - m_fixture = fixture; - m_point = point; - m_normal = normal; - - return fraction; - } - - b2Fixture* m_fixture; - b2Vec2 m_point; - b2Vec2 m_normal; -}; - -class EdgeShapes : public Test -{ -public: - - enum - { - e_maxBodies = 256 - }; - - EdgeShapes() - { - // Ground body - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - float32 x1 = -20.0f; - float32 y1 = 2.0f * cosf(x1 / 10.0f * b2_pi); - for (int32 i = 0; i < 80; ++i) - { - float32 x2 = x1 + 0.5f; - float32 y2 = 2.0f * cosf(x2 / 10.0f * b2_pi); - - b2EdgeShape shape; - shape.Set(b2Vec2(x1, y1), b2Vec2(x2, y2)); - ground->CreateFixture(&shape, 0.0f); - - x1 = x2; - y1 = y2; - } - } - - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.5f, 0.0f); - vertices[1].Set(0.5f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - m_polygons[0].Set(vertices, 3); - } - - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.1f, 0.0f); - vertices[1].Set(0.1f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - m_polygons[1].Set(vertices, 3); - } - - { - float32 w = 1.0f; - float32 b = w / (2.0f + b2Sqrt(2.0f)); - float32 s = b2Sqrt(2.0f) * b; - - b2Vec2 vertices[8]; - vertices[0].Set(0.5f * s, 0.0f); - vertices[1].Set(0.5f * w, b); - vertices[2].Set(0.5f * w, b + s); - vertices[3].Set(0.5f * s, w); - vertices[4].Set(-0.5f * s, w); - vertices[5].Set(-0.5f * w, b + s); - vertices[6].Set(-0.5f * w, b); - vertices[7].Set(-0.5f * s, 0.0f); - - m_polygons[2].Set(vertices, 8); - } - - { - m_polygons[3].SetAsBox(0.5f, 0.5f); - } - - { - m_circle.m_radius = 0.5f; - } - - m_bodyIndex = 0; - memset(m_bodies, 0, sizeof(m_bodies)); - - m_angle = 0.0f; - } - - void Create(int32 index) - { - if (m_bodies[m_bodyIndex] != NULL) - { - m_world->DestroyBody(m_bodies[m_bodyIndex]); - m_bodies[m_bodyIndex] = NULL; - } - - b2BodyDef bd; - - float32 x = RandomFloat(-10.0f, 10.0f); - float32 y = RandomFloat(10.0f, 20.0f); - bd.position.Set(x, y); - bd.angle = RandomFloat(-b2_pi, b2_pi); - bd.type = b2_dynamicBody; - - if (index == 4) - { - bd.angularDamping = 0.02f; - } - - m_bodies[m_bodyIndex] = m_world->CreateBody(&bd); - - if (index < 4) - { - b2FixtureDef fd; - fd.shape = m_polygons + index; - fd.friction = 0.3f; - fd.density = 20.0f; - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - else - { - b2FixtureDef fd; - fd.shape = &m_circle; - fd.friction = 0.3f; - fd.density = 20.0f; - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - - m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies; - } - - void DestroyBody() - { - for (int32 i = 0; i < e_maxBodies; ++i) - { - if (m_bodies[i] != NULL) - { - m_world->DestroyBody(m_bodies[i]); - m_bodies[i] = NULL; - return; - } - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case '1': - case '2': - case '3': - case '4': - case '5': - Create(key - '1'); - break; - - case 'd': - DestroyBody(); - break; - } - } - - void Step(Settings* settings) - { - bool advanceRay = settings->pause == 0 || settings->singleStep; - - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff"); - m_textLine += DRAW_STRING_NEW_LINE; - - float32 L = 25.0f; - b2Vec2 point1(0.0f, 10.0f); - b2Vec2 d(L * cosf(m_angle), -L * b2Abs(sinf(m_angle))); - b2Vec2 point2 = point1 + d; - - EdgeShapesCallback callback; - - m_world->RayCast(&callback, point1, point2); - - if (callback.m_fixture) - { - m_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f)); - - m_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f)); - - b2Vec2 head = callback.m_point + 0.5f * callback.m_normal; - m_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f)); - } - else - { - m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f)); - } - - if (advanceRay) - { - m_angle += 0.25f * b2_pi / 180.0f; - } - } - - static Test* Create() - { - return new EdgeShapes; - } - - int32 m_bodyIndex; - b2Body* m_bodies[e_maxBodies]; - b2PolygonShape m_polygons[4]; - b2CircleShape m_circle; - - float32 m_angle; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/EdgeTest.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/EdgeTest.h deleted file mode 100644 index a89f262807..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/EdgeTest.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef EDGE_TEST_H -#define EDGE_TEST_H - -class EdgeTest : public Test -{ -public: - - EdgeTest() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2Vec2 v1(-10.0f, 0.0f), v2(-7.0f, -2.0f), v3(-4.0f, 0.0f); - b2Vec2 v4(0.0f, 0.0f), v5(4.0f, 0.0f), v6(7.0f, 2.0f), v7(10.0f, 0.0f); - - b2EdgeShape shape; - - shape.Set(v1, v2); - shape.m_hasVertex3 = true; - shape.m_vertex3 = v3; - ground->CreateFixture(&shape, 0.0f); - - shape.Set(v2, v3); - shape.m_hasVertex0 = true; - shape.m_hasVertex3 = true; - shape.m_vertex0 = v1; - shape.m_vertex3 = v4; - ground->CreateFixture(&shape, 0.0f); - - shape.Set(v3, v4); - shape.m_hasVertex0 = true; - shape.m_hasVertex3 = true; - shape.m_vertex0 = v2; - shape.m_vertex3 = v5; - ground->CreateFixture(&shape, 0.0f); - - shape.Set(v4, v5); - shape.m_hasVertex0 = true; - shape.m_hasVertex3 = true; - shape.m_vertex0 = v3; - shape.m_vertex3 = v6; - ground->CreateFixture(&shape, 0.0f); - - shape.Set(v5, v6); - shape.m_hasVertex0 = true; - shape.m_hasVertex3 = true; - shape.m_vertex0 = v4; - shape.m_vertex3 = v7; - ground->CreateFixture(&shape, 0.0f); - - shape.Set(v6, v7); - shape.m_hasVertex0 = true; - shape.m_vertex0 = v5; - ground->CreateFixture(&shape, 0.0f); - } - - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-0.5f, 0.6f); - bd.allowSleep = false; - b2Body* body = m_world->CreateBody(&bd); - - b2CircleShape shape; - shape.m_radius = 0.5f; - - body->CreateFixture(&shape, 1.0f); - } - - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(1.0f, 0.6f); - bd.allowSleep = false; - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - - body->CreateFixture(&shape, 1.0f); - } - } - - static Test* Create() - { - return new EdgeTest; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Gears.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Gears.h deleted file mode 100644 index 580707cefa..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Gears.h +++ /dev/null @@ -1,186 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef GEARS_H -#define GEARS_H - -class Gears : public Test -{ -public: - Gears() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(50.0f, 0.0f), b2Vec2(-50.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2CircleShape circle1; - circle1.m_radius = 1.0f; - - b2PolygonShape box; - box.SetAsBox(0.5f, 5.0f); - - b2CircleShape circle2; - circle2.m_radius = 2.0f; - - b2BodyDef bd1; - bd1.type = b2_staticBody; - bd1.position.Set(10.0f, 9.0f); - b2Body* body1 = m_world->CreateBody(&bd1); - body1->CreateFixture(&circle1, 5.0f); - - b2BodyDef bd2; - bd2.type = b2_dynamicBody; - bd2.position.Set(10.0f, 8.0f); - b2Body* body2 = m_world->CreateBody(&bd2); - body2->CreateFixture(&box, 5.0f); - - b2BodyDef bd3; - bd3.type = b2_dynamicBody; - bd3.position.Set(10.0f, 6.0f); - b2Body* body3 = m_world->CreateBody(&bd3); - body3->CreateFixture(&circle2, 5.0f); - - b2RevoluteJointDef jd1; - jd1.Initialize(body2, body1, bd1.position); - b2Joint* joint1 = m_world->CreateJoint(&jd1); - - b2RevoluteJointDef jd2; - jd2.Initialize(body2, body3, bd3.position); - b2Joint* joint2 = m_world->CreateJoint(&jd2); - - b2GearJointDef jd4; - jd4.bodyA = body1; - jd4.bodyB = body3; - jd4.joint1 = joint1; - jd4.joint2 = joint2; - jd4.ratio = circle2.m_radius / circle1.m_radius; - m_world->CreateJoint(&jd4); - } - - { - b2CircleShape circle1; - circle1.m_radius = 1.0f; - - b2CircleShape circle2; - circle2.m_radius = 2.0f; - - b2PolygonShape box; - box.SetAsBox(0.5f, 5.0f); - - b2BodyDef bd1; - bd1.type = b2_dynamicBody; - bd1.position.Set(-3.0f, 12.0f); - b2Body* body1 = m_world->CreateBody(&bd1); - body1->CreateFixture(&circle1, 5.0f); - - b2RevoluteJointDef jd1; - jd1.bodyA = ground; - jd1.bodyB = body1; - jd1.localAnchorA = ground->GetLocalPoint(bd1.position); - jd1.localAnchorB = body1->GetLocalPoint(bd1.position); - jd1.referenceAngle = body1->GetAngle() - ground->GetAngle(); - m_joint1 = (b2RevoluteJoint*)m_world->CreateJoint(&jd1); - - b2BodyDef bd2; - bd2.type = b2_dynamicBody; - bd2.position.Set(0.0f, 12.0f); - b2Body* body2 = m_world->CreateBody(&bd2); - body2->CreateFixture(&circle2, 5.0f); - - b2RevoluteJointDef jd2; - jd2.Initialize(ground, body2, bd2.position); - m_joint2 = (b2RevoluteJoint*)m_world->CreateJoint(&jd2); - - b2BodyDef bd3; - bd3.type = b2_dynamicBody; - bd3.position.Set(2.5f, 12.0f); - b2Body* body3 = m_world->CreateBody(&bd3); - body3->CreateFixture(&box, 5.0f); - - b2PrismaticJointDef jd3; - jd3.Initialize(ground, body3, bd3.position, b2Vec2(0.0f, 1.0f)); - jd3.lowerTranslation = -5.0f; - jd3.upperTranslation = 5.0f; - jd3.enableLimit = true; - - m_joint3 = (b2PrismaticJoint*)m_world->CreateJoint(&jd3); - - b2GearJointDef jd4; - jd4.bodyA = body1; - jd4.bodyB = body2; - jd4.joint1 = m_joint1; - jd4.joint2 = m_joint2; - jd4.ratio = circle2.m_radius / circle1.m_radius; - m_joint4 = (b2GearJoint*)m_world->CreateJoint(&jd4); - - b2GearJointDef jd5; - jd5.bodyA = body2; - jd5.bodyB = body3; - jd5.joint1 = m_joint2; - jd5.joint2 = m_joint3; - jd5.ratio = -1.0f / circle2.m_radius; - m_joint5 = (b2GearJoint*)m_world->CreateJoint(&jd5); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 0: - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - float32 ratio, value; - - ratio = m_joint4->GetRatio(); - value = m_joint1->GetJointAngle() + ratio * m_joint2->GetJointAngle(); - m_debugDraw.DrawString(5, m_textLine, "theta1 + %4.2f * theta2 = %4.2f", (float) ratio, (float) value); - m_textLine += DRAW_STRING_NEW_LINE; - - ratio = m_joint5->GetRatio(); - value = m_joint2->GetJointAngle() + ratio * m_joint3->GetJointTranslation(); - m_debugDraw.DrawString(5, m_textLine, "theta2 + %4.2f * delta = %4.2f", (float) ratio, (float) value); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new Gears; - } - - b2RevoluteJoint* m_joint1; - b2RevoluteJoint* m_joint2; - b2PrismaticJoint* m_joint3; - b2GearJoint* m_joint4; - b2GearJoint* m_joint5; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Mobile.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Mobile.h deleted file mode 100644 index d16e659379..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Mobile.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MOBILE_H -#define MOBILE_H - -class Mobile : public Test -{ -public: - - enum - { - e_depth = 4 - }; - - Mobile() - { - b2Body* ground; - - // Create ground body. - { - b2BodyDef bodyDef; - bodyDef.position.Set(0.0f, 5.0f); - ground = m_world->CreateBody(&bodyDef); - } - - float32 a = 0.5f; - b2Vec2 h(0.0f, a); - - b2Body* root = AddNode(ground, b2Vec2_zero, 0, 3.0f, a); - - b2RevoluteJointDef jointDef; - jointDef.bodyA = ground; - jointDef.bodyB = root; - jointDef.localAnchorA.SetZero(); - jointDef.localAnchorB = h; - m_world->CreateJoint(&jointDef); - } - - b2Body* AddNode(b2Body* parent, const b2Vec2& localAnchor, int32 depth, float32 offset, float32 a) - { - float32 density = 20.0f; - b2Vec2 h(0.0f, a); - - b2Vec2 p = parent->GetPosition() + localAnchor - h; - - b2BodyDef bodyDef; - bodyDef.type = b2_dynamicBody; - bodyDef.position = p; - b2Body* body = m_world->CreateBody(&bodyDef); - - b2PolygonShape shape; - shape.SetAsBox(0.25f * a, a); - body->CreateFixture(&shape, density); - - if (depth == e_depth) - { - return body; - } - - b2Vec2 a1 = b2Vec2(offset, -a); - b2Vec2 a2 = b2Vec2(-offset, -a); - b2Body* body1 = AddNode(body, a1, depth + 1, 0.5f * offset, a); - b2Body* body2 = AddNode(body, a2, depth + 1, 0.5f * offset, a); - - b2RevoluteJointDef jointDef; - jointDef.bodyA = body; - jointDef.localAnchorB = h; - - jointDef.localAnchorA = a1; - jointDef.bodyB = body1; - m_world->CreateJoint(&jointDef); - - jointDef.localAnchorA = a2; - jointDef.bodyB = body2; - m_world->CreateJoint(&jointDef); - - return body; - } - - static Test* Create() - { - return new Mobile; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/MobileBalanced.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/MobileBalanced.h deleted file mode 100644 index ea4784190b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/MobileBalanced.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MOBILE_BALANCED_H -#define MOBILE_BALANCED_H - -class MobileBalanced : public Test -{ -public: - - enum - { - e_depth = 4 - }; - - MobileBalanced() - { - b2Body* ground; - - // Create ground body. - { - b2BodyDef bodyDef; - bodyDef.position.Set(0.0f, 5.0f); - ground = m_world->CreateBody(&bodyDef); - } - - float32 a = 0.5f; - b2Vec2 h(0.0f, a); - - b2Body* root = AddNode(ground, b2Vec2_zero, 0, 3.0f, a); - - b2RevoluteJointDef jointDef; - jointDef.bodyA = ground; - jointDef.bodyB = root; - jointDef.localAnchorA.SetZero(); - jointDef.localAnchorB = h; - m_world->CreateJoint(&jointDef); - } - - b2Body* AddNode(b2Body* parent, const b2Vec2& localAnchor, int32 depth, float32 offset, float32 a) - { - float32 density = 20.0f; - b2Vec2 h(0.0f, a); - - b2Vec2 p = parent->GetPosition() + localAnchor - h; - - b2BodyDef bodyDef; - bodyDef.type = b2_dynamicBody; - bodyDef.position = p; - b2Body* body = m_world->CreateBody(&bodyDef); - - b2PolygonShape shape; - shape.SetAsBox(0.25f * a, a); - body->CreateFixture(&shape, density); - - if (depth == e_depth) - { - return body; - } - - shape.SetAsBox(offset, 0.25f * a, b2Vec2(0, -a), 0.0f); - body->CreateFixture(&shape, density); - - b2Vec2 a1 = b2Vec2(offset, -a); - b2Vec2 a2 = b2Vec2(-offset, -a); - b2Body* body1 = AddNode(body, a1, depth + 1, 0.5f * offset, a); - b2Body* body2 = AddNode(body, a2, depth + 1, 0.5f * offset, a); - - b2RevoluteJointDef jointDef; - jointDef.bodyA = body; - jointDef.localAnchorB = h; - - jointDef.localAnchorA = a1; - jointDef.bodyB = body1; - m_world->CreateJoint(&jointDef); - - jointDef.localAnchorA = a2; - jointDef.bodyB = body2; - m_world->CreateJoint(&jointDef); - - return body; - } - - static Test* Create() - { - return new MobileBalanced; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/MotorJoint.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/MotorJoint.h deleted file mode 100644 index cd3ded9bae..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/MotorJoint.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -* Copyright (c) 2006-2012 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MOTOR_JOINT_H -#define MOTOR_JOINT_H - -/// This test shows how to use a motor joint. A motor joint -/// can be used to animate a dynamic body. With finite motor forces -/// the body can be blocked by collision with other bodies. -class MotorJoint : public Test -{ -public: - MotorJoint() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); - - b2FixtureDef fd; - fd.shape = &shape; - - ground->CreateFixture(&fd); - } - - // Define motorized body - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 8.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(2.0f, 0.5f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.friction = 0.6f; - fd.density = 2.0f; - body->CreateFixture(&fd); - - b2MotorJointDef mjd; - mjd.Initialize(ground, body); - mjd.maxForce = 1000.0f; - mjd.maxTorque = 1000.0f; - m_joint = (b2MotorJoint*)m_world->CreateJoint(&mjd); - } - - m_go = false; - m_time = 0.0f; - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 's': - m_go = !m_go; - break; - } - } - - void Step(Settings* settings) - { - if (m_go && settings->hz > 0.0f) - { - m_time += 1.0f / settings->hz; - } - - b2Vec2 linearOffset; - linearOffset.x = 6.0f * sinf(2.0f * m_time); - linearOffset.y = 8.0f + 4.0f * sinf(1.0f * m_time); - - float32 angularOffset = 4.0f * m_time; - - m_joint->SetLinearOffset(linearOffset); - m_joint->SetAngularOffset(angularOffset); - - m_debugDraw.DrawPoint(linearOffset, 4.0f, b2Color(0.9f, 0.9f, 0.9f)); - - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Keys: (s) pause"); - m_textLine += 15; - } - - static Test* Create() - { - return new MotorJoint; - } - - b2MotorJoint* m_joint; - float32 m_time; - bool m_go; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/OneSidedPlatform.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/OneSidedPlatform.h deleted file mode 100644 index 69e339a855..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/OneSidedPlatform.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -* Copyright (c) 2008-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef ONE_SIDED_PLATFORM_H -#define ONE_SIDED_PLATFORM_H - -class OneSidedPlatform : public Test -{ -public: - - enum State - { - e_unknown, - e_above, - e_below - }; - - OneSidedPlatform() - { - // Ground - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - // Platform - { - b2BodyDef bd; - bd.position.Set(0.0f, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(3.0f, 0.5f); - m_platform = body->CreateFixture(&shape, 0.0f); - - m_bottom = 10.0f - 0.5f; - m_top = 10.0f + 0.5f; - } - - // Actor - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 12.0f); - b2Body* body = m_world->CreateBody(&bd); - - m_radius = 0.5f; - b2CircleShape shape; - shape.m_radius = m_radius; - m_character = body->CreateFixture(&shape, 20.0f); - - body->SetLinearVelocity(b2Vec2(0.0f, -50.0f)); - - m_state = e_unknown; - } - } - - void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) - { - Test::PreSolve(contact, oldManifold); - - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - if (fixtureA != m_platform && fixtureA != m_character) - { - return; - } - - if (fixtureB != m_platform && fixtureB != m_character) - { - return; - } - -#if 1 - b2Vec2 position = m_character->GetBody()->GetPosition(); - - if (position.y < m_top + m_radius - 3.0f * b2_linearSlop) - { - contact->SetEnabled(false); - } -#else - b2Vec2 v = m_character->GetBody()->GetLinearVelocity(); - if (v.y > 0.0f) - { - contact->SetEnabled(false); - } -#endif - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape."); - m_textLine += DRAW_STRING_NEW_LINE; - - b2Vec2 v = m_character->GetBody()->GetLinearVelocity(); - m_debugDraw.DrawString(5, m_textLine, "Character Linear Velocity: %f", v.y); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new OneSidedPlatform; - } - - float32 m_radius, m_top, m_bottom; - State m_state; - b2Fixture* m_platform; - b2Fixture* m_character; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pinball.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pinball.h deleted file mode 100644 index 9d5982f25f..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pinball.h +++ /dev/null @@ -1,169 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef PINBALL_H -#define PINBALL_H - -/// This tests bullet collision and provides an example of a gameplay scenario. -/// This also uses a loop shape. -class Pinball : public Test -{ -public: - Pinball() - { - // Ground body - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2Vec2 vs[5]; - vs[0].Set(0.0f, -2.0f); - vs[1].Set(8.0f, 6.0f); - vs[2].Set(8.0f, 20.0f); - vs[3].Set(-8.0f, 20.0f); - vs[4].Set(-8.0f, 6.0f); - - b2ChainShape loop; - loop.CreateLoop(vs, 5); - b2FixtureDef fd; - fd.shape = &loop; - fd.density = 0.0f; - ground->CreateFixture(&fd); - } - - // Flippers - { - b2Vec2 p1(-2.0f, 0.0f), p2(2.0f, 0.0f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - - bd.position = p1; - b2Body* leftFlipper = m_world->CreateBody(&bd); - - bd.position = p2; - b2Body* rightFlipper = m_world->CreateBody(&bd); - - b2PolygonShape box; - box.SetAsBox(1.75f, 0.1f); - - b2FixtureDef fd; - fd.shape = &box; - fd.density = 1.0f; - - leftFlipper->CreateFixture(&fd); - rightFlipper->CreateFixture(&fd); - - b2RevoluteJointDef jd; - jd.bodyA = ground; - jd.localAnchorB.SetZero(); - jd.enableMotor = true; - jd.maxMotorTorque = 1000.0f; - jd.enableLimit = true; - - jd.motorSpeed = 0.0f; - jd.localAnchorA = p1; - jd.bodyB = leftFlipper; - jd.lowerAngle = -30.0f * b2_pi / 180.0f; - jd.upperAngle = 5.0f * b2_pi / 180.0f; - m_leftJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd); - - jd.motorSpeed = 0.0f; - jd.localAnchorA = p2; - jd.bodyB = rightFlipper; - jd.lowerAngle = -5.0f * b2_pi / 180.0f; - jd.upperAngle = 30.0f * b2_pi / 180.0f; - m_rightJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd); - } - - // Circle character - { - b2BodyDef bd; - bd.position.Set(1.0f, 15.0f); - bd.type = b2_dynamicBody; - bd.bullet = true; - - m_ball = m_world->CreateBody(&bd); - - b2CircleShape shape; - shape.m_radius = 0.2f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - m_ball->CreateFixture(&fd); - } - - m_button = false; - } - - void Step(Settings* settings) - { - if (m_button) - { - m_leftJoint->SetMotorSpeed(20.0f); - m_rightJoint->SetMotorSpeed(-20.0f); - } - else - { - m_leftJoint->SetMotorSpeed(-10.0f); - m_rightJoint->SetMotorSpeed(10.0f); - } - - Test::Step(settings); - - m_debugDraw.DrawString(5, m_textLine, "Press 'a' to control the flippers"); - m_textLine += DRAW_STRING_NEW_LINE; - - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - case 'A': - m_button = true; - break; - } - } - - void KeyboardUp(unsigned char key) - { - switch (key) - { - case 'a': - case 'A': - m_button = false; - break; - } - } - - static Test* Create() - { - return new Pinball; - } - - b2RevoluteJoint* m_leftJoint; - b2RevoluteJoint* m_rightJoint; - b2Body* m_ball; - bool m_button; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/PolyCollision.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/PolyCollision.h deleted file mode 100644 index 0316a7b16e..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/PolyCollision.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef POLYCOLLISION_H -#define POLYCOLLISION_H - -class PolyCollision : public Test -{ -public: - PolyCollision() - { - { - m_polygonA.SetAsBox(0.2f, 0.4f); - m_transformA.Set(b2Vec2(0.0f, 0.0f), 0.0f); - } - - { - m_polygonB.SetAsBox(0.5f, 0.5f); - m_positionB.Set(19.345284f, 1.5632932f); - m_angleB = 1.9160721f; - m_transformB.Set(m_positionB, m_angleB); - } - } - - static Test* Create() - { - return new PolyCollision; - } - - void Step(Settings* settings) - { - B2_NOT_USED(settings); - - b2Manifold manifold; - b2CollidePolygons(&manifold, &m_polygonA, m_transformA, &m_polygonB, m_transformB); - - b2WorldManifold worldManifold; - worldManifold.Initialize(&manifold, m_transformA, m_polygonA.m_radius, m_transformB, m_polygonB.m_radius); - - m_debugDraw.DrawString(5, m_textLine, "point count = %d", manifold.pointCount); - m_textLine += DRAW_STRING_NEW_LINE; - - { - b2Color color(0.9f, 0.9f, 0.9f); - b2Vec2 v[b2_maxPolygonVertices]; - for (int32 i = 0; i < m_polygonA.m_count; ++i) - { - v[i] = b2Mul(m_transformA, m_polygonA.m_vertices[i]); - } - m_debugDraw.DrawPolygon(v, m_polygonA.m_count, color); - - for (int32 i = 0; i < m_polygonB.m_count; ++i) - { - v[i] = b2Mul(m_transformB, m_polygonB.m_vertices[i]); - } - m_debugDraw.DrawPolygon(v, m_polygonB.m_count, color); - } - - for (int32 i = 0; i < manifold.pointCount; ++i) - { - m_debugDraw.DrawPoint(worldManifold.points[i], 4.0f, b2Color(0.9f, 0.3f, 0.3f)); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - m_positionB.x -= 0.1f; - break; - - case 'd': - m_positionB.x += 0.1f; - break; - - case 's': - m_positionB.y -= 0.1f; - break; - - case 'w': - m_positionB.y += 0.1f; - break; - - case 'q': - m_angleB += 0.1f * b2_pi; - break; - - case 'e': - m_angleB -= 0.1f * b2_pi; - break; - } - - m_transformB.Set(m_positionB, m_angleB); - } - - b2PolygonShape m_polygonA; - b2PolygonShape m_polygonB; - - b2Transform m_transformA; - b2Transform m_transformB; - - b2Vec2 m_positionB; - float32 m_angleB; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/PolyShapes.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/PolyShapes.h deleted file mode 100644 index 532071a58d..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/PolyShapes.h +++ /dev/null @@ -1,299 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef POLY_SHAPES_H -#define POLY_SHAPES_H - -/// This tests stacking. It also shows how to use b2World::Query -/// and b2TestOverlap. - -/// This callback is called by b2World::QueryAABB. We find all the fixtures -/// that overlap an AABB. Of those, we use b2TestOverlap to determine which fixtures -/// overlap a circle. Up to 4 overlapped fixtures will be highlighted with a yellow border. -class PolyShapesCallback : public b2QueryCallback -{ -public: - - enum - { - e_maxCount = 4 - }; - - PolyShapesCallback() - { - m_count = 0; - } - - void DrawFixture(b2Fixture* fixture) - { - b2Color color(0.95f, 0.95f, 0.6f); - const b2Transform& xf = fixture->GetBody()->GetTransform(); - - switch (fixture->GetType()) - { - case b2Shape::e_circle: - { - b2CircleShape* circle = (b2CircleShape*)fixture->GetShape(); - - b2Vec2 center = b2Mul(xf, circle->m_p); - float32 radius = circle->m_radius; - - m_debugDraw->DrawCircle(center, radius, color); - } - break; - - case b2Shape::e_polygon: - { - b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape(); - int32 vertexCount = poly->m_count; - b2Assert(vertexCount <= b2_maxPolygonVertices); - b2Vec2 vertices[b2_maxPolygonVertices]; - - for (int32 i = 0; i < vertexCount; ++i) - { - vertices[i] = b2Mul(xf, poly->m_vertices[i]); - } - - m_debugDraw->DrawPolygon(vertices, vertexCount, color); - } - break; - - default: - break; - } - } - - /// Called for each fixture found in the query AABB. - /// @return false to terminate the query. - bool ReportFixture(b2Fixture* fixture) - { - if (m_count == e_maxCount) - { - return false; - } - - b2Body* body = fixture->GetBody(); - b2Shape* shape = fixture->GetShape(); - - bool overlap = b2TestOverlap(shape, 0, &m_circle, 0, body->GetTransform(), m_transform); - - if (overlap) - { - DrawFixture(fixture); - ++m_count; - } - - return true; - } - - b2CircleShape m_circle; - b2Transform m_transform; - b2Draw* m_debugDraw; - int32 m_count; -}; - -class PolyShapes : public Test -{ -public: - - enum - { - e_maxBodies = 256 - }; - - PolyShapes() - { - // Ground body - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.5f, 0.0f); - vertices[1].Set(0.5f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - m_polygons[0].Set(vertices, 3); - } - - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.1f, 0.0f); - vertices[1].Set(0.1f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - m_polygons[1].Set(vertices, 3); - } - - { - float32 w = 1.0f; - float32 b = w / (2.0f + b2Sqrt(2.0f)); - float32 s = b2Sqrt(2.0f) * b; - - b2Vec2 vertices[8]; - vertices[0].Set(0.5f * s, 0.0f); - vertices[1].Set(0.5f * w, b); - vertices[2].Set(0.5f * w, b + s); - vertices[3].Set(0.5f * s, w); - vertices[4].Set(-0.5f * s, w); - vertices[5].Set(-0.5f * w, b + s); - vertices[6].Set(-0.5f * w, b); - vertices[7].Set(-0.5f * s, 0.0f); - - m_polygons[2].Set(vertices, 8); - } - - { - m_polygons[3].SetAsBox(0.5f, 0.5f); - } - - { - m_circle.m_radius = 0.5f; - } - - m_bodyIndex = 0; - memset(m_bodies, 0, sizeof(m_bodies)); - } - - void Create(int32 index) - { - if (m_bodies[m_bodyIndex] != NULL) - { - m_world->DestroyBody(m_bodies[m_bodyIndex]); - m_bodies[m_bodyIndex] = NULL; - } - - b2BodyDef bd; - bd.type = b2_dynamicBody; - - float32 x = RandomFloat(-2.0f, 2.0f); - bd.position.Set(x, 10.0f); - bd.angle = RandomFloat(-b2_pi, b2_pi); - - if (index == 4) - { - bd.angularDamping = 0.02f; - } - - m_bodies[m_bodyIndex] = m_world->CreateBody(&bd); - - if (index < 4) - { - b2FixtureDef fd; - fd.shape = m_polygons + index; - fd.density = 1.0f; - fd.friction = 0.3f; - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - else - { - b2FixtureDef fd; - fd.shape = &m_circle; - fd.density = 1.0f; - fd.friction = 0.3f; - - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - - m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies; - } - - void DestroyBody() - { - for (int32 i = 0; i < e_maxBodies; ++i) - { - if (m_bodies[i] != NULL) - { - m_world->DestroyBody(m_bodies[i]); - m_bodies[i] = NULL; - return; - } - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case '1': - case '2': - case '3': - case '4': - case '5': - Create(key - '1'); - break; - - case 'a': - for (int32 i = 0; i < e_maxBodies; i += 2) - { - if (m_bodies[i]) - { - bool active = m_bodies[i]->IsActive(); - m_bodies[i]->SetActive(!active); - } - } - break; - - case 'd': - DestroyBody(); - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - PolyShapesCallback callback; - callback.m_circle.m_radius = 2.0f; - callback.m_circle.m_p.Set(0.0f, 1.1f); - callback.m_transform.SetIdentity(); - callback.m_debugDraw = &m_debugDraw; - - b2AABB aabb; - callback.m_circle.ComputeAABB(&aabb, callback.m_transform, 0); - - m_world->QueryAABB(&callback, aabb); - - b2Color color(0.4f, 0.7f, 0.8f); - m_debugDraw.DrawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color); - - m_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff"); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "Press 'a' to (de)activate some bodies"); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "Press 'd' to destroy a body"); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new PolyShapes; - } - - int32 m_bodyIndex; - b2Body* m_bodies[e_maxBodies]; - b2PolygonShape m_polygons[4]; - b2CircleShape m_circle; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Prismatic.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Prismatic.h deleted file mode 100644 index 731745c64d..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Prismatic.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef PRISMATIC_H -#define PRISMATIC_H - -// The motor in this test gets smoother with higher velocity iterations. -class Prismatic : public Test -{ -public: - Prismatic() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(2.0f, 0.5f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-10.0f, 10.0f); - bd.angle = 0.5f * b2_pi; - bd.allowSleep = false; - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 5.0f); - - b2PrismaticJointDef pjd; - - // Bouncy limit - b2Vec2 axis(2.0f, 1.0f); - axis.Normalize(); - pjd.Initialize(ground, body, b2Vec2(0.0f, 0.0f), axis); - - // Non-bouncy limit - //pjd.Initialize(ground, body, b2Vec2(-10.0f, 10.0f), b2Vec2(1.0f, 0.0f)); - - pjd.motorSpeed = 10.0f; - pjd.maxMotorForce = 10000.0f; - pjd.enableMotor = true; - pjd.lowerTranslation = 0.0f; - pjd.upperTranslation = 20.0f; - pjd.enableLimit = true; - - m_joint = (b2PrismaticJoint*)m_world->CreateJoint(&pjd); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'l': - m_joint->EnableLimit(!m_joint->IsLimitEnabled()); - break; - - case 'm': - m_joint->EnableMotor(!m_joint->IsMotorEnabled()); - break; - - case 's': - m_joint->SetMotorSpeed(-m_joint->GetMotorSpeed()); - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Keys: (l) limits, (m) motors, (s) speed"); - m_textLine += DRAW_STRING_NEW_LINE; - float32 force = m_joint->GetMotorForce(settings->hz); - m_debugDraw.DrawString(5, m_textLine, "Motor Force = %4.0f", (float) force); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new Prismatic; - } - - b2PrismaticJoint* m_joint; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pulleys.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pulleys.h deleted file mode 100644 index ad5dd8ce39..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pulleys.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef PULLEYS_H -#define PULLEYS_H - -class Pulleys : public Test -{ -public: - Pulleys() - { - float32 y = 16.0f; - float32 L = 12.0f; - float32 a = 1.0f; - float32 b = 2.0f; - - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape edge; - edge.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - //ground->CreateFixture(&shape, 0.0f); - - b2CircleShape circle; - circle.m_radius = 2.0f; - - circle.m_p.Set(-10.0f, y + b + L); - ground->CreateFixture(&circle, 0.0f); - - circle.m_p.Set(10.0f, y + b + L); - ground->CreateFixture(&circle, 0.0f); - } - - { - - b2PolygonShape shape; - shape.SetAsBox(a, b); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - - //bd.fixedRotation = true; - bd.position.Set(-10.0f, y); - b2Body* body1 = m_world->CreateBody(&bd); - body1->CreateFixture(&shape, 5.0f); - - bd.position.Set(10.0f, y); - b2Body* body2 = m_world->CreateBody(&bd); - body2->CreateFixture(&shape, 5.0f); - - b2PulleyJointDef pulleyDef; - b2Vec2 anchor1(-10.0f, y + b); - b2Vec2 anchor2(10.0f, y + b); - b2Vec2 groundAnchor1(-10.0f, y + b + L); - b2Vec2 groundAnchor2(10.0f, y + b + L); - pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 1.5f); - - m_joint1 = (b2PulleyJoint*)m_world->CreateJoint(&pulleyDef); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 0: - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - float32 ratio = m_joint1->GetRatio(); - float32 L = m_joint1->GetCurrentLengthA() + ratio * m_joint1->GetCurrentLengthB(); - m_debugDraw.DrawString(5, m_textLine, "L1 + %4.2f * L2 = %4.2f", (float) ratio, (float) L); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new Pulleys; - } - - b2PulleyJoint* m_joint1; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pyramid.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pyramid.h deleted file mode 100644 index b52322ef01..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Pyramid.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef PYRAMID_H -#define PYRAMID_H - -class Pyramid : public Test -{ -public: - enum - { - e_count = 20 - }; - - Pyramid() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - float32 a = 0.5f; - b2PolygonShape shape; - shape.SetAsBox(a, a); - - b2Vec2 x(-7.0f, 0.75f); - b2Vec2 y; - b2Vec2 deltaX(0.5625f, 1.25f); - b2Vec2 deltaY(1.125f, 0.0f); - - for (int32 i = 0; i < e_count; ++i) - { - y = x; - - for (int32 j = i; j < e_count; ++j) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = y; - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 5.0f); - - y += deltaY; - } - - x += deltaX; - } - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; - - //if (m_stepCount == 400) - //{ - // tree->RebuildBottomUp(); - //} - } - - static Test* Create() - { - return new Pyramid; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/RayCast.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/RayCast.h deleted file mode 100644 index 89d0bd06e2..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/RayCast.h +++ /dev/null @@ -1,481 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef RAY_CAST_H -#define RAY_CAST_H - -// This test demonstrates how to use the world ray-cast feature. -// NOTE: we are intentionally filtering one of the polygons, therefore -// the ray will always miss one type of polygon. - -// This callback finds the closest hit. Polygon 0 is filtered. -class RayCastClosestCallback : public b2RayCastCallback -{ -public: - RayCastClosestCallback() - { - m_hit = false; - } - - float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) - { - b2Body* body = fixture->GetBody(); - void* userData = body->GetUserData(); - if (userData) - { - int32 index = *(int32*)userData; - if (index == 0) - { - // By returning -1, we instruct the calling code to ignore this fixture and - // continue the ray-cast to the next fixture. - return -1.0f; - } - } - - m_hit = true; - m_point = point; - m_normal = normal; - - // By returning the current fraction, we instruct the calling code to clip the ray and - // continue the ray-cast to the next fixture. WARNING: do not assume that fixtures - // are reported in order. However, by clipping, we can always get the closest fixture. - return fraction; - } - - bool m_hit; - b2Vec2 m_point; - b2Vec2 m_normal; -}; - -// This callback finds any hit. Polygon 0 is filtered. For this type of query we are usually -// just checking for obstruction, so the actual fixture and hit point are irrelevant. -class RayCastAnyCallback : public b2RayCastCallback -{ -public: - RayCastAnyCallback() - { - m_hit = false; - } - - float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) - { - b2Body* body = fixture->GetBody(); - void* userData = body->GetUserData(); - if (userData) - { - int32 index = *(int32*)userData; - if (index == 0) - { - // By returning -1, we instruct the calling code to ignore this fixture - // and continue the ray-cast to the next fixture. - return -1.0f; - } - } - - m_hit = true; - m_point = point; - m_normal = normal; - - // At this point we have a hit, so we know the ray is obstructed. - // By returning 0, we instruct the calling code to terminate the ray-cast. - return 0.0f; - } - - bool m_hit; - b2Vec2 m_point; - b2Vec2 m_normal; -}; - -// This ray cast collects multiple hits along the ray. Polygon 0 is filtered. -// The fixtures are not necessary reported in order, so we might not capture -// the closest fixture. -class RayCastMultipleCallback : public b2RayCastCallback -{ -public: - enum - { - e_maxCount = 3 - }; - - RayCastMultipleCallback() - { - m_count = 0; - } - - float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) - { - b2Body* body = fixture->GetBody(); - void* userData = body->GetUserData(); - if (userData) - { - int32 index = *(int32*)userData; - if (index == 0) - { - // By returning -1, we instruct the calling code to ignore this fixture - // and continue the ray-cast to the next fixture. - return -1.0f; - } - } - - b2Assert(m_count < e_maxCount); - - m_points[m_count] = point; - m_normals[m_count] = normal; - ++m_count; - - if (m_count == e_maxCount) - { - // At this point the buffer is full. - // By returning 0, we instruct the calling code to terminate the ray-cast. - return 0.0f; - } - - // By returning 1, we instruct the caller to continue without clipping the ray. - return 1.0f; - } - - b2Vec2 m_points[e_maxCount]; - b2Vec2 m_normals[e_maxCount]; - int32 m_count; -}; - - -class RayCast : public Test -{ -public: - - enum - { - e_maxBodies = 256 - }; - - enum Mode - { - e_closest, - e_any, - e_multiple - }; - - RayCast() - { - // Ground body - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.5f, 0.0f); - vertices[1].Set(0.5f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - m_polygons[0].Set(vertices, 3); - } - - { - b2Vec2 vertices[3]; - vertices[0].Set(-0.1f, 0.0f); - vertices[1].Set(0.1f, 0.0f); - vertices[2].Set(0.0f, 1.5f); - m_polygons[1].Set(vertices, 3); - } - - { - float32 w = 1.0f; - float32 b = w / (2.0f + b2Sqrt(2.0f)); - float32 s = b2Sqrt(2.0f) * b; - - b2Vec2 vertices[8]; - vertices[0].Set(0.5f * s, 0.0f); - vertices[1].Set(0.5f * w, b); - vertices[2].Set(0.5f * w, b + s); - vertices[3].Set(0.5f * s, w); - vertices[4].Set(-0.5f * s, w); - vertices[5].Set(-0.5f * w, b + s); - vertices[6].Set(-0.5f * w, b); - vertices[7].Set(-0.5f * s, 0.0f); - - m_polygons[2].Set(vertices, 8); - } - - { - m_polygons[3].SetAsBox(0.5f, 0.5f); - } - - { - m_circle.m_radius = 0.5f; - } - - { - m_edge.Set(b2Vec2(-1.0f, 0.0f), b2Vec2(1.0f, 0.0f)); - } - - m_bodyIndex = 0; - memset(m_bodies, 0, sizeof(m_bodies)); - - m_angle = 0.0f; - - m_mode = e_closest; - } - - void Create(int32 index) - { - if (m_bodies[m_bodyIndex] != NULL) - { - m_world->DestroyBody(m_bodies[m_bodyIndex]); - m_bodies[m_bodyIndex] = NULL; - } - - b2BodyDef bd; - - float32 x = RandomFloat(-10.0f, 10.0f); - float32 y = RandomFloat(0.0f, 20.0f); - bd.position.Set(x, y); - bd.angle = RandomFloat(-b2_pi, b2_pi); - - m_userData[m_bodyIndex] = index; - bd.userData = m_userData + m_bodyIndex; - - if (index == 4) - { - bd.angularDamping = 0.02f; - } - - m_bodies[m_bodyIndex] = m_world->CreateBody(&bd); - - if (index < 4) - { - b2FixtureDef fd; - fd.shape = m_polygons + index; - fd.friction = 0.3f; - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - else if (index < 5) - { - b2FixtureDef fd; - fd.shape = &m_circle; - fd.friction = 0.3f; - - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - else - { - b2FixtureDef fd; - fd.shape = &m_edge; - fd.friction = 0.3f; - - m_bodies[m_bodyIndex]->CreateFixture(&fd); - } - - m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies; - } - - void DestroyBody() - { - for (int32 i = 0; i < e_maxBodies; ++i) - { - if (m_bodies[i] != NULL) - { - m_world->DestroyBody(m_bodies[i]); - m_bodies[i] = NULL; - return; - } - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - Create(key - '1'); - break; - - case 'd': - DestroyBody(); - break; - - case 'm': - if (m_mode == e_closest) - { - m_mode = e_any; - } - else if (m_mode == e_any) - { - m_mode = e_multiple; - } - else if (m_mode == e_multiple) - { - m_mode = e_closest; - } - } - } - - void Step(Settings* settings) - { - bool advanceRay = settings->pause == 0 || settings->singleStep; - - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Press 1-6 to drop stuff, m to change the mode"); - m_textLine += DRAW_STRING_NEW_LINE; - switch (m_mode) - { - case e_closest: - m_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: closest - find closest fixture along the ray"); - break; - - case e_any: - m_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: any - check for obstruction"); - break; - - case e_multiple: - m_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: multiple - gather multiple fixtures"); - break; - } - - m_textLine += DRAW_STRING_NEW_LINE; - - float32 L = 11.0f; - b2Vec2 point1(0.0f, 10.0f); - b2Vec2 d(L * cosf(m_angle), L * sinf(m_angle)); - b2Vec2 point2 = point1 + d; - - if (m_mode == e_closest) - { - RayCastClosestCallback callback; - m_world->RayCast(&callback, point1, point2); - - if (callback.m_hit) - { - m_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f)); - m_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f)); - b2Vec2 head = callback.m_point + 0.5f * callback.m_normal; - m_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f)); - } - else - { - m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f)); - } - } - else if (m_mode == e_any) - { - RayCastAnyCallback callback; - m_world->RayCast(&callback, point1, point2); - - if (callback.m_hit) - { - m_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f)); - m_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f)); - b2Vec2 head = callback.m_point + 0.5f * callback.m_normal; - m_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f)); - } - else - { - m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f)); - } - } - else if (m_mode == e_multiple) - { - RayCastMultipleCallback callback; - m_world->RayCast(&callback, point1, point2); - m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f)); - - for (int32 i = 0; i < callback.m_count; ++i) - { - b2Vec2 p = callback.m_points[i]; - b2Vec2 n = callback.m_normals[i]; - m_debugDraw.DrawPoint(p, 5.0f, b2Color(0.4f, 0.9f, 0.4f)); - m_debugDraw.DrawSegment(point1, p, b2Color(0.8f, 0.8f, 0.8f)); - b2Vec2 head = p + 0.5f * n; - m_debugDraw.DrawSegment(p, head, b2Color(0.9f, 0.9f, 0.4f)); - } - } - - if (advanceRay) - { - m_angle += 0.25f * b2_pi / 180.0f; - } - -#if 0 - // This case was failing. - { - b2Vec2 vertices[4]; - //vertices[0].Set(-22.875f, -3.0f); - //vertices[1].Set(22.875f, -3.0f); - //vertices[2].Set(22.875f, 3.0f); - //vertices[3].Set(-22.875f, 3.0f); - - b2PolygonShape shape; - //shape.Set(vertices, 4); - shape.SetAsBox(22.875f, 3.0f); - - b2RayCastInput input; - input.p1.Set(10.2725f,1.71372f); - input.p2.Set(10.2353f,2.21807f); - //input.maxFraction = 0.567623f; - input.maxFraction = 0.56762173f; - - b2Transform xf; - xf.SetIdentity(); - xf.position.Set(23.0f, 5.0f); - - b2RayCastOutput output; - bool hit; - hit = shape.RayCast(&output, input, xf); - hit = false; - - b2Color color(1.0f, 1.0f, 1.0f); - b2Vec2 vs[4]; - for (int32 i = 0; i < 4; ++i) - { - vs[i] = b2Mul(xf, shape.m_vertices[i]); - } - - m_debugDraw.DrawPolygon(vs, 4, color); - m_debugDraw.DrawSegment(input.p1, input.p2, color); - } -#endif - } - - static Test* Create() - { - return new RayCast; - } - - int32 m_bodyIndex; - b2Body* m_bodies[e_maxBodies]; - int32 m_userData[e_maxBodies]; - b2PolygonShape m_polygons[4]; - b2CircleShape m_circle; - b2EdgeShape m_edge; - - float32 m_angle; - - Mode m_mode; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Revolute.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Revolute.h deleted file mode 100644 index 6501eb6cba..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Revolute.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef REVOLUTE_H -#define REVOLUTE_H - -class Revolute : public Test -{ -public: - Revolute() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - - b2FixtureDef fd; - fd.shape = &shape; - //fd.filter.categoryBits = 2; - - ground->CreateFixture(&fd); - } - - { - b2CircleShape shape; - shape.m_radius = 0.5f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - - b2RevoluteJointDef rjd; - - bd.position.Set(-10.0f, 20.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 5.0f); - - float32 w = 100.0f; - body->SetAngularVelocity(w); - body->SetLinearVelocity(b2Vec2(-8.0f * w, 0.0f)); - - rjd.Initialize(ground, body, b2Vec2(-10.0f, 12.0f)); - rjd.motorSpeed = 1.0f * b2_pi; - rjd.maxMotorTorque = 10000.0f; - rjd.enableMotor = false; - rjd.lowerAngle = -0.25f * b2_pi; - rjd.upperAngle = 0.5f * b2_pi; - rjd.enableLimit = true; - rjd.collideConnected = true; - - m_joint = (b2RevoluteJoint*)m_world->CreateJoint(&rjd); - } - - { - b2CircleShape circle_shape; - circle_shape.m_radius = 3.0f; - - b2BodyDef circle_bd; - circle_bd.type = b2_dynamicBody; - circle_bd.position.Set(5.0f, 30.0f); - - b2FixtureDef fd; - fd.density = 5.0f; - fd.filter.maskBits = 1; - fd.shape = &circle_shape; - - m_ball = m_world->CreateBody(&circle_bd); - m_ball->CreateFixture(&fd); - - b2PolygonShape polygon_shape; - polygon_shape.SetAsBox(10.0f, 0.2f, b2Vec2 (-10.0f, 0.0f), 0.0f); - - b2BodyDef polygon_bd; - polygon_bd.position.Set(20.0f, 10.0f); - polygon_bd.type = b2_dynamicBody; - polygon_bd.bullet = true; - b2Body* polygon_body = m_world->CreateBody(&polygon_bd); - polygon_body->CreateFixture(&polygon_shape, 2.0f); - - b2RevoluteJointDef rjd; - rjd.Initialize(ground, polygon_body, b2Vec2(20.0f, 10.0f)); - rjd.lowerAngle = -0.25f * b2_pi; - rjd.upperAngle = 0.0f * b2_pi; - rjd.enableLimit = true; - m_world->CreateJoint(&rjd); - } - - // Tests mass computation of a small object far from the origin - { - b2BodyDef bodyDef; - bodyDef.type = b2_dynamicBody; - b2Body* body = m_world->CreateBody(&bodyDef); - - b2PolygonShape polyShape; - b2Vec2 verts[3]; - verts[0].Set( 17.63f, 36.31f ); - verts[1].Set( 17.52f, 36.69f ); - verts[2].Set( 17.19f, 36.36f ); - polyShape.Set(verts, 3); - - b2FixtureDef polyFixtureDef; - polyFixtureDef.shape = &polyShape; - polyFixtureDef.density = 1; - - body->CreateFixture(&polyFixtureDef); //assertion hits inside here - } - - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'l': - m_joint->EnableLimit(!m_joint->IsLimitEnabled()); - break; - - case 'm': - m_joint->EnableMotor(!m_joint->IsMotorEnabled()); - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Keys: (l) limits, (m) motor"); - m_textLine += DRAW_STRING_NEW_LINE; - - //if (m_stepCount == 360) - //{ - // m_ball->SetTransform(b2Vec2(0.0f, 0.5f), 0.0f); - //} - - //float32 torque1 = m_joint1->GetMotorTorque(); - //m_debugDraw.DrawString(5, m_textLine, "Motor Torque = %4.0f, %4.0f : Motor Force = %4.0f", (float) torque1, (float) torque2, (float) force3); - //m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new Revolute; - } - - b2Body* m_ball; - b2RevoluteJoint* m_joint; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Rope.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Rope.h deleted file mode 100644 index b479134e94..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Rope.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef ROPE_H -#define ROPE_H - -/// -class Rope : public Test -{ -public: - Rope() - { - const int32 N = 40; - b2Vec2 vertices[N]; - float32 masses[N]; - - for (int32 i = 0; i < N; ++i) - { - vertices[i].Set(0.0f, 20.0f - 0.25f * i); - masses[i] = 1.0f; - } - masses[0] = 0.0f; - masses[1] = 0.0f; - - b2RopeDef def; - def.vertices = vertices; - def.count = N; - def.gravity.Set(0.0f, -10.0f); - def.masses = masses; - def.damping = 0.1f; - def.k2 = 1.0f; - def.k3 = 0.5f; - - m_rope.Initialize(&def); - - m_angle = 0.0f; - m_rope.SetAngle(m_angle); - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'q': - m_angle = b2Max(-b2_pi, m_angle - 0.05f * b2_pi); - m_rope.SetAngle(m_angle); - break; - - case 'e': - m_angle = b2Min(b2_pi, m_angle + 0.05f * b2_pi); - m_rope.SetAngle(m_angle); - break; - } - } - - void Step(Settings* settings) - { - float32 dt = settings->hz > 0.0f ? 1.0f / settings->hz : 0.0f; - - if (settings->pause == 1 && settings->singleStep == 0) - { - dt = 0.0f; - } - - m_rope.Step(dt, 1); - - Test::Step(settings); - - m_rope.Draw(&m_debugDraw); - - m_debugDraw.DrawString(5, m_textLine, "Press (q,e) to adjust target angle"); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "Target angle = %g degrees", m_angle * 180.0f / b2_pi); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new Rope; - } - - b2Rope m_rope; - float32 m_angle; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/RopeJoint.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/RopeJoint.h deleted file mode 100644 index a8b935201a..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/RopeJoint.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef ROPE_JOINT_H -#define ROPE_JOINT_H - -/// This test shows how a rope joint can be used to stabilize a chain of -/// bodies with a heavy payload. Notice that the rope joint just prevents -/// excessive stretching and has no other effect. -/// By disabling the rope joint you can see that the Box2D solver has trouble -/// supporting heavy bodies with light bodies. Try playing around with the -/// densities, time step, and iterations to see how they affect stability. -/// This test also shows how to use contact filtering. Filtering is configured -/// so that the payload does not collide with the chain. -class RopeJoint : public Test -{ -public: - RopeJoint() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.125f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - fd.friction = 0.2f; - fd.filter.categoryBits = 0x0001; - fd.filter.maskBits = 0xFFFF & ~0x0002; - - b2RevoluteJointDef jd; - jd.collideConnected = false; - - const int32 N = 10; - const float32 y = 15.0f; - m_ropeDef.localAnchorA.Set(0.0f, y); - - b2Body* prevBody = ground; - for (int32 i = 0; i < N; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.5f + 1.0f * i, y); - if (i == N - 1) - { - shape.SetAsBox(1.5f, 1.5f); - fd.density = 100.0f; - fd.filter.categoryBits = 0x0002; - bd.position.Set(1.0f * i, y); - bd.angularDamping = 0.4f; - } - - b2Body* body = m_world->CreateBody(&bd); - - body->CreateFixture(&fd); - - b2Vec2 anchor(float32(i), y); - jd.Initialize(prevBody, body, anchor); - m_world->CreateJoint(&jd); - - prevBody = body; - } - - m_ropeDef.localAnchorB.SetZero(); - - float32 extraLength = 0.01f; - m_ropeDef.maxLength = N - 1.0f + extraLength; - m_ropeDef.bodyB = prevBody; - } - - { - m_ropeDef.bodyA = ground; - m_rope = m_world->CreateJoint(&m_ropeDef); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'j': - if (m_rope) - { - m_world->DestroyJoint(m_rope); - m_rope = NULL; - } - else - { - m_rope = m_world->CreateJoint(&m_ropeDef); - } - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Press (j) to toggle the rope joint."); - m_textLine += DRAW_STRING_NEW_LINE; - if (m_rope) - { - m_debugDraw.DrawString(5, m_textLine, "Rope ON"); - } - else - { - m_debugDraw.DrawString(5, m_textLine, "Rope OFF"); - } - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new RopeJoint; - } - - b2RopeJointDef m_ropeDef; - b2Joint* m_rope; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/SensorTest.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/SensorTest.h deleted file mode 100644 index f15cd7714e..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/SensorTest.h +++ /dev/null @@ -1,181 +0,0 @@ -/* -* Copyright (c) 2008-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SENSOR_TEST_H -#define SENSOR_TEST_H - -// This is used to test sensor shapes. -class SensorTest : public Test -{ -public: - - enum - { - e_count = 7 - }; - - SensorTest() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - { - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - -#if 0 - { - b2FixtureDef sd; - sd.SetAsBox(10.0f, 2.0f, b2Vec2(0.0f, 20.0f), 0.0f); - sd.isSensor = true; - m_sensor = ground->CreateFixture(&sd); - } -#else - { - b2CircleShape shape; - shape.m_radius = 5.0f; - shape.m_p.Set(0.0f, 10.0f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.isSensor = true; - m_sensor = ground->CreateFixture(&fd); - } -#endif - } - - { - b2CircleShape shape; - shape.m_radius = 1.0f; - - for (int32 i = 0; i < e_count; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-10.0f + 3.0f * i, 20.0f); - bd.userData = m_touching + i; - - m_touching[i] = false; - m_bodies[i] = m_world->CreateBody(&bd); - - m_bodies[i]->CreateFixture(&shape, 1.0f); - } - } - } - - // Implement contact listener. - void BeginContact(b2Contact* contact) - { - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - if (fixtureA == m_sensor) - { - void* userData = fixtureB->GetBody()->GetUserData(); - if (userData) - { - bool* touching = (bool*)userData; - *touching = true; - } - } - - if (fixtureB == m_sensor) - { - void* userData = fixtureA->GetBody()->GetUserData(); - if (userData) - { - bool* touching = (bool*)userData; - *touching = true; - } - } - } - - // Implement contact listener. - void EndContact(b2Contact* contact) - { - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - if (fixtureA == m_sensor) - { - void* userData = fixtureB->GetBody()->GetUserData(); - if (userData) - { - bool* touching = (bool*)userData; - *touching = false; - } - } - - if (fixtureB == m_sensor) - { - void* userData = fixtureA->GetBody()->GetUserData(); - if (userData) - { - bool* touching = (bool*)userData; - *touching = false; - } - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - // Traverse the contact results. Apply a force on shapes - // that overlap the sensor. - for (int32 i = 0; i < e_count; ++i) - { - if (m_touching[i] == false) - { - continue; - } - - b2Body* body = m_bodies[i]; - b2Body* ground = m_sensor->GetBody(); - - b2CircleShape* circle = (b2CircleShape*)m_sensor->GetShape(); - b2Vec2 center = ground->GetWorldPoint(circle->m_p); - - b2Vec2 position = body->GetPosition(); - - b2Vec2 d = center - position; - if (d.LengthSquared() < FLT_EPSILON * FLT_EPSILON) - { - continue; - } - - d.Normalize(); - b2Vec2 F = 100.0f * d; - body->ApplyForce(F, position, false); - } - } - - static Test* Create() - { - return new SensorTest; - } - - b2Fixture* m_sensor; - b2Body* m_bodies[e_count]; - bool m_touching[e_count]; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ShapeEditing.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/ShapeEditing.h deleted file mode 100644 index 5cea181793..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/ShapeEditing.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2008-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SHAPE_EDITING_H -#define SHAPE_EDITING_H - -class ShapeEditing : public Test -{ -public: - - ShapeEditing() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 10.0f); - m_body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(4.0f, 4.0f, b2Vec2(0.0f, 0.0f), 0.0f); - m_fixture1 = m_body->CreateFixture(&shape, 10.0f); - - m_fixture2 = NULL; - - m_sensor = false; - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'c': - if (m_fixture2 == NULL) - { - b2CircleShape shape; - shape.m_radius = 3.0f; - shape.m_p.Set(0.5f, -4.0f); - m_fixture2 = m_body->CreateFixture(&shape, 10.0f); - m_body->SetAwake(true); - } - break; - - case 'd': - if (m_fixture2 != NULL) - { - m_body->DestroyFixture(m_fixture2); - m_fixture2 = NULL; - m_body->SetAwake(true); - } - break; - - case 's': - if (m_fixture2 != NULL) - { - m_sensor = !m_sensor; - m_fixture2->SetSensor(m_sensor); - } - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape."); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "sensor = %d", m_sensor); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new ShapeEditing; - } - - b2Body* m_body; - b2Fixture* m_fixture1; - b2Fixture* m_fixture2; - bool m_sensor; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/SliderCrank.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/SliderCrank.h deleted file mode 100644 index 7d914d7eed..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/SliderCrank.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SLIDER_CRANK_H -#define SLIDER_CRANK_H - -// A motor driven slider crank with joint friction. - -class SliderCrank : public Test -{ -public: - SliderCrank() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2Body* prevBody = ground; - - // Define crank. - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 2.0f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 7.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 2.0f); - - b2RevoluteJointDef rjd; - rjd.Initialize(prevBody, body, b2Vec2(0.0f, 5.0f)); - rjd.motorSpeed = 1.0f * b2_pi; - rjd.maxMotorTorque = 10000.0f; - rjd.enableMotor = true; - m_joint1 = (b2RevoluteJoint*)m_world->CreateJoint(&rjd); - - prevBody = body; - } - - // Define follower. - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 4.0f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 13.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 2.0f); - - b2RevoluteJointDef rjd; - rjd.Initialize(prevBody, body, b2Vec2(0.0f, 9.0f)); - rjd.enableMotor = false; - m_world->CreateJoint(&rjd); - - prevBody = body; - } - - // Define piston - { - b2PolygonShape shape; - shape.SetAsBox(1.5f, 1.5f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.fixedRotation = true; - bd.position.Set(0.0f, 17.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 2.0f); - - b2RevoluteJointDef rjd; - rjd.Initialize(prevBody, body, b2Vec2(0.0f, 17.0f)); - m_world->CreateJoint(&rjd); - - b2PrismaticJointDef pjd; - pjd.Initialize(ground, body, b2Vec2(0.0f, 17.0f), b2Vec2(0.0f, 1.0f)); - - pjd.maxMotorForce = 1000.0f; - pjd.enableMotor = true; - - m_joint2 = (b2PrismaticJoint*)m_world->CreateJoint(&pjd); - } - - // Create a payload - { - b2PolygonShape shape; - shape.SetAsBox(1.5f, 1.5f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 23.0f); - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 2.0f); - } - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'f': - m_joint2->EnableMotor(!m_joint2->IsMotorEnabled()); - m_joint2->GetBodyB()->SetAwake(true); - break; - - case 'm': - m_joint1->EnableMotor(!m_joint1->IsMotorEnabled()); - m_joint1->GetBodyB()->SetAwake(true); - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Keys: (f) toggle friction, (m) toggle motor"); - m_textLine += DRAW_STRING_NEW_LINE; - float32 torque = m_joint1->GetMotorTorque(settings->hz); - m_debugDraw.DrawString(5, m_textLine, "Motor Torque = %5.0f", (float) torque); - m_textLine += DRAW_STRING_NEW_LINE; - } - - static Test* Create() - { - return new SliderCrank; - } - - b2RevoluteJoint* m_joint1; - b2PrismaticJoint* m_joint2; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/SphereStack.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/SphereStack.h deleted file mode 100644 index 2948cbfd48..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/SphereStack.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPHERE_STACK_H -#define SPHERE_STACK_H - -class SphereStack : public Test -{ -public: - - enum - { - e_count = 10 - }; - - SphereStack() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2CircleShape shape; - shape.m_radius = 1.0f; - - for (int32 i = 0; i < e_count; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0, 4.0f + 3.0f * i); - - m_bodies[i] = m_world->CreateBody(&bd); - - m_bodies[i]->CreateFixture(&shape, 1.0f); - - m_bodies[i]->SetLinearVelocity(b2Vec2(0.0f, -50.0f)); - } - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - - //for (int32 i = 0; i < e_count; ++i) - //{ - // printf("%g ", m_bodies[i]->GetWorldCenter().y); - //} - - //for (int32 i = 0; i < e_count; ++i) - //{ - // printf("%g ", m_bodies[i]->GetLinearVelocity().y); - //} - - //printf("\n"); - } - - static Test* Create() - { - return new SphereStack; - } - - b2Body* m_bodies[e_count]; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/TheoJansen.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/TheoJansen.h deleted file mode 100644 index f884d68176..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/TheoJansen.h +++ /dev/null @@ -1,256 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -// Inspired by a contribution by roman_m -// Dimensions scooped from APE (http://www.cove.org/ape/index.htm) - -#ifndef THEO_JANSEN_H -#define THEO_JANSEN_H - -class TheoJansen : public Test -{ -public: - - void CreateLeg(float32 s, const b2Vec2& wheelAnchor) - { - b2Vec2 p1(5.4f * s, -6.1f); - b2Vec2 p2(7.2f * s, -1.2f); - b2Vec2 p3(4.3f * s, -1.9f); - b2Vec2 p4(3.1f * s, 0.8f); - b2Vec2 p5(6.0f * s, 1.5f); - b2Vec2 p6(2.5f * s, 3.7f); - - b2FixtureDef fd1, fd2; - fd1.filter.groupIndex = -1; - fd2.filter.groupIndex = -1; - fd1.density = 1.0f; - fd2.density = 1.0f; - - b2PolygonShape poly1, poly2; - - if (s > 0.0f) - { - b2Vec2 vertices[3]; - - vertices[0] = p1; - vertices[1] = p2; - vertices[2] = p3; - poly1.Set(vertices, 3); - - vertices[0] = b2Vec2_zero; - vertices[1] = p5 - p4; - vertices[2] = p6 - p4; - poly2.Set(vertices, 3); - } - else - { - b2Vec2 vertices[3]; - - vertices[0] = p1; - vertices[1] = p3; - vertices[2] = p2; - poly1.Set(vertices, 3); - - vertices[0] = b2Vec2_zero; - vertices[1] = p6 - p4; - vertices[2] = p5 - p4; - poly2.Set(vertices, 3); - } - - fd1.shape = &poly1; - fd2.shape = &poly2; - - b2BodyDef bd1, bd2; - bd1.type = b2_dynamicBody; - bd2.type = b2_dynamicBody; - bd1.position = m_offset; - bd2.position = p4 + m_offset; - - bd1.angularDamping = 10.0f; - bd2.angularDamping = 10.0f; - - b2Body* body1 = m_world->CreateBody(&bd1); - b2Body* body2 = m_world->CreateBody(&bd2); - - body1->CreateFixture(&fd1); - body2->CreateFixture(&fd2); - - b2DistanceJointDef djd; - - // Using a soft distance constraint can reduce some jitter. - // It also makes the structure seem a bit more fluid by - // acting like a suspension system. - djd.dampingRatio = 0.5f; - djd.frequencyHz = 10.0f; - - djd.Initialize(body1, body2, p2 + m_offset, p5 + m_offset); - m_world->CreateJoint(&djd); - - djd.Initialize(body1, body2, p3 + m_offset, p4 + m_offset); - m_world->CreateJoint(&djd); - - djd.Initialize(body1, m_wheel, p3 + m_offset, wheelAnchor + m_offset); - m_world->CreateJoint(&djd); - - djd.Initialize(body2, m_wheel, p6 + m_offset, wheelAnchor + m_offset); - m_world->CreateJoint(&djd); - - b2RevoluteJointDef rjd; - - rjd.Initialize(body2, m_chassis, p4 + m_offset); - m_world->CreateJoint(&rjd); - } - - TheoJansen() - { - m_offset.Set(0.0f, 8.0f); - m_motorSpeed = 2.0f; - m_motorOn = true; - b2Vec2 pivot(0.0f, 0.8f); - - // Ground - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-50.0f, 0.0f), b2Vec2(50.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - - shape.Set(b2Vec2(-50.0f, 0.0f), b2Vec2(-50.0f, 10.0f)); - ground->CreateFixture(&shape, 0.0f); - - shape.Set(b2Vec2(50.0f, 0.0f), b2Vec2(50.0f, 10.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - // Balls - for (int32 i = 0; i < 40; ++i) - { - b2CircleShape shape; - shape.m_radius = 0.25f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-40.0f + 2.0f * i, 0.5f); - - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 1.0f); - } - - // Chassis - { - b2PolygonShape shape; - shape.SetAsBox(2.5f, 1.0f); - - b2FixtureDef sd; - sd.density = 1.0f; - sd.shape = &shape; - sd.filter.groupIndex = -1; - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = pivot + m_offset; - m_chassis = m_world->CreateBody(&bd); - m_chassis->CreateFixture(&sd); - } - - { - b2CircleShape shape; - shape.m_radius = 1.6f; - - b2FixtureDef sd; - sd.density = 1.0f; - sd.shape = &shape; - sd.filter.groupIndex = -1; - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = pivot + m_offset; - m_wheel = m_world->CreateBody(&bd); - m_wheel->CreateFixture(&sd); - } - - { - b2RevoluteJointDef jd; - jd.Initialize(m_wheel, m_chassis, pivot + m_offset); - jd.collideConnected = false; - jd.motorSpeed = m_motorSpeed; - jd.maxMotorTorque = 400.0f; - jd.enableMotor = m_motorOn; - m_motorJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd); - } - - b2Vec2 wheelAnchor; - - wheelAnchor = pivot + b2Vec2(0.0f, -0.8f); - - CreateLeg(-1.0f, wheelAnchor); - CreateLeg(1.0f, wheelAnchor); - - m_wheel->SetTransform(m_wheel->GetPosition(), 120.0f * b2_pi / 180.0f); - CreateLeg(-1.0f, wheelAnchor); - CreateLeg(1.0f, wheelAnchor); - - m_wheel->SetTransform(m_wheel->GetPosition(), -120.0f * b2_pi / 180.0f); - CreateLeg(-1.0f, wheelAnchor); - CreateLeg(1.0f, wheelAnchor); - } - - void Step(Settings* settings) - { - m_debugDraw.DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, toggle motor = m"); - m_textLine += DRAW_STRING_NEW_LINE; - - Test::Step(settings); - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'a': - m_motorJoint->SetMotorSpeed(-m_motorSpeed); - break; - - case 's': - m_motorJoint->SetMotorSpeed(0.0f); - break; - - case 'd': - m_motorJoint->SetMotorSpeed(m_motorSpeed); - break; - - case 'm': - m_motorJoint->EnableMotor(!m_motorJoint->IsMotorEnabled()); - break; - } - } - - static Test* Create() - { - return new TheoJansen; - } - - b2Vec2 m_offset; - b2Body* m_chassis; - b2Body* m_wheel; - b2RevoluteJoint* m_motorJoint; - bool m_motorOn; - float32 m_motorSpeed; -}; - -#endif // THEO_JANSEN_H diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Tiles.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Tiles.h deleted file mode 100644 index 9d675d2c88..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Tiles.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TILES_H -#define TILES_H - -/// This stress tests the dynamic tree broad-phase. This also shows that tile -/// based collision is _not_ smooth due to Box2D not knowing about adjacency. -class Tiles : public Test -{ -public: - enum - { - e_count = 20 - }; - - Tiles() - { - m_fixtureCount = 0; - b2Timer timer; - - { - float32 a = 0.5f; - b2BodyDef bd; - bd.position.y = -a; - b2Body* ground = m_world->CreateBody(&bd); - -#if 1 - int32 N = 200; - int32 M = 10; - b2Vec2 position; - position.y = 0.0f; - for (int32 j = 0; j < M; ++j) - { - position.x = -N * a; - for (int32 i = 0; i < N; ++i) - { - b2PolygonShape shape; - shape.SetAsBox(a, a, position, 0.0f); - ground->CreateFixture(&shape, 0.0f); - ++m_fixtureCount; - position.x += 2.0f * a; - } - position.y -= 2.0f * a; - } -#else - int32 N = 200; - int32 M = 10; - b2Vec2 position; - position.x = -N * a; - for (int32 i = 0; i < N; ++i) - { - position.y = 0.0f; - for (int32 j = 0; j < M; ++j) - { - b2PolygonShape shape; - shape.SetAsBox(a, a, position, 0.0f); - ground->CreateFixture(&shape, 0.0f); - position.y -= 2.0f * a; - } - position.x += 2.0f * a; - } -#endif - } - - { - float32 a = 0.5f; - b2PolygonShape shape; - shape.SetAsBox(a, a); - - b2Vec2 x(-7.0f, 0.75f); - b2Vec2 y; - b2Vec2 deltaX(0.5625f, 1.25f); - b2Vec2 deltaY(1.125f, 0.0f); - - for (int32 i = 0; i < e_count; ++i) - { - y = x; - - for (int32 j = i; j < e_count; ++j) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = y; - - //if (i == 0 && j == 0) - //{ - // bd.allowSleep = false; - //} - //else - //{ - // bd.allowSleep = true; - //} - - b2Body* body = m_world->CreateBody(&bd); - body->CreateFixture(&shape, 5.0f); - ++m_fixtureCount; - y += deltaY; - } - - x += deltaX; - } - } - - m_createTime = timer.GetMilliseconds(); - } - - void Step(Settings* settings) - { - const b2ContactManager& cm = m_world->GetContactManager(); - int32 height = cm.m_broadPhase.GetTreeHeight(); - int32 leafCount = cm.m_broadPhase.GetProxyCount(); - int32 minimumNodeCount = 2 * leafCount - 1; - float32 minimumHeight = ceilf(logf(float32(minimumNodeCount)) / logf(2.0f)); - m_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d, min = %d", height, int32(minimumHeight)); - m_textLine += DRAW_STRING_NEW_LINE; - - Test::Step(settings); - - m_debugDraw.DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d", - m_createTime, m_fixtureCount); - m_textLine += DRAW_STRING_NEW_LINE; - - //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; - - //if (m_stepCount == 400) - //{ - // tree->RebuildBottomUp(); - //} - } - - static Test* Create() - { - return new Tiles; - } - - int32 m_fixtureCount; - float32 m_createTime; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/TimeOfImpact.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/TimeOfImpact.h deleted file mode 100644 index 3d72eeda7b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/TimeOfImpact.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TIME_OF_IMPACT_H -#define TIME_OF_IMPACT_H - -class TimeOfImpact : public Test -{ -public: - TimeOfImpact() - { - m_shapeA.SetAsBox(25.0f, 5.0f); - m_shapeB.SetAsBox(2.5f, 2.5f); - } - - static Test* Create() - { - return new TimeOfImpact; - } - - void Step(Settings* settings) - { - Test::Step(settings); - - b2Sweep sweepA; - sweepA.c0.Set(24.0f, -60.0f); - sweepA.a0 = 2.95f; - sweepA.c = sweepA.c0; - sweepA.a = sweepA.a0; - sweepA.localCenter.SetZero(); - - b2Sweep sweepB; - sweepB.c0.Set(53.474274f, -50.252514f); - sweepB.a0 = 513.36676f; // - 162.0f * b2_pi; - sweepB.c.Set(54.595478f, -51.083473f); - sweepB.a = 513.62781f; // - 162.0f * b2_pi; - sweepB.localCenter.SetZero(); - - //sweepB.a0 -= 300.0f * b2_pi; - //sweepB.a -= 300.0f * b2_pi; - - b2TOIInput input; - input.proxyA.Set(&m_shapeA, 0); - input.proxyB.Set(&m_shapeB, 0); - input.sweepA = sweepA; - input.sweepB = sweepB; - input.tMax = 1.0f; - - b2TOIOutput output; - - b2TimeOfImpact(&output, &input); - - m_debugDraw.DrawString(5, m_textLine, "toi = %g", output.t); - m_textLine += DRAW_STRING_NEW_LINE; - - extern int32 b2_toiMaxIters, b2_toiMaxRootIters; - m_debugDraw.DrawString(5, m_textLine, "max toi iters = %d, max root iters = %d", b2_toiMaxIters, b2_toiMaxRootIters); - m_textLine += DRAW_STRING_NEW_LINE; - - b2Vec2 vertices[b2_maxPolygonVertices]; - - b2Transform transformA; - sweepA.GetTransform(&transformA, 0.0f); - for (int32 i = 0; i < m_shapeA.m_count; ++i) - { - vertices[i] = b2Mul(transformA, m_shapeA.m_vertices[i]); - } - m_debugDraw.DrawPolygon(vertices, m_shapeA.m_count, b2Color(0.9f, 0.9f, 0.9f)); - - b2Transform transformB; - sweepB.GetTransform(&transformB, 0.0f); - - //b2Vec2 localPoint(2.0f, -0.1f); - - for (int32 i = 0; i < m_shapeB.m_count; ++i) - { - vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]); - } - m_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.5f, 0.9f, 0.5f)); - - sweepB.GetTransform(&transformB, output.t); - for (int32 i = 0; i < m_shapeB.m_count; ++i) - { - vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]); - } - m_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.5f, 0.7f, 0.9f)); - - sweepB.GetTransform(&transformB, 1.0f); - for (int32 i = 0; i < m_shapeB.m_count; ++i) - { - vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]); - } - m_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.9f, 0.5f, 0.5f)); - -#if 0 - for (float32 t = 0.0f; t < 1.0f; t += 0.1f) - { - sweepB.GetTransform(&transformB, t); - for (int32 i = 0; i < m_shapeB.m_count; ++i) - { - vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]); - } - m_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.9f, 0.5f, 0.5f)); - } -#endif - } - - b2PolygonShape m_shapeA; - b2PolygonShape m_shapeB; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Tumbler.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Tumbler.h deleted file mode 100644 index d2c6c62ee8..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Tumbler.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TUMBLER_H -#define TUMBLER_H - -class Tumbler : public Test -{ -public: - - enum - { - e_count = 800 - }; - - Tumbler() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - } - - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.allowSleep = false; - bd.position.Set(0.0f, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.5f, 10.0f, b2Vec2( 10.0f, 0.0f), 0.0); - body->CreateFixture(&shape, 5.0f); - shape.SetAsBox(0.5f, 10.0f, b2Vec2(-10.0f, 0.0f), 0.0); - body->CreateFixture(&shape, 5.0f); - shape.SetAsBox(10.0f, 0.5f, b2Vec2(0.0f, 10.0f), 0.0); - body->CreateFixture(&shape, 5.0f); - shape.SetAsBox(10.0f, 0.5f, b2Vec2(0.0f, -10.0f), 0.0); - body->CreateFixture(&shape, 5.0f); - - b2RevoluteJointDef jd; - jd.bodyA = ground; - jd.bodyB = body; - jd.localAnchorA.Set(0.0f, 10.0f); - jd.localAnchorB.Set(0.0f, 0.0f); - jd.referenceAngle = 0.0f; - jd.motorSpeed = 0.05f * b2_pi; - jd.maxMotorTorque = 1e8f; - jd.enableMotor = true; - m_joint = (b2RevoluteJoint*)m_world->CreateJoint(&jd); - } - - m_count = 0; - } - - void Step(Settings* settings) - { - Test::Step(settings); - - if (m_count < e_count) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(0.0f, 10.0f); - b2Body* body = m_world->CreateBody(&bd); - - b2PolygonShape shape; - shape.SetAsBox(0.125f, 0.125f); - body->CreateFixture(&shape, 1.0f); - - ++m_count; - } - } - - static Test* Create() - { - return new Tumbler; - } - - b2RevoluteJoint* m_joint; - int32 m_count; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/VaryingFriction.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/VaryingFriction.h deleted file mode 100644 index c85a496b0b..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/VaryingFriction.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef VARYING_FRICTION_H -#define VARYING_FRICTION_H - -class VaryingFriction : public Test -{ -public: - - VaryingFriction() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(13.0f, 0.25f); - - b2BodyDef bd; - bd.position.Set(-4.0f, 22.0f); - bd.angle = -0.25f; - - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.25f, 1.0f); - - b2BodyDef bd; - bd.position.Set(10.5f, 19.0f); - - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(13.0f, 0.25f); - - b2BodyDef bd; - bd.position.Set(4.0f, 14.0f); - bd.angle = 0.25f; - - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.25f, 1.0f); - - b2BodyDef bd; - bd.position.Set(-10.5f, 11.0f); - - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(13.0f, 0.25f); - - b2BodyDef bd; - bd.position.Set(-4.0f, 6.0f); - bd.angle = -0.25f; - - b2Body* ground = m_world->CreateBody(&bd); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 25.0f; - - float friction[5] = {0.75f, 0.5f, 0.35f, 0.1f, 0.0f}; - - for (int i = 0; i < 5; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-15.0f + 4.0f * i, 28.0f); - b2Body* body = m_world->CreateBody(&bd); - - fd.friction = friction[i]; - body->CreateFixture(&fd); - } - } - } - - static Test* Create() - { - return new VaryingFriction; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/VaryingRestitution.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/VaryingRestitution.h deleted file mode 100644 index c06aca0a87..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/VaryingRestitution.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef VARYING_RESTITUTION_H -#define VARYING_RESTITUTION_H - -// Note: even with a restitution of 1.0, there is some energy change -// due to position correction. -class VaryingRestitution : public Test -{ -public: - - VaryingRestitution() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2CircleShape shape; - shape.m_radius = 1.0f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - - float32 restitution[7] = {0.0f, 0.1f, 0.3f, 0.5f, 0.75f, 0.9f, 1.0f}; - - for (int32 i = 0; i < 7; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position.Set(-10.0f + 3.0f * i, 20.0f); - - b2Body* body = m_world->CreateBody(&bd); - - fd.restitution = restitution[i]; - body->CreateFixture(&fd); - } - } - } - - static Test* Create() - { - return new VaryingRestitution; - } -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/VerticalStack.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/VerticalStack.h deleted file mode 100644 index a5c74f83ef..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/VerticalStack.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef VERTICAL_STACK_H -#define VERTICAL_STACK_H - -class VerticalStack : public Test -{ -public: - - enum - { - e_columnCount = 5, - e_rowCount = 16 - //e_columnCount = 1, - //e_rowCount = 1 - }; - - VerticalStack() - { - { - b2BodyDef bd; - b2Body* ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - - shape.Set(b2Vec2(20.0f, 0.0f), b2Vec2(20.0f, 20.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - float32 xs[5] = {0.0f, -10.0f, -5.0f, 5.0f, 10.0f}; - - for (int32 j = 0; j < e_columnCount; ++j) - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 1.0f; - fd.friction = 0.3f; - - for (int i = 0; i < e_rowCount; ++i) - { - b2BodyDef bd; - bd.type = b2_dynamicBody; - - int32 n = j * e_rowCount + i; - b2Assert(n < e_rowCount * e_columnCount); - m_indices[n] = n; - bd.userData = m_indices + n; - - float32 x = 0.0f; - //float32 x = RandomFloat(-0.02f, 0.02f); - //float32 x = i % 2 == 0 ? -0.025f : 0.025f; - bd.position.Set(xs[j] + x, 0.752f + 1.54f * i); - b2Body* body = m_world->CreateBody(&bd); - - m_bodies[n] = body; - - body->CreateFixture(&fd); - } - } - - m_bullet = NULL; - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case ',': - if (m_bullet != NULL) - { - m_world->DestroyBody(m_bullet); - m_bullet = NULL; - } - - { - b2CircleShape shape; - shape.m_radius = 0.25f; - - b2FixtureDef fd; - fd.shape = &shape; - fd.density = 20.0f; - fd.restitution = 0.05f; - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.bullet = true; - bd.position.Set(-31.0f, 5.0f); - - m_bullet = m_world->CreateBody(&bd); - m_bullet->CreateFixture(&fd); - - m_bullet->SetLinearVelocity(b2Vec2(400.0f, 0.0f)); - } - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "Press: (,) to launch a bullet."); - m_textLine += DRAW_STRING_NEW_LINE; - - //if (m_stepCount == 300) - //{ - // if (m_bullet != NULL) - // { - // m_world->DestroyBody(m_bullet); - // m_bullet = NULL; - // } - - // { - // b2CircleShape shape; - // shape.m_radius = 0.25f; - - // b2FixtureDef fd; - // fd.shape = &shape; - // fd.density = 20.0f; - // fd.restitution = 0.05f; - - // b2BodyDef bd; - // bd.type = b2_dynamicBody; - // bd.bullet = true; - // bd.position.Set(-31.0f, 5.0f); - - // m_bullet = m_world->CreateBody(&bd); - // m_bullet->CreateFixture(&fd); - - // m_bullet->SetLinearVelocity(b2Vec2(400.0f, 0.0f)); - // } - //} - } - - static Test* Create() - { - return new VerticalStack; - } - - b2Body* m_bullet; - b2Body* m_bodies[e_rowCount * e_columnCount]; - int32 m_indices[e_rowCount * e_columnCount]; -}; - -#endif diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Web.h b/tests/cpp-tests/Classes/Box2DTestBed/Tests/Web.h deleted file mode 100644 index 375a2b4ba3..0000000000 --- a/tests/cpp-tests/Classes/Box2DTestBed/Tests/Web.h +++ /dev/null @@ -1,209 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef WEB_H -#define WEB_H - -// This tests distance joints, body destruction, and joint destruction. -class Web : public Test -{ -public: - Web() - { - b2Body* ground = NULL; - { - b2BodyDef bd; - ground = m_world->CreateBody(&bd); - - b2EdgeShape shape; - shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); - ground->CreateFixture(&shape, 0.0f); - } - - { - b2PolygonShape shape; - shape.SetAsBox(0.5f, 0.5f); - - b2BodyDef bd; - bd.type = b2_dynamicBody; - - bd.position.Set(-5.0f, 5.0f); - m_bodies[0] = m_world->CreateBody(&bd); - m_bodies[0]->CreateFixture(&shape, 5.0f); - - bd.position.Set(5.0f, 5.0f); - m_bodies[1] = m_world->CreateBody(&bd); - m_bodies[1]->CreateFixture(&shape, 5.0f); - - bd.position.Set(5.0f, 15.0f); - m_bodies[2] = m_world->CreateBody(&bd); - m_bodies[2]->CreateFixture(&shape, 5.0f); - - bd.position.Set(-5.0f, 15.0f); - m_bodies[3] = m_world->CreateBody(&bd); - m_bodies[3]->CreateFixture(&shape, 5.0f); - - b2DistanceJointDef jd; - b2Vec2 p1, p2, d; - - jd.frequencyHz = 2.0f; - jd.dampingRatio = 0.0f; - - jd.bodyA = ground; - jd.bodyB = m_bodies[0]; - jd.localAnchorA.Set(-10.0f, 0.0f); - jd.localAnchorB.Set(-0.5f, -0.5f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[0] = m_world->CreateJoint(&jd); - - jd.bodyA = ground; - jd.bodyB = m_bodies[1]; - jd.localAnchorA.Set(10.0f, 0.0f); - jd.localAnchorB.Set(0.5f, -0.5f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[1] = m_world->CreateJoint(&jd); - - jd.bodyA = ground; - jd.bodyB = m_bodies[2]; - jd.localAnchorA.Set(10.0f, 20.0f); - jd.localAnchorB.Set(0.5f, 0.5f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[2] = m_world->CreateJoint(&jd); - - jd.bodyA = ground; - jd.bodyB = m_bodies[3]; - jd.localAnchorA.Set(-10.0f, 20.0f); - jd.localAnchorB.Set(-0.5f, 0.5f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[3] = m_world->CreateJoint(&jd); - - jd.bodyA = m_bodies[0]; - jd.bodyB = m_bodies[1]; - jd.localAnchorA.Set(0.5f, 0.0f); - jd.localAnchorB.Set(-0.5f, 0.0f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[4] = m_world->CreateJoint(&jd); - - jd.bodyA = m_bodies[1]; - jd.bodyB = m_bodies[2]; - jd.localAnchorA.Set(0.0f, 0.5f); - jd.localAnchorB.Set(0.0f, -0.5f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[5] = m_world->CreateJoint(&jd); - - jd.bodyA = m_bodies[2]; - jd.bodyB = m_bodies[3]; - jd.localAnchorA.Set(-0.5f, 0.0f); - jd.localAnchorB.Set(0.5f, 0.0f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[6] = m_world->CreateJoint(&jd); - - jd.bodyA = m_bodies[3]; - jd.bodyB = m_bodies[0]; - jd.localAnchorA.Set(0.0f, -0.5f); - jd.localAnchorB.Set(0.0f, 0.5f); - p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA); - p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB); - d = p2 - p1; - jd.length = d.Length(); - m_joints[7] = m_world->CreateJoint(&jd); - } - } - - void Keyboard(unsigned char key) - { - switch (key) - { - case 'b': - for (int32 i = 0; i < 4; ++i) - { - if (m_bodies[i]) - { - m_world->DestroyBody(m_bodies[i]); - m_bodies[i] = NULL; - break; - } - } - break; - - case 'j': - for (int32 i = 0; i < 8; ++i) - { - if (m_joints[i]) - { - m_world->DestroyJoint(m_joints[i]); - m_joints[i] = NULL; - break; - } - } - break; - } - } - - void Step(Settings* settings) - { - Test::Step(settings); - m_debugDraw.DrawString(5, m_textLine, "This demonstrates a soft distance joint."); - m_textLine += DRAW_STRING_NEW_LINE; - m_debugDraw.DrawString(5, m_textLine, "Press: (b) to delete a body, (j) to delete a joint"); - m_textLine += DRAW_STRING_NEW_LINE; - } - - void JointDestroyed(b2Joint* joint) - { - for (int32 i = 0; i < 8; ++i) - { - if (m_joints[i] == joint) - { - m_joints[i] = NULL; - break; - } - } - } - - static Test* Create() - { - return new Web; - } - - b2Body* m_bodies[4]; - b2Joint* m_joints[8]; -}; - -#endif diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-12847.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-12847.cpp index 18e5016ea2..0d6ffb0af4 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-12847.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-12847.cpp @@ -57,7 +57,7 @@ bool Bug12847Layer::init() { sprite1 = Sprite::create("Images/bug12847_sprite.png"); sprite1->getTexture()->setAliasTexParameters(); - sprite1->setPosition(Vec2(_visibleSize.width/3, 50)); + sprite1->setPosition(Vec2(_visibleSize.width/3, 50.0f)); this->addChild(sprite1, 1); sprite2 = Sprite::create("Images/bug12847_sprite.png"); @@ -71,7 +71,7 @@ bool Bug12847Layer::init() sprite3 = Sprite::createWithSpriteFrameName("bug12847_sprite2.png"); sprite3->getTexture()->setAliasTexParameters(); - sprite3->setPosition(Vec2(_visibleSize.width * 2/3, 50)); + sprite3->setPosition(Vec2(_visibleSize.width * 2/3, 50.0f)); this->addChild(sprite3, 1); sprite4 = Sprite::createWithSpriteFrameName("bug12847_sprite2.png"); diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp index 4e5ded14bc..f80774c7d1 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp @@ -45,7 +45,7 @@ bool Bug914Layer::init() for( int i=0;i < 5;i++) { layer = LayerColor::create(Color4B(i*20, i*20, i*20,255)); - layer->setContentSize(Size(i*100, i*100)); + layer->setContentSize(Size(i*100.0f, i*100.0f)); layer->setPosition(size.width/2, size.height/2); layer->setAnchorPoint(Vec2(0.5f, 0.5f)); layer->setIgnoreAnchorPointForPosition(false); diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-Child.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-Child.cpp index c4ab2d4b9d..abab81548f 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-Child.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-Child.cpp @@ -118,7 +118,7 @@ bool BugCameraMask::init() updateSpriteMaskLabel(); auto label = Label::create(); - label->setPosition(size.width/2, size.height * 0.9); + label->setPosition(size.width/2, size.height * 0.9f); label->setString("Sprite should always run action."); addChild(label); diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index a609d025d9..e9961f616e 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "testResource.h" #include "ui/UISlider.h" #include "platform/CCFileUtils.h" +#include "renderer/backend/Device.h" USING_NS_CC; @@ -67,7 +68,7 @@ CameraRotationTest::CameraRotationTest() auto s = Director::getInstance()->getWinSize(); _camControlNode = Node::create(); - _camControlNode->setPositionNormalized(Vec2(.5,.5)); + _camControlNode->setPositionNormalized(Vec2(0.5f,0.5f)); addChild(_camControlNode); _camNode = Node::create(); @@ -86,30 +87,30 @@ CameraRotationTest::CameraRotationTest() //Billboards //Yellow is at the back bill1 = BillBoard::create("Images/Icon.png"); - bill1->setPosition3D(Vec3(50, 10, -10)); + bill1->setPosition3D(Vec3(50.0f, 10.0f, -10.0f)); bill1->setColor(Color3B::YELLOW); bill1->setScale(0.6f); sp3d->addChild(bill1); l1 = Label::create(); - l1->setPosition(Vec2(0,-10)); + l1->setPosition(Vec2(0.0f,-10.0f)); l1->setString("Billboard1"); l1->setColor(Color3B::WHITE); l1->setScale(3); bill1->addChild(l1); auto p1 = ParticleSystemQuad::create("Particles/SmallSun.plist"); - p1->setPosition(30,80); + p1->setPosition(30.0f,80.0f); bill1->addChild(p1); bill2 = BillBoard::create("Images/Icon.png"); - bill2->setPosition3D(Vec3(-50, -10, 10)); + bill2->setPosition3D(Vec3(-50.0f, -10.0f, 10.0f)); bill2->setScale(0.6f); sp3d->addChild(bill2); l2 = Label::create(); l2->setString("Billboard2"); - l2->setPosition(Vec2(0,-10)); + l2->setPosition(Vec2(0.0f,-10.0f)); l2->setColor(Color3B::WHITE); l2->setScale(3); bill2->addChild(l2); @@ -127,7 +128,7 @@ CameraRotationTest::CameraRotationTest() //Listener _lis = EventListenerTouchOneByOne::create(); - _lis->onTouchBegan = [this](Touch* t, Event* e) { + _lis->onTouchBegan = [](Touch* t, Event* e) { return true; }; @@ -363,16 +364,16 @@ void Camera3DTestDemo::onEnter() //draw x for( int j =-20; j<=20 ;j++) { - line->drawLine(Vec3(-100, 0, 5*j),Vec3(100,0,5*j),Color4F(1,0,0,1)); + line->drawLine(Vec3(-100.0f, 0.0f, 5.0f*j),Vec3(100.0f,0.0f,5.0f*j),Color4F(1,0,0,1)); } //draw z for( int j =-20; j<=20 ;j++) { - line->drawLine(Vec3(5*j, 0, -100),Vec3(5*j,0,100),Color4F(0,0,1,1)); + line->drawLine(Vec3(5.0f*j, 0.0f, -100.0f),Vec3(5.0f*j,0.0f,100.0f),Color4F(0,0,1,1)); } //draw y - line->drawLine(Vec3(0, -50, 0),Vec3(0,0,0),Color4F(0,0.5,0,1)); - line->drawLine(Vec3(0, 0, 0),Vec3(0,50,0),Color4F(0,1,0,1)); + line->drawLine(Vec3(0.0f, -50.0f, 0.0f),Vec3(0,0,0),Color4F(0,0.5,0,1)); + line->drawLine(Vec3(0, 0, 0),Vec3(0,50.0f,0),Color4F(0,1,0,1)); _layer3D->addChild(line); _layer3D->setCameraMask(2); @@ -410,11 +411,6 @@ void Camera3DTestDemo::addNewSpriteWithCoords(Vec3 p,std::string fileName,bool p } void Camera3DTestDemo::onTouchesBegan(const std::vector& touches, cocos2d::Event *event) { - for ( auto &item: touches ) - { - auto touch = item; - auto location = touch->getLocation(); - } } void Camera3DTestDemo::onTouchesMoved(const std::vector& touches, cocos2d::Event *event) { @@ -827,7 +823,7 @@ void CameraCullingDemo::update(float dt) void CameraCullingDemo::reachEndCallBack() { _cameraFirst->stopActionByTag(100); - auto inverse = MoveTo::create(4.f, Vec2(-_cameraFirst->getPositionX(), 0)); + auto inverse = MoveTo::create(4.f, Vec2(-_cameraFirst->getPositionX(), 0.0f)); inverse->retain(); _moveAction->release(); @@ -844,11 +840,11 @@ void CameraCullingDemo::switchViewCallback(Ref* sender) if (_cameraFirst == nullptr) { - _cameraFirst = Camera::createPerspective(30, (float)s.width/s.height, 10, 200); + _cameraFirst = Camera::createPerspective(30.0f, (float)s.width/s.height, 10.0f, 200.0f); _cameraFirst->setCameraFlag(CameraFlag::USER8); - _cameraFirst->setPosition3D(Vec3(-100,0,0)); - _cameraFirst->lookAt(Vec3(1000,0,0)); - _moveAction = MoveTo::create(4.f, Vec2(-_cameraFirst->getPositionX(), 0)); + _cameraFirst->setPosition3D(Vec3(-100.0f,0.0f,0.0f)); + _cameraFirst->lookAt(Vec3(1000.0f,0.0f,0.0f)); + _moveAction = MoveTo::create(4.f, Vec2(-_cameraFirst->getPositionX(), 0.0f)); _moveAction->retain(); auto seq = Sequence::create(_moveAction, CallFunc::create(CC_CALLBACK_0(CameraCullingDemo::reachEndCallBack, this)), nullptr); seq->setTag(100); @@ -860,7 +856,7 @@ void CameraCullingDemo::switchViewCallback(Ref* sender) { _cameraThird = Camera::createPerspective(60, (float)s.width/s.height, 1, 1000); _cameraThird->setCameraFlag(CameraFlag::USER8); - _cameraThird->setPosition3D(Vec3(0, 130, 130)); + _cameraThird->setPosition3D(Vec3(0.0f, 130.0f, 130.0f)); _cameraThird->lookAt(Vec3(0,0,0)); addChild(_cameraThird); } @@ -892,8 +888,8 @@ void CameraCullingDemo::addSpriteCallback(Ref* sender) for (int z = -_row; z < _row; z++) { auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite->setPosition3D(Vec3(x * 30, 0, z * 30)); - sprite->setRotation3D(Vec3(0,180,0)); + sprite->setPosition3D(Vec3(x * 30.0f, 0.0f, z * 30.0f)); + sprite->setRotation3D(Vec3(0.0f,180.0f,0.0f)); _objects.push_back(sprite); _layer3D->addChild(sprite); } @@ -921,7 +917,7 @@ void CameraCullingDemo::delSpriteCallback(Ref* sender) for (int z = -_row; z < _row; z++) { auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite->setPosition3D(Vec3(x * 30, 0, z * 30)); + sprite->setPosition3D(Vec3(x * 30.0f, 0.0f, z * 30.0f)); _objects.push_back(sprite); _layer3D->addChild(sprite); } @@ -1045,22 +1041,22 @@ void CameraArcBallDemo::onEnter() { _camera=Camera::createPerspective(60, (float)s.width/s.height, 1, 1000); _camera->setCameraFlag(CameraFlag::USER1); - _camera->setPosition3D(Vec3(0, 10, 50)); - _camera->lookAt(Vec3(0, 0, 0), Vec3(0, 1, 0)); + _camera->setPosition3D(Vec3(0.0f, 10.0f, 50.0f)); + _camera->lookAt(Vec3(0, 0, 0), Vec3(0.0f, 1.0f, 0.0f)); _camera->retain(); _layer3D->addChild(_camera); } _sprite3D1 = Sprite3D::create("Sprite3DTest/orc.c3b"); _sprite3D1->setScale(0.5); - _sprite3D1->setRotation3D(Vec3(0,180,0)); + _sprite3D1->setRotation3D(Vec3(0.0f,180.0f,0.0f)); _sprite3D1->setPosition3D(Vec3(0,0,0)); _layer3D->addChild(_sprite3D1); _sprite3D2 = Sprite3D::create("Sprite3DTest/boss.c3b"); _sprite3D2->setScale(0.6f); - _sprite3D2->setRotation3D(Vec3(-90,0,0)); - _sprite3D2->setPosition3D(Vec3(20,0,0)); + _sprite3D2->setRotation3D(Vec3(-90.0f,0.0f,0.0f)); + _sprite3D2->setPosition3D(Vec3(20.0f,0.0f,0.0f)); _layer3D->addChild(_sprite3D2); _drawGrid =DrawNode3D::create(); @@ -1068,15 +1064,15 @@ void CameraArcBallDemo::onEnter() //draw x for( int j =-20; j<=20 ;j++) { - _drawGrid->drawLine(Vec3(-100, 0, 5*j),Vec3(100,0,5*j),Color4F(1,0,0,1)); + _drawGrid->drawLine(Vec3(-100.0f, 0, 5.0f*j),Vec3(100.0f,0,5.0f*j),Color4F(1,0,0,1)); } //draw z for( int j =-20; j<=20 ;j++) { - _drawGrid->drawLine(Vec3(5*j, 0, -100),Vec3(5*j,0,100),Color4F(0,0,1,1)); + _drawGrid->drawLine(Vec3(5.0f*j, 0, -100.0f),Vec3(5.0f*j,0,100.0f),Color4F(0,0,1,1)); } //draw y - _drawGrid->drawLine(Vec3(0, 0, 0),Vec3(0,50,0),Color4F(0,1,0,1)); + _drawGrid->drawLine(Vec3(0, 0, 0),Vec3(0,50.0f,0),Color4F(0,1,0,1)); _layer3D->addChild(_drawGrid); _layer3D->setCameraMask(2); @@ -1103,10 +1099,10 @@ void CameraArcBallDemo::onTouchsMoved( const std::vector &touchs, Event Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 prelocation = touchs[0]->getPreviousLocationInView(); Vec2 location = touchs[0]->getLocationInView(); - location.x = 2.0 * (location.x) / (visibleSize.width) - 1.0f; - location.y = 2.0 * (visibleSize.height - location.y) / (visibleSize.height) - 1.0f; - prelocation.x = 2.0 * (prelocation.x) / (visibleSize.width) - 1.0f; - prelocation.y = 2.0 * (visibleSize.height - prelocation.y) / (visibleSize.height) - 1.0f; + location.x = 2.0f * (location.x) / (visibleSize.width) - 1.0f; + location.y = 2.0f * (visibleSize.height - location.y) / (visibleSize.height) - 1.0f; + prelocation.x = 2.0f * (prelocation.x) / (visibleSize.width) - 1.0f; + prelocation.y = 2.0f * (visibleSize.height - prelocation.y) / (visibleSize.height) - 1.0f; Vec3 axes; float angle; @@ -1141,7 +1137,7 @@ void CameraArcBallDemo::calculateArcBall( cocos2d::Vec3 & axis, float & angle, f Vec3::cross(p2, p1, &axis); //calculate rotation axis axis.normalize(); - float t = (p2 - p1).length() / (2.0 * _radius); + float t = (p2 - p1).length() / (2.0f * _radius); //clamp -1 to 1 if (t > 1.0) t = 1.0; if (t < -1.0) t = -1.0; @@ -1160,7 +1156,7 @@ float CameraArcBallDemo::projectToSphere( float r, float x, float y ) } else //on hyperbola { - t = r / 1.41421356237309504880; + t = r / 1.41421356237309504880f; z = t*t / d; } return z; @@ -1213,11 +1209,6 @@ void CameraArcBallDemo::update(float dt) // FogTestDemo FogTestDemo::FogTestDemo() : CameraBaseTest() -, _layer3D(nullptr) -, _cameraType(CameraType::Free) -, _camera(nullptr) -, _programState1(nullptr) -, _programState2(nullptr) { } FogTestDemo::~FogTestDemo() @@ -1270,9 +1261,10 @@ void FogTestDemo::onEnter() auto vertexSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.vert"); auto fragSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.frag"); - - _programState1 = new backend::ProgramState(vertexSource, fragSource); - _programState2 = new backend::ProgramState(vertexSource, fragSource); + auto program = backend::Device::getInstance()->newProgram(vertexSource, fragSource); + _programState1 = new backend::ProgramState(program); + _programState2 = new backend::ProgramState(program); + CC_SAFE_RELEASE(program); _sprite3D1 = Sprite3D::create("Sprite3DTest/teapot.c3b"); _sprite3D2 = Sprite3D::create("Sprite3DTest/teapot.c3b"); @@ -1293,19 +1285,19 @@ void FogTestDemo::onEnter() _layer3D->addChild(_sprite3D1); _sprite3D1->setPosition3D( Vec3( 0, 0,0 ) ); _sprite3D1->setScale(2.0f); - _sprite3D1->setRotation3D(Vec3(-90,180,0)); + _sprite3D1->setRotation3D(Vec3(-90.0f,180.0f,0.0f)); _layer3D->addChild(_sprite3D2); - _sprite3D2->setPosition3D( Vec3( 0, 0,-20 ) ); + _sprite3D2->setPosition3D( Vec3( 0.0f, 0.0f,-20.0f) ); _sprite3D2->setScale(2.0f); - _sprite3D2->setRotation3D(Vec3(-90,180,0)); + _sprite3D2->setRotation3D(Vec3(-90.0f,180.0f,0.0f)); if (_camera == nullptr) { _camera=Camera::createPerspective(60, (float)s.width/s.height, 1, 1000); _camera->setCameraFlag(CameraFlag::USER1); - _camera->setPosition3D(Vec3(0, 30, 40)); - _camera->lookAt(Vec3(0,0,0), Vec3(0, 1, 0)); + _camera->setPosition3D(Vec3(0.0f, 30.0f, 40.0f)); + _camera->lookAt(Vec3(0,0,0), Vec3(0.0f, 1.0f, 0.0f)); _layer3D->addChild(_camera); } @@ -1322,12 +1314,13 @@ void FogTestDemo::onEnter() auto vertexSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.vert"); auto fragSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.frag"); - - _programState1 = new backend::ProgramState(vertexSource, fragSource); - _programState2 = new backend::ProgramState(vertexSource, fragSource); + auto program = backend::Device::getInstance()->newProgram(vertexSource, fragSource); + _programState1 = new backend::ProgramState(program); + _programState2 = new backend::ProgramState(program); _sprite3D1->setProgramState(_programState1); _sprite3D2->setProgramState(_programState2); + CC_SAFE_RELEASE(program); auto fogColor = Vec4(0.5, 0.5, 0.5, 1.0); float fogStart = 10; @@ -1517,8 +1510,8 @@ void BackgroundColorBrushTest::onEnter() { // 1st Camera - auto camera = Camera::createPerspective(60, (float)s.width/s.height, 1, 1000); - camera->setPosition3D(Vec3(0, 0, 200)); + auto camera = Camera::createPerspective(60.0f, (float)s.width/s.height, 1.0f, 1000.0f); + camera->setPosition3D(Vec3(0.0f, 0.0f, 200.0f)); camera->lookAt(Vec3::ZERO); camera->setDepth(-2); camera->setCameraFlag(CameraFlag::USER1); @@ -1527,11 +1520,11 @@ void BackgroundColorBrushTest::onEnter() // 3D model auto model = Sprite3D::create("Sprite3DTest/boss1.obj"); model->setScale(4); - model->setPosition3D(Vec3(20, 0, 0)); + model->setPosition3D(Vec3(20.0f, 0.0f, 0.0f)); model->setTexture("Sprite3DTest/boss.png"); model->setCameraMask(static_cast(CameraFlag::USER1)); addChild(model); - model->runAction(RepeatForever::create(RotateBy::create(1.f, Vec3(10, 20, 30)))); + model->runAction(RepeatForever::create(RotateBy::create(1.f, Vec3(10.0f, 20.0f, 30.0f)))); } { @@ -1544,7 +1537,7 @@ void BackgroundColorBrushTest::onEnter() auto camera = Camera::createPerspective(60, (float)s.width/s.height, 1, 1000); auto colorBrush = CameraBackgroundBrush::createColorBrush(Color4F(.1f, .1f, 1.f, .5f), 1.f); camera->setBackgroundBrush(colorBrush); - camera->setPosition3D(Vec3(0, 0, 200)); + camera->setPosition3D(Vec3(0.0f, 0.0f, 200.0f)); camera->lookAt(Vec3::ZERO); camera->setDepth(-1); camera->setCameraFlag(CameraFlag::USER2); @@ -1565,10 +1558,10 @@ void BackgroundColorBrushTest::onEnter() // 3D model for 2nd camera auto model = Sprite3D::create("Sprite3DTest/boss1.obj"); model->setScale(4); - model->setPosition3D(Vec3(-20, 0, 0)); + model->setPosition3D(Vec3(-20.0f, 0.0f, 0.0f)); model->setTexture("Sprite3DTest/boss.png"); model->setCameraMask(static_cast(CameraFlag::USER2)); base->addChild(model); - model->runAction(RepeatForever::create(RotateBy::create(1.f, Vec3(10, 20, 30)))); + model->runAction(RepeatForever::create(RotateBy::create(1.f, Vec3(10.0f, 20.0f, 30.0f)))); } } diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h index 94d45afd0a..75b4e244db 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h @@ -246,7 +246,7 @@ public: void switchTypeCallback(cocos2d::Ref* sender,int type); protected: - CameraType _cameraType; + CameraType _cameraType = CameraType::Free; cocos2d::Layer* _layer3D = nullptr; cocos2d::Camera* _camera = nullptr; cocos2d::Sprite3D* _sprite3D1 = nullptr; diff --git a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp index eb8206ba47..e7af66af9d 100644 --- a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -80,7 +80,7 @@ ChipmunkTest::ChipmunkTest() #endif addChild(parent, 0, kTagParentNode); - addNewSpriteAtPosition(cocos2d::Vec2(200,200)); + addNewSpriteAtPosition(cocos2d::Vec2(200.0f,200.0f)); // menu for debug layer MenuItemFont::setFontSize(18); @@ -142,7 +142,7 @@ void ChipmunkTest::initPhysics() cpHastySpaceSetThreads(_space, 0); #endif - cpSpaceSetGravity(_space, cpv(0, -100)); + cpSpaceSetGravity(_space, cpv(0.0f, -100.0f)); // // rogue shapes diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index cb2cf04daf..3c73098db0 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -122,7 +122,7 @@ void BasicTest::setup() auto clipper = this->clipper(); clipper->setTag( kTagClipperNode ); - clipper->setAnchorPoint(Vec2(0.5, 0.5)); + clipper->setAnchorPoint(Vec2(0.5f, 0.5f)); clipper->setPosition(s.width / 2 - 50, s.height / 2 - 50); clipper->setStencil(stencil); this->addChild(clipper); @@ -321,15 +321,15 @@ void NestedTest::setup() auto clipper = ClippingNode::create(); clipper->setContentSize(Size(size, size)); - clipper->setAnchorPoint(Vec2(0.5, 0.5)); + clipper->setAnchorPoint(Vec2(0.5f, 0.5f)); clipper->setPosition(parent->getContentSize().width / 2, parent->getContentSize().height / 2); clipper->setAlphaThreshold(0.05f); - clipper->runAction(RepeatForever::create(RotateBy::create(i % 3 ? 1.33 : 1.66, i % 2 ? 90 : -90))); + clipper->runAction(RepeatForever::create(RotateBy::create(i % 3 ? 1.33f : 1.66f, i % 2 ? 90.0f : -90.0f))); parent->addChild(clipper); auto stencil = Sprite::create(s_pathGrossini); - stencil->setScale( 2.5 - (i * (2.5 / depth)) ); - stencil->setAnchorPoint( Vec2(0.5, 0.5) ); + stencil->setScale( 2.5f - (i * (2.5f / depth)) ); + stencil->setAnchorPoint( Vec2(0.5f, 0.5f) ); stencil->setPosition(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2); stencil->setVisible(false); stencil->runAction(Sequence::createWithTwoActions(DelayTime::create(i), Show::create())); @@ -373,7 +373,7 @@ void HoleDemo::setup() transform = AffineTransformScale(transform, target->getScale(), target->getScale()); _outerClipper->setContentSize(SizeApplyAffineTransform(target->getContentSize(), transform)); - _outerClipper->setAnchorPoint( Vec2(0.5, 0.5) ); + _outerClipper->setAnchorPoint( Vec2(0.5f, 0.5f) ); _outerClipper->setPosition(Vec2(this->getContentSize()) * 0.5f); _outerClipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); @@ -453,18 +453,18 @@ void ScrollViewDemo::setup() { auto clipper = ClippingNode::create(); clipper->setTag( kTagClipperNode ); - clipper->setContentSize( Size(200, 200) ); - clipper->setAnchorPoint( Vec2(0.5, 0.5) ); + clipper->setContentSize( Size(200.0f, 200.0f) ); + clipper->setAnchorPoint( Vec2(0.5f, 0.5f) ); clipper->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2); clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); this->addChild(clipper); auto stencil = DrawNode::create(); Vec2 rectangle[4]; - rectangle[0] = Vec2(0, 0); - rectangle[1] = Vec2(clipper->getContentSize().width, 0); + rectangle[0] = Vec2(0.0f, 0.0f); + rectangle[1] = Vec2(clipper->getContentSize().width, 0.0f); rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height); - rectangle[3] = Vec2(0, clipper->getContentSize().height); + rectangle[3] = Vec2(0.0f, clipper->getContentSize().height); Color4F white(1, 1, 1, 1); stencil->drawPolygon(rectangle, 4, white, 1, white); @@ -472,7 +472,7 @@ void ScrollViewDemo::setup() auto content = Sprite::create(s_back2); content->setTag( kTagContentNode ); - content->setAnchorPoint( Vec2(0.5, 0.5) ); + content->setAnchorPoint( Vec2(0.5f, 0.5f) ); content->setPosition(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2); clipper->addChild(content); @@ -577,7 +577,8 @@ void RawStencilBufferTest::initCommands() }; _disableStencilCallback.init(_globalZOrder); - _programState = new (std::nothrow) backend::ProgramState(positionUColor_vert, positionUColor_frag); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_UCOLOR); + _programState = new (std::nothrow) backend::ProgramState(program); _locColor = _programState->getProgram()->getUniformLocation("u_color"); _locMVPMatrix = _programState->getProgram()->getUniformLocation("u_MVPMatrix"); const auto& projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); @@ -601,9 +602,9 @@ void RawStencilBufferTest::initCommands() cmd.setBeforeCallback( CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i) ); Vec2 vertices[] = { Vec2::ZERO, - Vec2(stencilPoint.x, 0), + Vec2(stencilPoint.x, 0.0f), stencilPoint, - Vec2(0, stencilPoint.y) + Vec2(0.0f, stencilPoint.y) }; unsigned short indices[] = {0, 2, 1, 0, 3, 2}; cmd.createVertexBuffer(sizeof(Vec2), 4, backend::BufferUsage::STATIC); @@ -625,9 +626,9 @@ void RawStencilBufferTest::initCommands() cmd2.setBeforeCallback(CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i)); Vec2 vertices2[] = { Vec2::ZERO, - Vec2(winPoint.x, 0), + Vec2(winPoint.x, 0.0f), winPoint, - Vec2(0, winPoint.y) + Vec2(0.0f, winPoint.y) }; cmd2.createVertexBuffer(sizeof(Vec2), 4, backend::BufferUsage::STATIC); cmd2.updateVertexBuffer(vertices2, sizeof(vertices2)); @@ -753,7 +754,8 @@ void RawStencilBufferTestAlphaTest::setup() RawStencilBufferTest::setup(); for(int i = 0; i < _planeCount; ++i) { - auto programState = new backend::ProgramState(positionTextureColor_vert, positionTextureColorAlphaTest_frag); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST); + auto programState = new backend::ProgramState(program); programState->setUniform(programState->getUniformLocation("u_alpha_value"), &_alphaThreshold, sizeof(_alphaThreshold)); _spritesStencil.at(i)->setProgramState(programState); } @@ -899,7 +901,7 @@ void ClippingToRenderTextureTest::expectedBehaviour() stencil->drawPolygon(triangle, 3, green, 0, green); auto clipper = ClippingNode::create(); - clipper->setAnchorPoint(Point(0.5, 0.5)); + clipper->setAnchorPoint(Point(0.5f, 0.5f)); clipper->setPosition( Point(visibleSize.width/2, visibleSize.height/2) ); clipper->setStencil(stencil); clipper->setInverted(true); @@ -945,7 +947,7 @@ void ClippingToRenderTextureTest::reproduceBug() stencil->drawPolygon(triangle, 3, green, 0, green); auto clipper = ClippingNode::create(); - clipper->setAnchorPoint(Point(0.5, 0.5)); + clipper->setAnchorPoint(Point(0.5f, 0.5f)); clipper->setPosition( Point(visibleSize.width/2, visibleSize.height/2) ); clipper->setStencil(stencil); clipper->setInverted(true); @@ -986,13 +988,13 @@ std::string ClippingRectangleNodeTest::subtitle() const void ClippingRectangleNodeTest::setup() { auto clipper = ClippingRectangleNode::create(); - clipper->setClippingRegion(Rect(this->getContentSize().width / 2 - 100, this->getContentSize().height / 2 - 100, 200, 200)); + clipper->setClippingRegion(Rect(this->getContentSize().width / 2 - 100, this->getContentSize().height / 2 - 100, 200.0f, 200.0f)); clipper->setTag( kTagClipperNode ); this->addChild(clipper); auto content = Sprite::create(s_back2); content->setTag( kTagContentNode ); - content->setAnchorPoint( Vec2(0.5, 0.5) ); + content->setAnchorPoint( Vec2(0.5f, 0.5f) ); content->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2); clipper->addChild(content); } diff --git a/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp b/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp index 4181834e23..2b94f72f47 100644 --- a/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp +++ b/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp @@ -83,7 +83,7 @@ struct DownloaderTest : public TestCase // add a title on the top auto title = Label::createWithTTF(name,"fonts/arial.ttf",16); title->setTag(TAG_TITLE); - title->setAnchorPoint(Vec2(0.5, 1)); + title->setAnchorPoint(Vec2(0.5f, 1.0f)); title->setPosition(viewSize.width / 2, viewSize.height - margin); bg->addChild(title, 10); @@ -92,7 +92,7 @@ struct DownloaderTest : public TestCase "cocosui/animationbuttonpressed.png"); btn->setTag(TAG_BUTTON); btn->setTitleText("Download"); - btn->setAnchorPoint(Vec2(0.5, 0)); + btn->setAnchorPoint(Vec2(0.5f, 0.0f)); btn->setPosition(Vec2(viewSize.width / 2, margin)); btn->addClickEventListener(callback); bg->addChild(btn, 10); @@ -101,7 +101,7 @@ struct DownloaderTest : public TestCase auto bar = ui::LoadingBar::create("ccs-res/cocosui/sliderProgress.png"); bar->setTag(TAG_PROGRESS_BAR); bar->ignoreContentAdaptWithSize(false); - bar->setAnchorPoint(Vec2(0.5, 0)); + bar->setAnchorPoint(Vec2(0.5f, 0.0f)); bar->setContentSize(Size(viewSize.width - margin * 2, btn->getContentSize().height)); bar->setPosition(btn->getPosition()); bar->setVisible(false); @@ -110,9 +110,9 @@ struct DownloaderTest : public TestCase // add a status label auto label = Label::createWithTTF("","fonts/arial.ttf",14); label->setTag(TAG_STATUS); - label->setAnchorPoint(Vec2(0.5, 0.5)); + label->setAnchorPoint(Vec2(0.5f, 0.5f)); label->setPosition(Vec2(viewSize.width / 2, viewSize.height / 2)); - label->setContentSize(Size(viewSize.width, 0)); + label->setContentSize(Size(viewSize.width, 0.0f)); label->setAlignment(TextHAlignment::CENTER, TextVAlignment::CENTER); label->setDimensions(viewSize.width, viewSize.height); bg->addChild(label, 20); @@ -167,7 +167,7 @@ struct DownloaderTest : public TestCase this->downloader->createDownloadDataTask(sURLList[1], sNameList[1]); }); topLeftView->setName(sNameList[1]); - topLeftView->setAnchorPoint(Vec2(1, 0)); + topLeftView->setAnchorPoint(Vec2(1.0f, 0.0f)); topLeftView->setPosition(VisibleRect::center()); this->addChild(topLeftView); diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 543f2c00e2..1c94ff53ab 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -66,54 +66,54 @@ DrawNodeTest::DrawNodeTest() draw->drawRect(Vec2(15,30), Vec2(30,15), Vec2(15,0), Vec2(0,15), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); // draw a circle - draw->drawCircle(VisibleRect::center() + Vec2(140,0), 100, CC_DEGREES_TO_RADIANS(90), 50, true, 1.0f, 2.0f, Color4F(1.0, 0.0, 0.0, 0.5)); + draw->drawCircle(VisibleRect::center() + Vec2(140,0), 100, CC_DEGREES_TO_RADIANS(90), 50, true, 1.0f, 2.0f, Color4F(1.0f, 0.0f, 0.0f, 0.5f)); - draw->drawCircle(VisibleRect::center() - Vec2(140,0), 50, CC_DEGREES_TO_RADIANS(90), 30, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + draw->drawCircle(VisibleRect::center() - Vec2(140,0), 50, CC_DEGREES_TO_RADIANS(90), 30, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); // Draw some beziers - draw->drawQuadBezier(Vec2(s.width - 150, s.height - 150), Vec2(s.width - 70, s.height - 10), Vec2(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawQuadBezier(Vec2(s.width - 150, s.height - 150), Vec2(s.width - 70, s.height - 10), Vec2(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); - draw->drawQuadBezier(Vec2(0, s.height), Vec2(s.width/2, s.height/2), Vec2(s.width, s.height), 50, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawQuadBezier(Vec2(0.0f, s.height), Vec2(s.width/2, s.height/2), Vec2(s.width, s.height), 50, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); - draw->drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x+30,VisibleRect::center().y+50), Vec2(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x+30,VisibleRect::center().y+50), Vec2(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); - draw->drawCubicBezier(Vec2(s.width - 250, 40), Vec2(s.width - 70, 100), Vec2(s.width - 30, 250), Vec2(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawCubicBezier(Vec2(s.width - 250, 40.0f), Vec2(s.width - 70, 100.0f), Vec2(s.width - 30, 250.0f), Vec2(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); auto array = PointArray::create(20); - array->addControlPoint(Vec2(0,0)); - array->addControlPoint(Vec2(80,80)); - array->addControlPoint(Vec2(s.width-80,80)); + array->addControlPoint(Vec2(0.0f,0.0f)); + array->addControlPoint(Vec2(80.0f,80.0f)); + array->addControlPoint(Vec2(s.width-80,80.0f)); array->addControlPoint(Vec2(s.width-80,s.height-80)); - array->addControlPoint(Vec2(80,s.height-80)); - array->addControlPoint(Vec2(80,80)); + array->addControlPoint(Vec2(80.0f,s.height-80)); + array->addControlPoint(Vec2(80.0f,80.0f)); array->addControlPoint(Vec2(s.width/2, s.height/2)); - draw->drawCardinalSpline(array, 0.5, 50, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawCardinalSpline(array, 0.5f, 50, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); auto array2 = PointArray::create(20); - array2->addControlPoint(Vec2(s.width / 2, 30)); - array2->addControlPoint(Vec2(s.width -80, 30)); + array2->addControlPoint(Vec2(s.width / 2, 30.0f)); + array2->addControlPoint(Vec2(s.width -80, 30.0f)); array2->addControlPoint(Vec2(s.width - 80, s.height - 80)); array2->addControlPoint(Vec2(s.width / 2, s.height - 80)); - array2->addControlPoint(Vec2(s.width / 2, 30)); - draw->drawCatmullRom(array2, 50, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + array2->addControlPoint(Vec2(s.width / 2, 30.0f)); + draw->drawCatmullRom(array2, 50, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); // open random color poly - Vec2 vertices[] = { Vec2(0,0), Vec2(50,50), Vec2(100,50), Vec2(100,100), Vec2(50,100) }; - draw->drawPoly( vertices, 5, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + Vec2 vertices[] = { Vec2(0.0f,0.0f), Vec2(50.0f,50.0f), Vec2(100.0f,50.0f), Vec2(100.0f,100.0f), Vec2(50.0f,100.0f) }; + draw->drawPoly( vertices, 5, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); // closed random color poly - Vec2 vertices2[] = { Vec2(30,130), Vec2(30,230), Vec2(50,200) }; - draw->drawPoly( vertices2, 3, true, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + Vec2 vertices2[] = { Vec2(30.0f,130.0f), Vec2(30.0f,230.0f), Vec2(50.0f,200.0f) }; + draw->drawPoly( vertices2, 3, true, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); // Draw 10 circles for( int i=0; i < 10; i++) { - draw->drawDot(Vec2(s.width/2, s.height/2), 10*(10-i), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + draw->drawDot(Vec2(s.width/2, s.height/2), 10*(10-i), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); } // Draw polygons - Vec2 points[] = { Vec2(s.height/4,0), Vec2(s.width,s.height/5), Vec2(s.width/3*2,s.height) }; - draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), Color4F(1,0,0,0.5), 4, Color4F(0,0,1,0.5)); + Vec2 points[] = { Vec2(s.height/4,0.0f), Vec2(s.width,s.height/5), Vec2(s.width/3*2,s.height) }; + draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), Color4F(1.0f,0.0f,0.0f,0.5f), 4, Color4F(0.0f,0.0f,1.0f,0.5f)); // star poly (triggers buggs) { @@ -127,7 +127,7 @@ DrawNodeTest::DrawNodeTest() // {o -h, o+w}, {o,o}, // left spike }; - draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1)); + draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), Color4F(1.0f,0.0f,0.0f,0.5f), 1, Color4F(0.0f,0.0f,1.0f,1.0f)); } // star poly (doesn't trigger bug... order is important un tesselation is supported. @@ -142,36 +142,36 @@ DrawNodeTest::DrawNodeTest() Vec2(o -h, o+w), // left spike }; - draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1)); + draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), Color4F(1.0f,0.0f,0.0f,0.5f), 1, Color4F(0.0f,0.0f,1.0f,1.0f)); } //draw a solid polygon - Vec2 vertices3[] = {Vec2(60,160), Vec2(70,190), Vec2(100,190), Vec2(90,160)}; - draw->drawSolidPoly( vertices3, 4, Color4F(1,1,0,1) ); + Vec2 vertices3[] = {Vec2(60.0f,160.0f), Vec2(70.0f,190.0f), Vec2(100.0f,190.0f), Vec2(90.0f,160.0f)}; + draw->drawSolidPoly( vertices3, 4, Color4F(1.0f,1.0f,0.0f,1.0f) ); //draw a solid rectangle - draw->drawSolidRect(Vec2(10,10), Vec2(20,20), Color4F(1,1,0,1)); + draw->drawSolidRect(Vec2(10.0f,10.0f), Vec2(20.0f,20.0f), Color4F(1.0f,1.0f,0.0f,1.0f)); //draw a solid circle - draw->drawSolidCircle( VisibleRect::center() + Vec2(140,0), 40, CC_DEGREES_TO_RADIANS(90), 50, 2.0f, 2.0f, Color4F(0.0, 1.0, 0.0, 1.0)); + draw->drawSolidCircle( VisibleRect::center() + Vec2(140.0f,0.0f), 40, CC_DEGREES_TO_RADIANS(90), 50, 2.0f, 2.0f, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); // Draw segment - draw->drawSegment(Vec2(20,s.height), Vec2(20,s.height/2), 10, Color4F(0, 1, 0, 1)); + draw->drawSegment(Vec2(20.0f,s.height), Vec2(20.0f,s.height/2), 10, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); - draw->drawSegment(Vec2(10,s.height/2), Vec2(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5)); + draw->drawSegment(Vec2(10.0f,s.height/2), Vec2(s.width/2, s.height/2), 40, Color4F(1.0f, 0.0f, 1.0f, 0.5f)); // Draw triangle - draw->drawTriangle(Vec2(10, 10), Vec2(70, 30), Vec2(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + draw->drawTriangle(Vec2(10.0f, 10.0f), Vec2(70.0f, 30.0f), Vec2(100.0f, 140.0f), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5f)); for (int i = 0; i < 100; i++) { - draw->drawPoint(Vec2(i*7, 5), (float)i/5+1, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + draw->drawPoint(Vec2(i*7.0f, 5.0f), (float)i/5+1, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1.0f)); } auto draw1 = DrawNode::create(); this->addChild(draw1, 10); draw1->setLineWidth(4); - draw1->drawLine(Vec2(0, s.height), Vec2(s.width, s.height - 20), Color4F::YELLOW); - draw1->drawLine(Vec2(0, 0), Vec2(s.width, s.height - 20), Color4F::YELLOW); + draw1->drawLine(Vec2(0.0f, s.height), Vec2(s.width, s.height - 20), Color4F::YELLOW); + draw1->drawLine(Vec2(0.0f, 0.0f), Vec2(s.width, s.height - 20), Color4F::YELLOW); draw->runAction(RepeatForever::create(Sequence::create(FadeIn::create(1.2),FadeOut::create(1.2), NULL))); draw1->runAction(RepeatForever::create(Sequence::create(FadeIn::create(1.2),FadeOut::create(1.2), NULL))); @@ -197,9 +197,9 @@ Issue11942Test::Issue11942Test() // draw a circle draw->setLineWidth(1); - draw->drawCircle(VisibleRect::center() - Vec2(140,0), 50, CC_DEGREES_TO_RADIANS(90), 30, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + draw->drawCircle(VisibleRect::center() - Vec2(140.0f,0.0f), 50, CC_DEGREES_TO_RADIANS(90), 30, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); draw->setLineWidth(10); - draw->drawCircle(VisibleRect::center() + Vec2(140,0), 50, CC_DEGREES_TO_RADIANS(90), 30, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + draw->drawCircle(VisibleRect::center() + Vec2(140.0f,0.0f), 50, CC_DEGREES_TO_RADIANS(90), 30, false, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); } string Issue11942Test::title() const diff --git a/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index c82084558b..7a9d62b358 100644 --- a/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/cpp-tests/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -312,7 +312,7 @@ void EffectAdvanceBaseTest::onEnter() TestCase::onEnter(); _bgNode = NodeGrid::create(); - _bgNode->setAnchorPoint(Vec2(0.5,0.5)); + _bgNode->setAnchorPoint(Vec2(0.5f,0.5f)); addChild(_bgNode); //_bgNode->setPosition( VisibleRect::center() ); auto bg = Sprite::create("Images/background3.png"); @@ -322,7 +322,7 @@ void EffectAdvanceBaseTest::onEnter() _bgNode->addChild(bg); _target1 = NodeGrid::create(); - _target1->setAnchorPoint(Vec2(0.5,0.5)); + _target1->setAnchorPoint(Vec2(0.5f,0.5f)); auto grossini = Sprite::create("Images/grossinis_sister2.png"); _target1->addChild(grossini); _bgNode->addChild(_target1); @@ -333,7 +333,7 @@ void EffectAdvanceBaseTest::onEnter() _target2 = NodeGrid::create(); - _target2->setAnchorPoint(Vec2(0.5,0.5)); + _target2->setAnchorPoint(Vec2(0.5f,0.5f)); auto tamara = Sprite::create("Images/grossinis_sister1.png"); _target2->addChild(tamara); _bgNode->addChild(_target2); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp index fe5f508e42..d6bf7f0d98 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp @@ -123,8 +123,7 @@ void AssetsManagerExLoaderScene::startDownloadCallback(Ref* sender) } else { - int testIndex = _testIndex; - _amListener = cocos2d::extension::EventListenerAssetsManagerEx::create(_am, [testIndex, this](EventAssetsManagerEx* event){ + _amListener = cocos2d::extension::EventListenerAssetsManagerEx::create(_am, [this](EventAssetsManagerEx* event){ static int failCount = 0; switch (event->getEventCode()) { diff --git a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index 164413d1a0..144595032e 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -44,9 +44,9 @@ bool TableViewTest::init() Size winSize = Director::getInstance()->getWinSize(); - TableView* tableView = TableView::create(this, Size(250, 60)); + TableView* tableView = TableView::create(this, Size(250.0f, 60.0f)); tableView->setDirection(ScrollView::Direction::HORIZONTAL); - tableView->setPosition(Vec2(20,winSize.height/2-30)); + tableView->setPosition(Vec2(20.0f,winSize.height/2-30)); tableView->setDelegate(this); this->addChild(tableView); tableView->reloadData(); @@ -58,7 +58,7 @@ bool TableViewTest::init() CCAssert(nullptr == tableView->getChildByName("testNode"), "The added child has been removed!"); - tableView = TableView::create(this, Size(60, 250)); + tableView = TableView::create(this, Size(60.0f, 250.0f)); tableView->setDirection(ScrollView::Direction::VERTICAL); tableView->setPosition(Vec2(winSize.width-150,winSize.height/2-120)); tableView->setDelegate(this); diff --git a/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp b/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp index 59170abbff..a998e7edeb 100644 --- a/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp +++ b/tests/cpp-tests/Classes/IntervalTest/IntervalTest.cpp @@ -108,7 +108,7 @@ IntervalTest::IntervalTest() auto sprite = Sprite::create(s_pathGrossini); sprite->setPosition(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50); - auto jump = JumpBy::create(3, Vec2(s.width-80,0), 50, 4); + auto jump = JumpBy::create(3, Vec2(s.width-80,0.0f), 50, 4); addChild(sprite); sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), nullptr) )); diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 9d3bdaa8b8..0d21487228 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -213,8 +213,8 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() auto s = Director::getInstance()->getWinSize(); auto drawNode = DrawNode::create(); - drawNode->drawLine( Vec2(0, s.height/2), Vec2(s.width, s.height/2), Color4F(1.0, 1.0, 1.0, 1.0) ); - drawNode->drawLine( Vec2(s.width/2, 0), Vec2(s.width/2, s.height), Color4F(1.0, 1.0, 1.0, 1.0) ); + drawNode->drawLine( Vec2(0.0f, s.height/2), Vec2(s.width, s.height/2), Color4F(1.0f, 1.0f, 1.0f, 1.0f) ); + drawNode->drawLine( Vec2(s.width/2, 0.0f), Vec2(s.width/2, s.height), Color4F(1.0f, 1.0f, 1.0f, 1.0f) ); addChild(drawNode, -1); // Upper Label @@ -254,7 +254,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() // Bottom Label auto label2 = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "00.0"); addChild(label2, 0, kTagBitmapAtlas2); - label2->setPosition( Vec2(s.width/2.0f, 80) ); + label2->setPosition( Vec2(s.width/2.0f, 80.0f) ); auto lastChar = (Sprite*) label2->getLetter(3); lastChar->runAction( rot_4ever->clone() ); @@ -472,7 +472,7 @@ LabelFNTandTTFEmpty::LabelFNTandTTFEmpty() auto label3 = Label::createWithCharMap("fonts/tuffy_bold_italic-charmap.plist"); addChild(label3, 0, kTagBitmapAtlas3); - label3->setPosition(Vec2(s.width/2, 100)); + label3->setPosition(Vec2(s.width/2, 100.0f)); schedule(CC_CALLBACK_1(LabelFNTandTTFEmpty::updateStrings, this), 1.0f, "update_strings_key"); @@ -919,7 +919,7 @@ LabelFNTBounds::LabelFNTBounds() Vec2(labelSize.width + origin.width, labelSize.height + origin.height), Vec2(origin.width, labelSize.height + origin.height) }; - drawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0)); + drawNode->drawPoly(vertices, 4, true, Color4F(1.0f, 1.0f, 1.0f, 1.0f)); addChild(drawNode); } @@ -941,7 +941,7 @@ LabelTTFLongLineWrapping::LabelTTFLongLineWrapping() TTFConfig ttfConfig("fonts/arial.ttf", 14); auto label1 = Label::createWithTTF(ttfConfig, LongSentencesExample, TextHAlignment::CENTER,size.width); label1->setPosition( Vec2(size.width/2, size.height/2) ); - label1->setAnchorPoint(Vec2(0.5, 1.0)); + label1->setAnchorPoint(Vec2(0.5f, 1.0f)); addChild(label1); } @@ -1056,19 +1056,19 @@ LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest() drawNode->setAnchorPoint(Vec2(0, 0)); this->addChild(drawNode); drawNode->drawSegment( - Vec2(size.width * 0.1, size.height * 0.8), - Vec2(size.width * 0.1, 0), 1, Color4F(1, 0, 0, 1)); + Vec2(size.width * 0.1f, size.height * 0.8f), + Vec2(size.width * 0.1, 0.0f), 1, Color4F(1.0f, 0.0f, 0.0f, 1.0f)); drawNode->drawSegment( - Vec2(size.width * 0.85, size.height * 0.8), - Vec2(size.width * 0.85, 0), 1, Color4F(1, 0, 0, 1)); + Vec2(size.width * 0.85f, size.height * 0.8f), + Vec2(size.width * 0.85f, 0.0f), 1, Color4F(1.0f, 0.0f, 0.0f, 1.0f)); TTFConfig ttfConfig("fonts/HKYuanMini.ttf", 25, GlyphCollection::DYNAMIC); auto label1 = Label::createWithTTF(ttfConfig, - "你好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75); + "你好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75f); if(label1) { label1->setTextColor(Color4B(128, 255, 255, 255)); - label1->setPosition(Vec2(size.width * 0.1, size.height * 0.6)); - label1->setAnchorPoint(Vec2(0, 0.5)); + label1->setPosition(Vec2(size.width * 0.1f, size.height * 0.6f)); + label1->setAnchorPoint(Vec2(0.0f, 0.5f)); this->addChild(label1); // Demo for unloadFontAtlasTTF function, after it been called, all UI widget // use the special font must reset font, because the old one is invalid. @@ -1077,20 +1077,20 @@ LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest() } auto label2 = Label::createWithTTF(ttfConfig, - "早上好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75); + "早上好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75f); if(label2) { label2->setTextColor(Color4B(255, 128, 255, 255)); - label2->setPosition(Vec2(size.width * 0.1, size.height * 0.4)); - label2->setAnchorPoint(Vec2(0, 0.5)); + label2->setPosition(Vec2(size.width * 0.1f, size.height * 0.4f)); + label2->setAnchorPoint(Vec2(0.0f, 0.5f)); this->addChild(label2); } auto label3 = Label::createWithTTF(ttfConfig, - "美好的一天啊美好的一天啊美好的一天啊", TextHAlignment::LEFT, size.width * 0.75); + "美好的一天啊美好的一天啊美好的一天啊", TextHAlignment::LEFT, size.width * 0.75f); if(label3) { label3->setTextColor(Color4B(255, 255, 128, 255)); - label3->setPosition(Vec2(size.width * 0.1, size.height * 0.2)); - label3->setAnchorPoint(Vec2(0, 0.5)); + label3->setPosition(Vec2(size.width * 0.1f, size.height * 0.2f)); + label3->setAnchorPoint(Vec2(0.0f, 0.5f)); this->addChild(label3); } } @@ -1232,9 +1232,9 @@ LabelTTFDistanceField::LabelTTFDistanceField() Vec2 vertices[4] = { Vec2::ZERO, - Vec2(labelContentSize.width, 0), + Vec2(labelContentSize.width, 0.0f), Vec2(labelContentSize.width, labelContentSize.height), - Vec2(0, labelContentSize.height) + Vec2(0.0f, labelContentSize.height) }; borderDraw->drawPoly(vertices, 4, true, Color4F::RED); @@ -1252,9 +1252,9 @@ LabelTTFDistanceField::LabelTTFDistanceField() Vec2 vertices2[4] = { Vec2::ZERO, - Vec2(labelContentSize2.width, 0), + Vec2(labelContentSize2.width, 0.0f), Vec2(labelContentSize2.width, labelContentSize2.height), - Vec2(0, labelContentSize2.height) + Vec2(0.0f, labelContentSize2.height) }; borderDraw2->drawPoly(vertices2, 4, true, Color4F::GREEN); } @@ -1347,7 +1347,7 @@ void LabelShadowTest::onEnter() slider2->loadBarTexture("cocosui/sliderTrack.png"); slider2->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider2->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider2->setPosition(Vec2(size.width * 0.15f, size.height / 2.0)); + slider2->setPosition(Vec2(size.width * 0.15f, size.height / 2.0f)); slider2->setRotation(90); slider2->setPercent(52); slider2->addEventListener(CC_CALLBACK_2(LabelShadowTest::sliderEvent, this)); @@ -1380,7 +1380,7 @@ void LabelShadowTest::onEnter() addChild(shadowLabelGrow); shadowLabelBMFont = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "BMFont:Shadow"); - shadowLabelBMFont->setPosition( Vec2(size.width/2, horizontalSliderY + step * (0.5f + 0))); + shadowLabelBMFont->setPosition( Vec2(size.width/2, horizontalSliderY + step * 0.5f)); shadowLabelBMFont->setColor( Color3B::RED ); shadowLabelBMFont->enableShadow(Color4B::GREEN); addChild(shadowLabelBMFont); @@ -1563,7 +1563,7 @@ LabelTTFOldNew::LabelTTFOldNew() Vec2(labelSize.width + origin.width, labelSize.height + origin.height), Vec2(origin.width, labelSize.height + origin.height) }; - drawNode->drawPoly(vertices, 4, true, Color4F(1.0, 0.0, 0.0, 1.0)); + drawNode->drawPoly(vertices, 4, true, Color4F(1.0f, 0.0f, 0.0f, 1.0f)); labelSize = label2->getContentSize(); origin = Director::getInstance()->getWinSize(); @@ -1578,7 +1578,7 @@ LabelTTFOldNew::LabelTTFOldNew() Vec2(labelSize.width + origin.width, labelSize.height + origin.height), Vec2(origin.width, labelSize.height + origin.height) }; - drawNode->drawPoly(vertices2, 4, true, Color4F(1.0, 1.0, 1.0, 1.0)); + drawNode->drawPoly(vertices2, 4, true, Color4F(1.0f, 1.0f, 1.0f, 1.0f)); addChild(drawNode); } @@ -1636,7 +1636,7 @@ LabelAlignmentTest::LabelAlignmentTest() MenuItemFont::create("Right", CC_CALLBACK_1(LabelAlignmentTest::setAlignmentRight, this)), nullptr); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vec2(50, s.height / 2 - 20)); + menu->setPosition(Vec2(50.0f, s.height / 2 - 20)); this->addChild(menu); menu = Menu::create( @@ -1894,7 +1894,7 @@ std::string LabelIssue9255Test::subtitle() const LabelSmallDimensionsTest::LabelSmallDimensionsTest() { - auto label = Label::createWithSystemFont("Hello World!", "fonts/arial.ttf", 24, Size(30,100)); + auto label = Label::createWithSystemFont("Hello World!", "fonts/arial.ttf", 24, Size(30.0f,100.0f)); label->setPosition(VisibleRect::center()); addChild(label); } @@ -2259,7 +2259,7 @@ void LabelLayoutBaseTest::initFontSizeChange(const cocos2d::Size& size) stepper->setScale(0.5); fontSizeLabel->setPosition(stepper->getPosition() - - Vec2(stepper->getContentSize().width/2 + fontSizeLabel->getContentSize().width/2,0)); + Vec2(stepper->getContentSize().width/2 + fontSizeLabel->getContentSize().width/2,0.0f)); this->addChild(fontSizeLabel); } @@ -2338,7 +2338,7 @@ void LabelLayoutBaseTest::initAlignmentOption(const cocos2d::Size& size) MenuItemFont::create("Right", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentRight, this)), nullptr); menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vec2(50, size.height / 2 - 20)); + menu->setPosition(Vec2(50.0f, size.height / 2 - 20)); this->addChild(menu); menu = Menu::create( @@ -2369,7 +2369,7 @@ void LabelLayoutBaseTest::initSliders(const cocos2d::Size& size) slider2->loadBarTexture("cocosui/sliderTrack.png"); slider2->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider2->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider2->setPosition(Vec2(size.width * 0.2f, size.height / 2.0)); + slider2->setPosition(Vec2(size.width * 0.2f, size.height / 2.0f)); slider2->setRotation(90); slider2->setPercent(52); addChild(slider2); @@ -2495,10 +2495,10 @@ void LabelLayoutBaseTest::updateDrawNodeSize(const cocos2d::Size &drawNodeSize) Vec2(origin.width, drawNodeSize.height + origin.height) }; _drawNode->clear(); - _drawNode->drawLine(vertices[0], vertices[1], Color4F(1.0, 1.0, 1.0, 1.0)); - _drawNode->drawLine(vertices[0], vertices[3], Color4F(1.0, 1.0, 1.0, 1.0)); - _drawNode->drawLine(vertices[2], vertices[3], Color4F(1.0, 1.0, 1.0, 1.0)); - _drawNode->drawLine(vertices[1], vertices[2], Color4F(1.0, 1.0, 1.0, 1.0)); + _drawNode->drawLine(vertices[0], vertices[1], Color4F(1.0f, 1.0f, 1.0f, 1.0f)); + _drawNode->drawLine(vertices[0], vertices[3], Color4F(1.0f, 1.0f, 1.0f, 1.0f)); + _drawNode->drawLine(vertices[2], vertices[3], Color4F(1.0f, 1.0f, 1.0f, 1.0f)); + _drawNode->drawLine(vertices[1], vertices[2], Color4F(1.0f, 1.0f, 1.0f, 1.0f)); } @@ -2756,7 +2756,7 @@ void LabelToggleTypeTest::initToggleCheckboxes() this->addChild(radioButton); auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20); - label->setPosition(radioButton->getPosition() + Vec2(50,0)); + label->setPosition(radioButton->getPosition() + Vec2(50.0f,0.0f)); this->addChild(label); } } @@ -2901,7 +2901,7 @@ void LabelSystemFontTest::initToggleCheckboxes() this->addChild(radioButton); auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20); - label->setPosition(radioButton->getPosition() + Vec2(50,0)); + label->setPosition(radioButton->getPosition() + Vec2(50.0f,0.0f)); this->addChild(label); } } @@ -3014,7 +3014,7 @@ LabelRichText::LabelRichText() if (richText2) { richText2->ignoreContentAdaptWithSize(false); - richText2->setContentSize(Size(400, 400)); + richText2->setContentSize(Size(400.0f, 400.0f)); richText2->setPosition(center); addChild(richText2); @@ -3300,7 +3300,7 @@ LabelLocalizationTest::LabelLocalizationTest() this->addChild(radioButton); auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20); - label->setPosition(radioButton->getPosition() + Vec2(50, 0)); + label->setPosition(radioButton->getPosition() + Vec2(50.0f, 0.0f)); this->addChild(label); } @@ -3309,18 +3309,18 @@ LabelLocalizationTest::LabelLocalizationTest() _label1->setPosition(Vec2(winSize.width / 2, winSize.height * 1 / 3)); Label * label = Label::createWithSystemFont("From json data :", "Arial", 24); - label->setAnchorPoint(Vec2(0, 0.5)); + label->setAnchorPoint(Vec2(0.0f, 0.5f)); addChild(label, 0); - label->setPosition(Vec2(20, winSize.height * 1 / 3 + 24)); + label->setPosition(Vec2(20.0f, winSize.height * 1 / 3 + 24)); _label2 = Label::createWithSystemFont(_localizationBin->getLocalizationString("Text Label"), "Arial", 24); addChild(_label2, 0); _label2->setPosition(Vec2(winSize.width / 2, winSize.height * 1 / 2)); label = Label::createWithSystemFont("From binary data :", "Arial", 24); - label->setAnchorPoint(Vec2(0, 0.5)); + label->setAnchorPoint(Vec2(0.0f, 0.5f)); addChild(label, 0); - label->setPosition(Vec2(20, winSize.height * 1 / 2 + 24)); + label->setPosition(Vec2(20.0f, winSize.height * 1 / 2 + 24)); } std::string LabelLocalizationTest::title() const @@ -3486,7 +3486,7 @@ LabelIssue16717::LabelIssue16717() { auto label = Label::createWithTTF("Hello World", "fonts/arial.ttf", 70); - label->setPosition(VisibleRect::center() + Vec2(0, 40)); + label->setPosition(VisibleRect::center() + Vec2(0.0f, 40.0f)); label->enableOutline(Color4B(0, 255, 0, 100), 10); // Set 100 alpha for outline label->setTextColor(Color4B(0, 0, 255, 100)); // Also set 100 alpha for text addChild(label); @@ -3494,7 +3494,7 @@ LabelIssue16717::LabelIssue16717() { auto label = Label::createWithTTF("Hello World", "fonts/arial.ttf", 70); - label->setPosition(VisibleRect::center() + Vec2(0, -40)); + label->setPosition(VisibleRect::center() + Vec2(0.0f, -40.0f)); label->enableOutline(Color4B(0, 255, 0, 100), 10); // Set 100 alpha for outline label->setTextColor(Color4B(0, 255, 0, 100)); // Also set 100 alpha for text addChild(label); diff --git a/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp b/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp index cd527cac9d..1bc88b56b6 100644 --- a/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp +++ b/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp @@ -132,7 +132,7 @@ void LayerTestCascadingOpacityB::onEnter() auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); - layer1->setPosition( Vec2(0, s.height/2)); + layer1->setPosition( Vec2(0.0f, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -143,9 +143,9 @@ void LayerTestCascadingOpacityB::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vec2( s.width*1/3, 0)); - sister2->setPosition( Vec2( s.width*2/3, 0)); - label->setPosition( Vec2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0.0f)); + sister2->setPosition( Vec2( s.width*2/3, 0.0f)); + label->setPosition( Vec2( s.width/2, 0.0f)); layer1->runAction( RepeatForever::create( @@ -185,7 +185,7 @@ void LayerTestCascadingOpacityC::onEnter() layer1->setCascadeColorEnabled(false); layer1->setCascadeOpacityEnabled(false); - layer1->setPosition( Vec2(0, s.height/2)); + layer1->setPosition( Vec2(0.0f, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -196,9 +196,9 @@ void LayerTestCascadingOpacityC::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vec2( s.width*1/3, 0)); - sister2->setPosition( Vec2( s.width*2/3, 0)); - label->setPosition( Vec2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0.0f)); + sister2->setPosition( Vec2( s.width*2/3, 0.0f)); + label->setPosition( Vec2( s.width/2, 0.0f)); layer1->runAction( RepeatForever::create( @@ -286,7 +286,7 @@ void LayerTestCascadingColorB::onEnter() auto s = Director::getInstance()->getWinSize(); auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); - layer1->setPosition( Vec2(0, s.height/2)); + layer1->setPosition( Vec2(0.0f, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -297,9 +297,9 @@ void LayerTestCascadingColorB::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vec2( s.width*1/3, 0)); - sister2->setPosition( Vec2( s.width*2/3, 0)); - label->setPosition( Vec2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0.0f)); + sister2->setPosition( Vec2( s.width*2/3, 0.0f)); + label->setPosition( Vec2( s.width/2, 0.0f)); layer1->runAction( RepeatForever::create( @@ -338,7 +338,7 @@ void LayerTestCascadingColorC::onEnter() auto s = Director::getInstance()->getWinSize(); auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); - layer1->setPosition( Vec2(0, s.height/2)); + layer1->setPosition( Vec2(0.0f, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); @@ -349,9 +349,9 @@ void LayerTestCascadingColorC::onEnter() layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); - sister1->setPosition( Vec2( s.width*1/3, 0)); - sister2->setPosition( Vec2( s.width*2/3, 0)); - label->setPosition( Vec2( s.width/2, 0)); + sister1->setPosition( Vec2( s.width*1/3, 0.0f)); + sister2->setPosition( Vec2( s.width*2/3, 0.0f)); + label->setPosition( Vec2( s.width/2, 0.0f)); layer1->runAction( RepeatForever::create( @@ -547,7 +547,7 @@ LayerGradientTest::LayerGradientTest() auto menu = Menu::create(item, nullptr); addChild(menu); auto s = Director::getInstance()->getWinSize(); - menu->setPosition(Vec2(s.width / 2, 100)); + menu->setPosition(Vec2(s.width / 2, 100.0f)); } void LayerGradientTest::toggleItem(Ref *sender) @@ -754,18 +754,18 @@ std::string LayerIgnoreAnchorPointScale::subtitle() const LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest() { auto layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255)); - layer1->setContentSize(Size(80, 80)); - layer1->setPosition(Vec2(50,50)); + layer1->setContentSize(Size(80.0f, 80.0f)); + layer1->setPosition(Vec2(50.0f,50.0f)); addChild(layer1); auto layer2 = LayerGradient::create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127)); - layer2->setContentSize(Size(80, 80)); - layer2->setPosition(Vec2(100,90)); + layer2->setContentSize(Size(80.0f, 80.0f)); + layer2->setPosition(Vec2(100.0f,90.0f)); addChild(layer2); auto layer3 = LayerGradient::create(); - layer3->setContentSize(Size(80, 80)); - layer3->setPosition(Vec2(150,140)); + layer3->setContentSize(Size(80.0f, 80.0f)); + layer3->setPosition(Vec2(150.0f,140.0f)); layer3->setStartColor(Color3B(255, 0, 0)); layer3->setEndColor(Color3B(255, 0, 255)); layer3->setStartOpacity(255); @@ -798,7 +798,7 @@ void LayerBug3162A::onEnter() { _layer[i] = LayerColor::create(color[i]); _layer[i]->setContentSize(size); - _layer[i]->setPosition(Vec2(size.width/2, size.height/2) - Vec2(20, 20)); + _layer[i]->setPosition(Vec2(size.width/2, size.height/2) - Vec2(20.0f, 20.0f)); _layer[i]->setOpacity(150); _layer[i]->setCascadeOpacityEnabled(true); if (i > 0) @@ -841,7 +841,7 @@ void LayerBug3162B::onEnter() { _layer[i] = LayerColor::create(color[i]); _layer[i]->setContentSize(size); - _layer[i]->setPosition(Vec2(size.width/2, size.height/2) - Vec2(20, 20)); + _layer[i]->setPosition(Vec2(size.width/2, size.height/2) - Vec2(20.0f, 20.0f)); //_layer[i]->setOpacity(150); if (i > 0) { @@ -920,11 +920,11 @@ void LayerRadialGradientTest::onEnter() addChild(_layer); auto scaleSlider = LayerRadialGradientTest::createSlider(); - scaleSlider->setPosition(Vec2(50, 130)); + scaleSlider->setPosition(Vec2(50.0f, 130.0f)); addChild(scaleSlider); auto listview = createListView(); - listview->setPosition(Vec2(100, 150)); + listview->setPosition(Vec2(100.0f, 150.0f)); addChild(listview); } diff --git a/tests/cpp-tests/Classes/LightTest/LightTest.cpp b/tests/cpp-tests/Classes/LightTest/LightTest.cpp index 4afe15cb65..26c449459d 100644 --- a/tests/cpp-tests/Classes/LightTest/LightTest.cpp +++ b/tests/cpp-tests/Classes/LightTest/LightTest.cpp @@ -43,8 +43,8 @@ LightTest::LightTest() auto s = Director::getInstance()->getWinSize(); auto camera = Camera::createPerspective(60, (float)s.width/s.height, 1.0f, 1000.0f); camera->setCameraFlag(CameraFlag::USER1); - camera->setPosition3D(Vec3(0.0, 100, 100)); - camera->lookAt(Vec3(0.0, 0.0, 0.0), Vec3(0.0, 1.0, 0.0)); + camera->setPosition3D(Vec3(0.0f, 100.0f, 100.0f)); + camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); addChild(camera); TTFConfig ttfConfig("fonts/arial.ttf", 15); @@ -120,8 +120,8 @@ void LightTest::addSprite() { std::string fileName = "Sprite3DTest/orc.c3b"; auto sprite = Sprite3D::create(fileName); - sprite->setRotation3D(Vec3(0.0, 180.0, 0.0)); - sprite->setPosition(Vec2(0.0, 0.0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + sprite->setPosition(Vec2(0.0f, 0.0f)); sprite->setScale(2.0); auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); sprite->getAttachNode("Bip001 R Hand")->addChild(sp); @@ -139,7 +139,7 @@ void LightTest::addSprite() { std::string fileName = "Sprite3DTest/sphere.c3b"; auto sprite = Sprite3D::create(fileName); - sprite->setPosition(Vec2(30.0, 0.0)); + sprite->setPosition(Vec2(30.0f, 0.0f)); addChild(sprite); sprite->setCameraMask(2); } @@ -148,7 +148,7 @@ void LightTest::addSprite() std::string fileName = "Sprite3DTest/sphere.c3b"; auto sprite = Sprite3D::create(fileName); sprite->setScale(0.5f); - sprite->setPosition(Vec2(-50.0, 0.0)); + sprite->setPosition(Vec2(-50.0f, 0.0f)); addChild(sprite); sprite->setCameraMask(2); } @@ -157,7 +157,7 @@ void LightTest::addSprite() std::string fileName = "Sprite3DTest/sphere.c3b"; auto sprite = Sprite3D::create(fileName); sprite->setScale(0.5f); - sprite->setPosition(Vec2(-30.0, 10.0)); + sprite->setPosition(Vec2(-30.0f, 10.0f)); addChild(sprite); sprite->setCameraMask(2); } diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index 24935b11f8..de0539305e 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -66,7 +66,7 @@ void Material_Sprite3DTest::onEnter() sprite->setScale(8.f); sprite->setTexture("Sprite3DTest/boss.png"); this->addChild(sprite); - sprite->setPositionNormalized(Vec2(0.5,0.5)); + sprite->setPositionNormalized(Vec2(0.5f,0.5f)); } std::string Material_Sprite3DTest::subtitle() const @@ -296,7 +296,7 @@ void Material_setTechnique::onEnter() auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); sprite->setScale(6); this->addChild(sprite); - sprite->setPositionNormalized(Vec2(0.5,0.5)); + sprite->setPositionNormalized(Vec2(0.5f,0.5f)); _sprite = sprite; @@ -313,7 +313,7 @@ void Material_setTechnique::onEnter() this->schedule(CC_CALLBACK_1(Material_setTechnique::changeMaterial, this), 1, "cookie"); _techniqueState = 0; - auto rot = RotateBy::create(5, Vec3(30,60,270)); + auto rot = RotateBy::create(5, Vec3(30.0f,60.0f,270.0f)); auto repeat = RepeatForever::create(rot); sprite->runAction(repeat); } @@ -354,12 +354,12 @@ void Material_clone::onEnter() auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); sprite->setScale(3); this->addChild(sprite); - sprite->setPositionNormalized(Vec2(0.25, 0.5)); + sprite->setPositionNormalized(Vec2(0.25f, 0.5f)); Material *mat = Material::createWithFilename("Materials/3d_effects.material"); sprite->setMaterial(mat); - auto rot = RotateBy::create(5, Vec3(360,240,120)); + auto rot = RotateBy::create(5, Vec3(360.0f,240.0f,120.0f)); auto repeat = RepeatForever::create(rot); sprite->runAction(repeat); @@ -367,7 +367,7 @@ void Material_clone::onEnter() auto sprite2 = Sprite3D::create("Sprite3DTest/boss1.obj"); sprite2->setScale(3); this->addChild(sprite2); - sprite2->setPositionNormalized(Vec2(0.5, 0.5)); + sprite2->setPositionNormalized(Vec2(0.5f, 0.5f)); sprite2->setMaterial(mat); sprite2->runAction(repeat->clone()); @@ -375,7 +375,7 @@ void Material_clone::onEnter() auto sprite3 = Sprite3D::create("Sprite3DTest/boss1.obj"); sprite3->setScale(3); this->addChild(sprite3); - sprite3->setPositionNormalized(Vec2(0.75, 0.5)); + sprite3->setPositionNormalized(Vec2(0.75f, 0.5f)); auto mat2 = mat->clone(); sprite3->setMaterial(mat2); sprite3->runAction(repeat->clone()); diff --git a/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp b/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp index 91cbad64c4..29ea7aa37d 100644 --- a/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp +++ b/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp @@ -127,7 +127,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() child->setPosition( Vec2( dstPoint.x + offset, dstPoint.y) ); child->runAction( - EaseElasticOut::create(MoveBy::create(2, Vec2(dstPoint.x - offset,0)), 0.35f) + EaseElasticOut::create(MoveBy::create(2, Vec2(dstPoint.x - offset,0.0f)), 0.35f) ); i++; } @@ -259,7 +259,7 @@ void MenuLayer2::alignMenusH() // TIP: if no padding, padding = 5 menu->alignItemsHorizontally(); auto p = menu->getPosition(); - menu->setPosition(p + Vec2(0,30)); + menu->setPosition(p + Vec2(0.0f,30.0f)); } else @@ -267,7 +267,7 @@ void MenuLayer2::alignMenusH() // TIP: but padding is configurable menu->alignItemsHorizontallyWithPadding(40); auto p = menu->getPosition(); - menu->setPosition(p - Vec2(0,30)); + menu->setPosition(p - Vec2(0.0f,30.0f)); } } } @@ -283,14 +283,14 @@ void MenuLayer2::alignMenusV() // TIP: if no padding, padding = 5 menu->alignItemsVertically(); auto p = menu->getPosition(); - menu->setPosition(p + Vec2(100,0)); + menu->setPosition(p + Vec2(100.0f,0.0f)); } else { // TIP: but padding is configurable menu->alignItemsVerticallyWithPadding(40); auto p = menu->getPosition(); - menu->setPosition(p - Vec2(100,0)); + menu->setPosition(p - Vec2(100.0f,0.0f)); } } } diff --git a/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp b/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp index 1d5f992907..b016c17898 100644 --- a/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/cpp-tests/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -61,7 +61,7 @@ void MotionStreakTest1::onEnter() // the target object is offset from root, and the streak is moved to follow it _target = Sprite::create(s_pathR1); _root->addChild(_target); - _target->setPosition(Vec2(s.width/4, 0)); + _target->setPosition(Vec2(s.width/4, 0.0f)); // create the streak object and add it to the scene _streak = MotionStreak::create(2, 3, 32, Color3B::GREEN, s_streak); diff --git a/tests/cpp-tests/Classes/MultiTouchTest/MultiTouchTest.cpp b/tests/cpp-tests/Classes/MultiTouchTest/MultiTouchTest.cpp index 764583b9aa..54cd482799 100644 --- a/tests/cpp-tests/Classes/MultiTouchTest/MultiTouchTest.cpp +++ b/tests/cpp-tests/Classes/MultiTouchTest/MultiTouchTest.cpp @@ -47,8 +47,8 @@ public: DrawNode* drawNode = DrawNode::create(); auto s = Director::getInstance()->getWinSize(); Color4F color(touchColor.r/255.0f, touchColor.g/255.0f, touchColor.b/255.0f, 1.0f); - drawNode->drawLine(Vec2(0, touchPoint.y), Vec2(s.width, touchPoint.y), color); - drawNode->drawLine(Vec2(touchPoint.x, 0), Vec2(touchPoint.x, s.height), color); + drawNode->drawLine(Vec2(0.0f, touchPoint.y), Vec2(s.width, touchPoint.y), color); + drawNode->drawLine(Vec2(touchPoint.x, 0.0f), Vec2(touchPoint.x, s.height), color); drawNode->drawDot(touchPoint, 3, color); addChild(drawNode); } @@ -74,7 +74,7 @@ bool MultiTouchTest::init() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto title = Label::createWithSystemFont("Please touch the screen!", "", 24); - title->setPosition(VisibleRect::top()+Vec2(0, -40)); + title->setPosition(VisibleRect::top()+Vec2(0.0f, -40.0f)); addChild(title); return true; diff --git a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp index 331e4460d9..a2b3254da7 100644 --- a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp +++ b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp @@ -29,7 +29,6 @@ using namespace cocos2d; using namespace cocos2d::ui; -using namespace cocos2d::experimental; AudioEngineTests::AudioEngineTests() { @@ -870,7 +869,7 @@ std::string AudioSwitchStateTest::title() const std::string AudioSwitchStateTest::subtitle() const { - return "Should not crash"; + return "Should not crash. No sound is ok"; } ///////////////////////////////////////////////////////////////////////// diff --git a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h index 5d9c30e988..ffcd11e7b9 100644 --- a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h +++ b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h @@ -111,7 +111,7 @@ public: private: static const int FILE_COUNT = 2; std::string _files[FILE_COUNT]; - cocos2d::experimental::AudioProfile _audioProfile; + cocos2d::AudioProfile _audioProfile; int _audioCount; cocos2d::Label* _showLabel; diff --git a/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp b/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp index 9ba95088db..fa1d97c419 100644 --- a/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp +++ b/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp @@ -75,7 +75,7 @@ void TouchableSpriteTest::onEnter() auto containerForSprite1 = Node::create(); auto sprite1 = Sprite::create("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 80)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 80.0f)); containerForSprite1->addChild(sprite1); addChild(containerForSprite1, 10); @@ -142,7 +142,7 @@ void TouchableSpriteTest::onEnter() }); nextItem->setFontSizeObj(16); - nextItem->setPosition(VisibleRect::right() + Vec2(-100, -30)); + nextItem->setPosition(VisibleRect::right() + Vec2(-100.0f, -30.0f)); auto menu2 = Menu::create(nextItem, nullptr); menu2->setPosition(Vec2(0, 0)); @@ -151,7 +151,7 @@ void TouchableSpriteTest::onEnter() }); removeAllTouchItem->setFontSizeObj(16); - removeAllTouchItem->setPosition(VisibleRect::right() + Vec2(-100, 0)); + removeAllTouchItem->setPosition(VisibleRect::right() + Vec2(-100.0f, 0.0f)); auto menu = Menu::create(removeAllTouchItem, nullptr); menu->setPosition(Vec2(0, 0)); @@ -271,7 +271,7 @@ void FixedPriorityTest::onEnter() auto sprite1 = TouchableSprite::create(30); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 40.0f)); addChild(sprite1, 10); auto sprite2 = TouchableSprite::create(20); @@ -356,10 +356,10 @@ void RemoveListenerWhenDispatching::onEnter() } }, MenuItemFont::create("Enabled"), MenuItemFont::create("Disabled"), nullptr); - toggleItem->setPosition(origin + Vec2(size.width/2, 80)); + toggleItem->setPosition(origin + Vec2(size.width/2, 80.0f)); auto menu = Menu::create(toggleItem, nullptr); - menu->setPosition(Vec2(0, 0)); - menu->setAnchorPoint(Vec2(0, 0)); + menu->setPosition(Vec2(0.0f, 0.0f)); + menu->setAnchorPoint(Vec2(0.0f, 0.0f)); addChild(menu, -1); } @@ -528,8 +528,8 @@ _pos = _max; \ ptNow.x += acc->x * 9.81f; ptNow.y += acc->y * 9.81f; - FIX_POS(ptNow.x, (VisibleRect::left().x+ballSize.width / 2.0), (VisibleRect::right().x - ballSize.width / 2.0)); - FIX_POS(ptNow.y, (VisibleRect::bottom().y+ballSize.height / 2.0), (VisibleRect::top().y - ballSize.height / 2.0)); + FIX_POS(ptNow.x, (VisibleRect::left().x+ballSize.width / 2.0), (VisibleRect::right().x - ballSize.width / 2.0f)); + FIX_POS(ptNow.y, (VisibleRect::bottom().y+ballSize.height / 2.0), (VisibleRect::top().y - ballSize.height / 2.0f)); sprite->setPosition(ptNow); }); @@ -650,13 +650,13 @@ void RemoveListenerAfterAddingTest::onEnter() _eventDispatcher->removeEventListener(listener); }); - item1->setPosition(VisibleRect::center() + Vec2(0, 80)); + item1->setPosition(VisibleRect::center() + Vec2(0.0f, 80.0f)); auto addNextButton = [this](){ auto next = MenuItemFont::create("Please Click Me To Reset!", [this](Ref* sender){ getTestSuite()->restartCurrTest(); }); - next->setPosition(VisibleRect::center() + Vec2(0, -40)); + next->setPosition(VisibleRect::center() + Vec2(0.0f, -40.0f)); auto menu = Menu::create(next, nullptr); menu->setPosition(VisibleRect::leftBottom()); @@ -677,7 +677,7 @@ void RemoveListenerAfterAddingTest::onEnter() addNextButton(); }); - item2->setPosition(VisibleRect::center() + Vec2(0, 40)); + item2->setPosition(VisibleRect::center() + Vec2(0.0f, 40.0f)); auto item3 = MenuItemFont::create("Click Me 3", [=](Ref* sender){ auto listener = EventListenerTouchOneByOne::create(); @@ -1073,7 +1073,7 @@ PauseResumeTargetTest::PauseResumeTargetTest() auto sprite1 = TouchableSprite::create(); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 40.0f)); addChild(sprite1, -10); auto sprite2 = TouchableSprite::create(); @@ -1143,7 +1143,7 @@ PauseResumeTargetTest2::PauseResumeTargetTest2() _touchableSprite = TouchableSprite::create(); _touchableSprite->retain(); _touchableSprite->setTexture("Images/CyanSquare.png"); - _touchableSprite->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); + _touchableSprite->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 40.0f)); addChild(_touchableSprite); _itemPauseTouch = MenuItemFont::create("pauseTouch", [=](Ref* sender){ @@ -1154,7 +1154,7 @@ PauseResumeTargetTest2::PauseResumeTargetTest2() }); _itemPauseTouch->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); - _itemPauseTouch->setPosition(VisibleRect::right() + Vec2(-150, 0)); + _itemPauseTouch->setPosition(VisibleRect::right() + Vec2(-150.0f, 0.0f)); _itemResumeTouch = MenuItemFont::create("resumeTouch", [=](Ref* sender){ _itemPauseTouch->setEnabled(true); @@ -1174,7 +1174,7 @@ PauseResumeTargetTest2::PauseResumeTargetTest2() }); _itemAddToScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); - _itemAddToScene->setPosition(VisibleRect::right() + Vec2(-150, -50)); + _itemAddToScene->setPosition(VisibleRect::right() + Vec2(-150.0f, -50.0f)); _itemRemoveFromScene = MenuItemFont::create("removeFromScene", [=](Ref* sender){ _itemAddToScene->setEnabled(true); @@ -1183,7 +1183,7 @@ PauseResumeTargetTest2::PauseResumeTargetTest2() }); _itemRemoveFromScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); - _itemRemoveFromScene->setPosition(VisibleRect::right() + Vec2(0, -50)); + _itemRemoveFromScene->setPosition(VisibleRect::right() + Vec2(0.0f, -50.0f)); _itemAddToScene->setEnabled(false); _itemResumeTouch->setEnabled(false); @@ -1223,7 +1223,7 @@ PauseResumeTargetTest3::PauseResumeTargetTest3() Size size = Director::getInstance()->getVisibleSize(); _touchableSprite = Sprite::create("Images/CyanSquare.png"); - _touchableSprite->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); + _touchableSprite->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 40.0f)); addChild(_touchableSprite); auto item = MenuItemFont::create("addListener", [=](Ref* sender){ @@ -1289,8 +1289,8 @@ Issue4129::Issue4129() _customlistener = _eventDispatcher->addCustomEventListener(EVENT_COME_TO_BACKGROUND, [this](EventCustom* event){ auto label = Label::createWithSystemFont("Yeah, this issue was fixed.", "", 20); - label->setAnchorPoint(Vec2(0, 0.5f)); - label->setPosition(Vec2(VisibleRect::left() + Vec2(0, 30))); + label->setAnchorPoint(Vec2(0.0f, 0.5f)); + label->setPosition(Vec2(VisibleRect::left() + Vec2(0.0f, 30.0f))); this->addChild(label); // After test, remove it. @@ -1312,7 +1312,7 @@ Issue4129::Issue4129() }); nextItem->setFontSizeObj(16); - nextItem->setPosition(VisibleRect::right() + Vec2(-100, -30)); + nextItem->setPosition(VisibleRect::right() + Vec2(-100.0f, -30.0f)); auto menu2 = Menu::create(nextItem, nullptr); menu2->setPosition(Vec2(0, 0)); @@ -1324,7 +1324,7 @@ Issue4129::Issue4129() }); removeAllTouchItem->setFontSizeObj(16); - removeAllTouchItem->setPosition(VisibleRect::right() + Vec2(-100, 0)); + removeAllTouchItem->setPosition(VisibleRect::right() + Vec2(-100.0f, 0.0f)); auto menu = Menu::create(removeAllTouchItem, nullptr); menu->setPosition(Vec2(0, 0)); @@ -1358,7 +1358,7 @@ Issue4160::Issue4160() auto sprite1 = TouchableSprite::create(-30); sprite1->setTexture("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 40)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 40.0f)); addChild(sprite1, -10); auto sprite2 = TouchableSprite::create(-20); diff --git a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp index 057a1e3c04..476fb637b6 100644 --- a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp +++ b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp @@ -26,6 +26,8 @@ #include "NewRendererTest.h" #include #include +#include "renderer/backend/Device.h" + USING_NS_CC; class DurationRecorder { @@ -44,7 +46,7 @@ public: else if(itr->second < 0) { itr->second = n + itr->second; } - return itr->second; + return static_cast(itr->second); } inline int64_t now() const{ @@ -237,8 +239,8 @@ NewClippingNodeTest::NewClippingNodeTest() auto clipper = ClippingNode::create(); clipper->setTag( kTagClipperNode ); - clipper->setContentSize( Size(200, 200) ); - clipper->setAnchorPoint( Vec2(0.5, 0.5) ); + clipper->setContentSize( Size(200.0f, 200.0f) ); + clipper->setAnchorPoint( Vec2(0.5f, 0.5f) ); clipper->setPosition( Vec2(s.width / 2, s.height / 2) ); clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); @@ -264,7 +266,7 @@ NewClippingNodeTest::NewClippingNodeTest() auto content = Sprite::create("Images/background2.png"); content->setTag( kTagContentNode ); - content->setAnchorPoint( Vec2(0.5, 0.5) ); + content->setAnchorPoint( Vec2(0.5f, 0.5f) ); content->setPosition( Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); clipper->addChild(content); @@ -620,13 +622,13 @@ CaptureScreenTest::CaptureScreenTest() auto sp1 = Sprite::create("Images/grossini.png"); sp1->setPosition(left); - auto move1 = MoveBy::create(1, Vec2(s.width/2, 0)); + auto move1 = MoveBy::create(1, Vec2(s.width/2, 0.0f)); auto seq1 = RepeatForever::create(Sequence::create(move1, move1->reverse(), nullptr)); addChild(sp1); sp1->runAction(seq1); auto sp2 = Sprite::create("Images/grossinis_sister1.png"); sp2->setPosition(right); - auto move2 = MoveBy::create(1, Vec2(-s.width/2, 0)); + auto move2 = MoveBy::create(1, Vec2(-s.width/2, 0.0f)); auto seq2 = RepeatForever::create(Sequence::create(move2, move2->reverse(), nullptr)); addChild(sp2); sp2->runAction(seq2); @@ -693,13 +695,13 @@ CaptureNodeTest::CaptureNodeTest() auto sp1 = Sprite::create("Images/grossini.png"); sp1->setPosition(left); - auto move1 = MoveBy::create(1, Vec2(s.width / 2, 0)); + auto move1 = MoveBy::create(1, Vec2(s.width / 2, 0.0f)); auto seq1 = RepeatForever::create(Sequence::create(move1, move1->reverse(), nullptr)); addChild(sp1); sp1->runAction(seq1); auto sp2 = Sprite::create("Images/grossinis_sister1.png"); sp2->setPosition(right); - auto move2 = MoveBy::create(1, Vec2(-s.width / 2, 0)); + auto move2 = MoveBy::create(1, Vec2(-s.width / 2, 0.0f)); auto seq2 = RepeatForever::create(Sequence::create(move2, move2->reverse(), nullptr)); addChild(sp2); sp2->runAction(seq2); @@ -757,7 +759,7 @@ void CaptureNodeTest::onCaptured(Ref*) BugAutoCulling::BugAutoCulling() { Size s = Director::getInstance()->getWinSize(); - auto fastmap = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); + auto fastmap = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); this->addChild(fastmap); for (int i = 0; i < 30; i++) { auto sprite = Sprite::create("Images/grossini.png"); @@ -769,7 +771,7 @@ BugAutoCulling::BugAutoCulling() } this->scheduleOnce([=](float){ auto camera = Director::getInstance()->getRunningScene()->getCameras().front(); - auto move = MoveBy::create(2.0, Vec2(2 * s.width, 0)); + auto move = MoveBy::create(2.0f, Vec2(2 * s.width, 0.0f)); camera->runAction(Sequence::create(move, move->reverse(),nullptr)); }, 1.0f, "lambda-autoculling-bug"); } @@ -803,7 +805,7 @@ RendererBatchQuadTri::RendererBatchQuadTri() addChild(label); auto sprite = Sprite::create("fonts/tuffy_bold_italic-charmap.png"); - sprite->setTextureRect(Rect(0,0,100,100)); + sprite->setTextureRect(Rect(0.0f,0.0f,100.0f,100.0f)); sprite->setPosition(Vec2(x,y)); sprite->setColor(Color3B::BLUE); addChild(sprite); @@ -861,9 +863,10 @@ cocos2d::backend::ProgramState* RendererUniformBatch::createBlurProgramState() auto fileUtiles = FileUtils::getInstance(); auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName); auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); - auto programState = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str()); - - + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource.c_str()); + auto programState = new backend::ProgramState(program); + programState->autorelease(); + CC_SAFE_RELEASE(program); backend::UniformLocation loc = programState->getUniformLocation("resolution"); auto resolution = Vec2(85, 121); @@ -888,9 +891,11 @@ cocos2d::backend::ProgramState* RendererUniformBatch::createSepiaProgramState() auto fileUtiles = FileUtils::getInstance(); auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName); auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); - auto glprogram = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str()); - - return glprogram; + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource.c_str()); + auto programState = new backend::ProgramState(program); + programState->autorelease(); + CC_SAFE_RELEASE(program); + return programState; } std::string RendererUniformBatch::title() const @@ -944,8 +949,10 @@ backend::ProgramState* RendererUniformBatch2::createBlurProgramState() auto fileUtiles = FileUtils::getInstance(); auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName); auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); - - auto programState = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str()); + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource.c_str()); + auto programState = new backend::ProgramState(program); + programState->autorelease(); + CC_SAFE_RELEASE(program); backend::UniformLocation loc = programState->getUniformLocation("resolution"); auto resolution = Vec2(85, 121); @@ -970,9 +977,11 @@ backend::ProgramState* RendererUniformBatch2::createSepiaProgramState() auto fileUtiles = FileUtils::getInstance(); auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName); auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); - auto glprogram = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str()); - - return glprogram; + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource.c_str()); + auto programState = new backend::ProgramState(program); + programState->autorelease(); + CC_SAFE_RELEASE(program); + return programState; } std::string RendererUniformBatch2::title() const diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index d5f19383d4..b0cd647d62 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -47,10 +47,9 @@ enum CocosNodeTests::CocosNodeTests() { - //ADD_TEST_CASE(CameraTest1); - // TODO: Camera has been removed from CCNode; add new feature to support it - // ADD_TEST_CASE(CameraTest2); - //ADD_TEST_CASE(CameraCenterTest); + ADD_TEST_CASE(CameraTest1); + ADD_TEST_CASE(CameraTest2); + ADD_TEST_CASE(CameraCenterTest); ADD_TEST_CASE(NodeTest2); ADD_TEST_CASE(NodeTest4); ADD_TEST_CASE(NodeTest5); @@ -106,8 +105,8 @@ void NodeTest2::onEnter() auto sp3 = Sprite::create(s_pathSister1); auto sp4 = Sprite::create(s_pathSister2); - sp1->setPosition(Vec2(100, s.height /2 )); - sp2->setPosition(Vec2(380, s.height /2 )); + sp1->setPosition(Vec2(100.0f, s.height /2 )); + sp2->setPosition(Vec2(380.0f, s.height /2 )); addChild(sp1); addChild(sp2); @@ -192,10 +191,10 @@ NodeTest5::NodeTest5() auto sp1 = Sprite::create(s_pathSister1); auto sp2 = Sprite::create(s_pathSister2); - sp1->setPosition(Vec2(100,160)); - sp2->setPosition(Vec2(380,160)); + sp1->setPosition(Vec2(100.0f,160.0f)); + sp2->setPosition(Vec2(380.0f,160.0f)); - auto rot = RotateBy::create(2, 360); + auto rot = RotateBy::create(2.0f, 360.0f); auto rot_back = rot->reverse(); auto forever = RepeatForever::create(Sequence::create(rot, rot_back, nullptr)); auto forever2 = forever->clone(); @@ -247,10 +246,10 @@ NodeTest6::NodeTest6() auto sp2 = Sprite::create(s_pathSister2); auto sp21 = Sprite::create(s_pathSister2); - sp1->setPosition(Vec2(100,160)); - sp2->setPosition(Vec2(380,160)); + sp1->setPosition(Vec2(100.0f,160.0f)); + sp2->setPosition(Vec2(380.0f,160.0f)); - auto rot = RotateBy::create(2, 360); + auto rot = RotateBy::create(2.0f, 360.0f); auto rot_back = rot->reverse(); auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, nullptr)); auto forever11 = forever1->clone(); @@ -360,9 +359,9 @@ StressTest2::StressTest2() auto sublayer = Layer::create(); auto sp1 = Sprite::create(s_pathSister1); - sp1->setPosition( Vec2(80, s.height/2) ); + sp1->setPosition( Vec2(80.0f, s.height/2) ); - auto move = MoveBy::create(3, Vec2(350,0)); + auto move = MoveBy::create(3, Vec2(350.0f,0.0f)); auto move_ease_inout3 = EaseInOut::create(move->clone(), 2.0f); auto move_ease_inout_back3 = move_ease_inout3->reverse(); auto seq3 = Sequence::create( move_ease_inout3, move_ease_inout_back3, nullptr); @@ -371,7 +370,7 @@ StressTest2::StressTest2() auto fire = ParticleFire::create(); fire->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); - fire->setPosition( Vec2(80, s.height/2-50) ); + fire->setPosition( Vec2(80.0f, s.height/2-50) ); auto copy_seq3 = seq3->clone(); @@ -489,11 +488,11 @@ NodeToWorld::NodeToWorld() menu->setPosition( Vec2(backSize.width/2, backSize.height/2)); back->addChild(menu); - auto rot = RotateBy::create(5, 360); + auto rot = RotateBy::create(5.0f, 360.0f); auto fe = RepeatForever::create( rot); item->runAction( fe ); - auto move = MoveBy::create(3, Vec2(200,0)); + auto move = MoveBy::create(3.0f, Vec2(200.0f,0.0f)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, nullptr); auto fe2 = RepeatForever::create(seq); @@ -520,13 +519,13 @@ NodeToWorld3D::NodeToWorld3D() Size s = Director::getInstance()->getWinSize(); auto parent = Node::create(); parent->setContentSize(s); - parent->setAnchorPoint(Vec2(0.5, 0.5)); + parent->setAnchorPoint(Vec2(0.5f, 0.5f)); parent->setPosition(s.width/2, s.height/2); this->addChild(parent); auto back = Sprite::create(s_back3); parent->addChild( back, -10); - back->setAnchorPoint( Vec2(0,0) ); + back->setAnchorPoint( Vec2(0.0f,0.0f) ); auto backSize = back->getContentSize(); auto item = MenuItemImage::create(s_PlayNormal, s_PlaySelect); @@ -539,7 +538,7 @@ NodeToWorld3D::NodeToWorld3D() auto fe = RepeatForever::create( rot); item->runAction( fe ); - auto move = MoveBy::create(3, Vec2(200,0)); + auto move = MoveBy::create(3, Vec2(200.0f,0.0f)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, nullptr); auto fe2 = RepeatForever::create(seq); @@ -729,8 +728,8 @@ CameraCenterTest::CameraCenterTest() addChild( sprite, 0); sprite->setPosition(Vec2(s.width/5*1, s.height/5*1)); sprite->setColor(Color3B::RED); - sprite->setTextureRect(Rect(0, 0, 120, 50)); - orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->setTextureRect(Rect(0.0f, 0.0f, 120.0f, 50.0f)); + orbit = OrbitCamera::create(10.0f, 1.0f, 0.0f, 0.0f, 360.0f, 0.0f, 0.0f); sprite->runAction(RepeatForever::create( orbit )); // [sprite setAnchorPoint: Vec2(0,1)); @@ -741,8 +740,8 @@ CameraCenterTest::CameraCenterTest() addChild( sprite, 0, 40); sprite->setPosition(Vec2(s.width/5*1, s.height/5*4)); sprite->setColor(Color3B::BLUE); - sprite->setTextureRect(Rect(0, 0, 120, 50)); - orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->setTextureRect(Rect(0.0f, 0.0f, 120.0f, 50.0f)); + orbit = OrbitCamera::create(10.0f, 1.0f, 0.0f, 0.0f, 360.0f, 0.0f, 0.0f); sprite->runAction(RepeatForever::create( orbit )); @@ -751,8 +750,8 @@ CameraCenterTest::CameraCenterTest() addChild( sprite, 0); sprite->setPosition(Vec2(s.width/5*4, s.height/5*1)); sprite->setColor(Color3B::YELLOW); - sprite->setTextureRect(Rect(0, 0, 120, 50)); - orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->setTextureRect(Rect(0.0f, 0.0f, 120.0f, 50.0f)); + orbit = OrbitCamera::create(10.0f, 1.0f, 0.0f, 0.0f, 360.0f, 0.0f, 0.0f); sprite->runAction(RepeatForever::create( orbit) ); @@ -761,8 +760,8 @@ CameraCenterTest::CameraCenterTest() addChild( sprite, 0, 40); sprite->setPosition(Vec2(s.width/5*4, s.height/5*4)); sprite->setColor(Color3B::GREEN); - sprite->setTextureRect(Rect(0, 0, 120, 50)); - orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->setTextureRect(Rect(0.0f, 0.0f, 120.0f, 50.0f)); + orbit = OrbitCamera::create(10.0f, 1.0f, 0.0f, 0.0f, 360.0f, 0.0f, 0.0f); sprite->runAction( RepeatForever::create( orbit ) ); // CENTER @@ -770,8 +769,8 @@ CameraCenterTest::CameraCenterTest() addChild( sprite, 0, 40); sprite->setPosition(Vec2(s.width/2, s.height/2)); sprite->setColor(Color3B::WHITE); - sprite->setTextureRect(Rect(0, 0, 120, 50)); - orbit = OrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->setTextureRect(Rect(0.0f, 0.0f, 120.0f, 50.0f)); + orbit = OrbitCamera::create(10.0f, 1.0f, 0.0f, 0.0f, 360.0f, 0.0f, 0.0f); sprite->runAction(RepeatForever::create( orbit ) ); } @@ -970,61 +969,41 @@ public: auto sprite = new (std::nothrow) MySprite; sprite->initWithFile(spritefilename); sprite->autorelease(); - -// auto shaderState = GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); -// sprite->setGLProgramState(shaderState); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR); + auto programState = new (std::nothrow) backend::ProgramState(program); + programState->autorelease(); + sprite->setProgramState(programState); return sprite; } + virtual void setProgramState(backend::ProgramState* programState) override; virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; - void onDraw(const Mat4 &transform, uint32_t flags); protected: CustomCommand _customCommand; }; +void MySprite::setProgramState(backend::ProgramState* programState) +{ + Sprite::setProgramState(programState); + auto& pipelineDescriptor = _customCommand.getPipelineDescriptor(); + pipelineDescriptor.programState = programState; + + _customCommand.setDrawType(CustomCommand::DrawType::ARRAY); + _customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP); + _customCommand.createVertexBuffer(sizeof(V3F_C4B_T2F), 4, CustomCommand::BufferUsage::STATIC); + _customCommand.updateVertexBuffer(&_quad, 4*sizeof(V3F_C4B_T2F)); +} + void MySprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { + const auto& projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + auto mvpMatrix = projectionMat * transform; + _customCommand.getPipelineDescriptor().programState->setUniform(_mvpMatrixLocation, mvpMatrix.m, sizeof(mvpMatrix.m)); _customCommand.init(_globalZOrder, transform, flags); - _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void MySprite::onDraw(const Mat4 &transform, uint32_t flags) -{ -// getGLProgram()->use(); -// getGLProgram()->setUniformsForBuiltins(transform); - -// cocos2d::utils::setBlending(_blendFunc.src, _blendFunc.dst); - -// glActiveTexture(GL_TEXTURE0); -// glBindTexture(GL_TEXTURE_2D, _texture->getName()); - -// glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); -// glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD); -// glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); - - #define kQuadSize sizeof(_quad.bl) -// size_t offset = (size_t)&_quad; - - // vertex - int diff = offsetof( V3F_C4B_T2F, vertices); -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - - // texCoords - diff = offsetof( V3F_C4B_T2F, texCoords); -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - - // color - diff = offsetof( V3F_C4B_T2F, colors); -// glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); - - //TODO coulsonwang -// glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); -// -// CHECK_GL_ERROR_DEBUG(); - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4); -} //------------------------------------------------------------------ // // CameraTest1 @@ -1144,11 +1123,11 @@ NodeNormalizedPositionTest1::NodeNormalizedPositionTest1() { Sprite *sprites[5]; Vec2 positions[5]; - positions[0] = Vec2(0,0); - positions[1] = Vec2(0,1); - positions[2] = Vec2(0.5,0.5); - positions[3] = Vec2(1,0); - positions[4] = Vec2(1,1); + positions[0] = Vec2(0.0f,0.0f); + positions[1] = Vec2(0.0f,1.0f); + positions[2] = Vec2(0.5f,0.5f); + positions[3] = Vec2(1.0f,0.0f); + positions[4] = Vec2(1.0f,1.0f); for(int i=0; i<5; i++) { sprites[i] = Sprite::create("Images/grossini.png"); @@ -1177,11 +1156,11 @@ NodeNormalizedPositionTest2::NodeNormalizedPositionTest2() { Sprite *sprites[5]; Vec2 positions[5]; - positions[0] = Vec2(0,0); - positions[1] = Vec2(0,1); - positions[2] = Vec2(0.5,0.5); - positions[3] = Vec2(1,0); - positions[4] = Vec2(1,1); + positions[0] = Vec2(0.0f,0.0f); + positions[1] = Vec2(0.0f,1.0f); + positions[2] = Vec2(0.5f,0.5f); + positions[3] = Vec2(1.0f,0.0f); + positions[4] = Vec2(1.0f,1.0f); for(int i=0; i<5; i++) { sprites[i] = Sprite::create("Images/grossini.png"); @@ -1230,7 +1209,7 @@ NodeNormalizedPositionBugTest::NodeNormalizedPositionBugTest() { Vec2 position; - position = Vec2(0.5,0.5); + position = Vec2(0.5f,0.5f); sprite = Sprite::create("Images/grossini.png"); @@ -1395,14 +1374,14 @@ void NodeNameTest::test(float dt) // search from parent // name is xxx/.. i = 0; - parent->enumerateChildren("node/..", [&i](Node* node) -> bool { + parent->getChildByName("node1")->enumerateChildren("node[[:digit:]]+/node/..", [&i](Node* node) -> bool { ++i; return true; }); CCAssert(i == 1, ""); i = 0; - parent->enumerateChildren("node/..", [&i](Node* node) -> bool { + parent->getChildByName("node1")->enumerateChildren("node[[:digit:]]+/node/..", [&i](Node* node) -> bool { ++i; return false; }); @@ -1441,11 +1420,11 @@ void NodeNameTest::test(float dt) CCAssert(i == 1, ""); i = 0; - parent->enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool { + parent->getChildByName("node1")->enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool { ++i; return false; }); - CCAssert(i == 100, ""); + CCAssert(i == 110, ""); // utils::findChildren() @@ -1486,7 +1465,7 @@ void Issue16100Test::onEnter() this->addChild(sprite); sprite->setPosition(-200,s.height/3); - auto moveby = MoveBy::create(2, Vec2(400,0)); + auto moveby = MoveBy::create(2, Vec2(400.0f,0.0f)); auto movebyback = moveby->reverse(); auto seq = Sequence::create(moveby, movebyback, nullptr); auto forever = RepeatForever::create(seq); @@ -1501,7 +1480,7 @@ void Issue16100Test::onEnter() this->addChild(sister); sister->setPosition(-200,s.height*2/3); - auto moveby1 = MoveBy::create(2, Vec2(400,0)); + auto moveby1 = MoveBy::create(2, Vec2(400.0f,0.0f)); auto movebyback1 = moveby1->reverse(); auto seq1 = Sequence::create(moveby1, movebyback1, nullptr); auto forever1 = RepeatForever::create(seq1); diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp index f62e1e7ffe..c22299983a 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp @@ -71,7 +71,7 @@ void DemoFire::onEnter() _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) );//.pvr"); auto p = _emitter->getPosition(); - _emitter->setPosition( Vec2(p.x, 100) ); + _emitter->setPosition( Vec2(p.x, 100.0f) ); setEmitterPosition(); } @@ -439,7 +439,7 @@ void DemoSmoke::onEnter() _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); auto p = _emitter->getPosition(); - _emitter->setPosition( Vec2( p.x, 100) ); + _emitter->setPosition( Vec2( p.x, 100.0f) ); setEmitterPosition(); } @@ -468,7 +468,7 @@ void DemoSnow::onEnter() _emitter->setLifeVar(1); // gravity - _emitter->setGravity(Vec2(0,-10)); + _emitter->setGravity(Vec2(0.0f,-10.0f)); // speed of particles _emitter->setSpeed(130); @@ -547,7 +547,7 @@ void DemoModernArt::onEnter() _emitter->setDuration(-1); // gravity - _emitter->setGravity(Vec2(0,0)); + _emitter->setGravity(Vec2(0.0f,0.0f)); // angle _emitter->setAngle(0); @@ -656,8 +656,8 @@ void ParallaxParticle::onEnter() auto p1 = Sprite::create(s_back3); auto p2 = Sprite::create(s_back3); - p->addChild( p1, 1, Vec2(0.5f,1), Vec2(0,250) ); - p->addChild(p2, 2, Vec2(1.5f,1), Vec2(0,50) ); + p->addChild( p1, 1, Vec2(0.5f,1.0f), Vec2(0.0f,250.0f) ); + p->addChild(p2, 2, Vec2(1.5f,1.0f), Vec2(0.0f,50.0f) ); _emitter = ParticleFlower::create(); _emitter->retain(); @@ -670,7 +670,7 @@ void ParallaxParticle::onEnter() p2->addChild(par, 10); par->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - auto move = MoveBy::create(4, Vec2(300,0)); + auto move = MoveBy::create(4, Vec2(300.0f,0.0f)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, nullptr); p->runAction(RepeatForever::create(seq)); @@ -1115,7 +1115,7 @@ void ParticleDemo::onEnter() auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); - labelAtlas->setPosition(Vec2(s.width-66,50)); + labelAtlas->setPosition(Vec2(s.width-66,50.0f)); // moving background _background = Sprite::create(s_back3); @@ -1406,7 +1406,7 @@ bool RainbowEffect::initWithTotalParticles(int numberOfParticles) setEmitterMode(ParticleSystem::Mode::GRAVITY); // Gravity Mode: gravity - setGravity(Vec2(0,0)); + setGravity(Vec2(0.0f,0.0f)); // Gravity mode: radial acceleration setRadialAccel(0); @@ -1508,7 +1508,7 @@ void MultipleParticleSystems::onEnter() for (int i = 0; i<5; i++) { auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); - particleSystem->setPosition(Vec2(i*50 ,i*50)); + particleSystem->setPosition(Vec2(i*50.0f,i*50.0f)); particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); addChild(particleSystem); @@ -1566,7 +1566,7 @@ void MultipleParticleSystemsBatched::onEnter() auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); - particleSystem->setPosition(Vec2(i*50 ,i*50)); + particleSystem->setPosition(Vec2(i*50.0f,i*50.0f)); batchNode->setTexture(particleSystem->getTexture()); batchNode->addChild(particleSystem); @@ -1628,7 +1628,7 @@ void AddAndDeleteParticleSystems::onEnter() particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setTotalParticles(200); - particleSystem->setPosition(Vec2(i*15 +100,i*15+100)); + particleSystem->setPosition(Vec2(i*15 +100.0f,i*15+100.0f)); unsigned int randZ = rand() % 100; _batchNode->addChild(particleSystem, randZ, -1); @@ -1774,7 +1774,7 @@ void ReorderParticleSystems::onEnter() // additive - particleSystem->setPosition(Vec2(i*10+120 ,200)); + particleSystem->setPosition(Vec2(i*10+120.0f,200.0f)); _batchNode->addChild(particleSystem); diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp index afe1993be7..9d530d4177 100644 --- a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp @@ -176,9 +176,7 @@ void Physics3DTestDemo::onTouchesEnded(const std::vector& touches, cocos } } -Physics3DTestDemo::Physics3DTestDemo( void ) -: _angle(0.0f) -, _camera(nullptr) +Physics3DTestDemo::Physics3DTestDemo() { } @@ -188,7 +186,7 @@ void Physics3DTestDemo::update( float /*delta*/ ) } -Physics3DTestDemo::~Physics3DTestDemo( void ) +Physics3DTestDemo::~Physics3DTestDemo() { } diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h index 2bdf5150d7..a53773cb83 100644 --- a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h @@ -68,9 +68,9 @@ protected: protected: std::string _title; - cocos2d::Camera *_camera; - float _angle; - bool _needShootBox; + cocos2d::Camera *_camera = nullptr; + float _angle = 0.f; + bool _needShootBox = false; }; class BasicPhysics3DDemo : public Physics3DTestDemo diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index 06c447458a..1ee4b61928 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -249,7 +249,7 @@ Sprite* PhysicsDemo::makeTriangle(Vec2 point, Size size, int color, PhysicsMater triangle->setScaleY(size.height / 43.5f); } - Vec2 vers[] = { Vec2(0, triangle->getContentSize().height / 2), Vec2(triangle->getContentSize().width / 2, -triangle->getContentSize().height / 2), Vec2(-triangle->getContentSize().width / 2, -triangle->getContentSize().height / 2) }; + Vec2 vers[] = { Vec2(0.0f, triangle->getContentSize().height / 2), Vec2(triangle->getContentSize().width / 2, -triangle->getContentSize().height / 2), Vec2(-triangle->getContentSize().width / 2, -triangle->getContentSize().height / 2) }; triangle->addComponent(PhysicsBody::createPolygon(vers, 3, material)); triangle->setPosition(Vec2(point.x, point.y)); @@ -318,7 +318,7 @@ void PhysicsDemoLogoSmash::onEnter() { PhysicsDemo::onEnter(); - _physicsWorld->setGravity(Vec2(0, 0)); + _physicsWorld->setGravity(Vec2(0.0f, 0.0f)); _physicsWorld->setUpdateRate(5.0f); _ball = SpriteBatchNode::create("Images/ball.png", sizeof(LOGO_IMAGE)/sizeof(LOGO_IMAGE[0])); @@ -346,10 +346,10 @@ void PhysicsDemoLogoSmash::onEnter() } - auto bullet = makeBall(Vec2(400, 0), 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); - bullet->getPhysicsBody()->setVelocity(Vec2(200, 0)); + auto bullet = makeBall(Vec2(400.0f, 0.0f), 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); + bullet->getPhysicsBody()->setVelocity(Vec2(200.0f, 0.0f)); - bullet->setPosition(Vec2(-500, VisibleRect::getVisibleRect().size.height/2)); + bullet->setPosition(Vec2(-500.0f, VisibleRect::getVisibleRect().size.height/2)); _ball->addChild(bullet); } @@ -432,8 +432,8 @@ void PhysicsDemoPyramidStack::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto node = Node::create(); - node->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), - VisibleRect::rightBottom() + Vec2(0, 50))); + node->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0.0f, 50.0f), + VisibleRect::rightBottom() + Vec2(0.0f, 50.0f))); this->addChild(node); auto ball = Sprite::create("Images/ball.png"); @@ -442,7 +442,7 @@ void PhysicsDemoPyramidStack::onEnter() auto body = PhysicsBody::createCircle(10); ball->addComponent(body); body->setTag(DRAG_BODYS_TAG); - ball->setPosition(VisibleRect::bottom() + Vec2(0, 60)); + ball->setPosition(VisibleRect::bottom() + Vec2(0.0f, 60.0f)); this->addChild(ball); scheduleOnce(CC_SCHEDULE_SELECTOR(PhysicsDemoPyramidStack::updateOnce), 3.0); @@ -486,8 +486,8 @@ void PhysicsDemoRayCast::onEnter() _physicsWorld->setGravity(Point::ZERO); auto node = DrawNode::create(); - node->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); - node->drawSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50), 1, STATIC_COLOR); + node->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0.0f, 50.0f), VisibleRect::rightBottom() + Vec2(0.0f, 50.0f))); + node->drawSegment(VisibleRect::leftBottom() + Vec2(0.0f, 50.0f), VisibleRect::rightBottom() + Vec2(0.0f, 50.0f), 1, STATIC_COLOR); this->addChild(node); MenuItemFont::setFontSize(18); @@ -664,9 +664,9 @@ void PhysicsDemoActions::onEnter() this->addChild(node); Sprite* sp1 = addGrossiniAtPosition(VisibleRect::center()); - Sprite* sp2 = addGrossiniAtPosition(VisibleRect::left() + Vec2(50, 0)); - Sprite* sp3 = addGrossiniAtPosition(VisibleRect::right() - Vec2(20, 0)); - Sprite* sp4 = addGrossiniAtPosition(VisibleRect::leftTop() + Vec2(50, -50)); + Sprite* sp2 = addGrossiniAtPosition(VisibleRect::left() + Vec2(50.0f, 0.0f)); + Sprite* sp3 = addGrossiniAtPosition(VisibleRect::right() - Vec2(20.0f, 0.0f)); + Sprite* sp4 = addGrossiniAtPosition(VisibleRect::leftTop() + Vec2(50.0f, -50.0f)); sp4->getPhysicsBody()->setGravityEnable(false); sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); @@ -746,11 +746,11 @@ void PhysicsDemoJoints::onEnter() case 1: { - auto sp1 = makeBall(offset - Vec2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30.0f, 0.0f), 10); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -763,11 +763,11 @@ void PhysicsDemoJoints::onEnter() } case 2: { - auto sp1 = makeBall(offset - Vec2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30.0f, 0.0f), 10); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -780,11 +780,11 @@ void PhysicsDemoJoints::onEnter() } case 3: { - auto sp1 = makeBall(offset - Vec2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30.0f, 0.0f), 10); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -797,11 +797,11 @@ void PhysicsDemoJoints::onEnter() } case 4: { - auto sp1 = makeBall(offset - Vec2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30.0f, 0.0f), 10); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -814,15 +814,15 @@ void PhysicsDemoJoints::onEnter() } case 5: { - auto sp1 = makeBall(offset - Vec2(30, 0), 10); + auto sp1 = makeBall(offset - Vec2(30.0f, 0.0f), 10); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1PhysicsBody, sp2PhysicsBody, Vec2(30, 15), Vec2(30, -15), Vec2(-30, 0)); + PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1PhysicsBody, sp2PhysicsBody, Vec2(30.0f, 15.0f), Vec2(30.0f, -15.0f), Vec2(-30.0f, 0.0f)); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -831,11 +831,11 @@ void PhysicsDemoJoints::onEnter() } case 6: { - auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -850,11 +850,11 @@ void PhysicsDemoJoints::onEnter() } case 7: { - auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -869,11 +869,11 @@ void PhysicsDemoJoints::onEnter() } case 8: { - auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -888,11 +888,11 @@ void PhysicsDemoJoints::onEnter() } case 9: { - auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -907,11 +907,11 @@ void PhysicsDemoJoints::onEnter() } case 10: { - auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); + auto sp1 = makeBox(offset - Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp1PhysicsBody = sp1->getPhysicsBody(); sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2 = makeBox(offset + Vec2(30.0f, 0.0f), Size(30.0f, 10.0f)); auto sp2PhysicsBody = sp2->getPhysicsBody(); sp2PhysicsBody->setTag(DRAG_BODYS_TAG); @@ -971,7 +971,7 @@ void PhysicsDemoPump::onEnter() // balls for (int i = 0; i < 6; ++i) { - auto ball = makeBall(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0), 22, PhysicsMaterial(0.05f, 0.0f, 0.1f)); + auto ball = makeBall(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0.0f), 22, PhysicsMaterial(0.05f, 0.0f, 0.1f)); ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(ball); } @@ -1001,18 +1001,18 @@ void PhysicsDemoPump::onEnter() sgearBody->setTag(1); auto sgear = Node::create(); sgear->addComponent(sgearBody); - sgear->setPosition(VisibleRect::leftBottom() + Vec2(125, 0)); + sgear->setPosition(VisibleRect::leftBottom() + Vec2(125.0f, 0.0f)); this->addChild(sgear); _physicsWorld->addJoint(PhysicsJointPin::construct(nodeBody, sgearBody, sgear->getPosition())); - _physicsWorld->addJoint(PhysicsJointDistance::construct(pumpBody, sgearBody, Vec2(0, 0), Vec2(0, -44))); + _physicsWorld->addJoint(PhysicsJointDistance::construct(pumpBody, sgearBody, Vec2(0.0f, 0.0f), Vec2(0.0f, -44.0f))); // big gear auto bgearBody = PhysicsBody::createCircle(100); bgearBody->setCategoryBitmask(0x04); auto bgear = Node::create(); bgear->addComponent(bgearBody); - bgear->setPosition(VisibleRect::leftBottom() + Vec2(275, 0)); + bgear->setPosition(VisibleRect::leftBottom() + Vec2(275.0f, 0.0f)); this->addChild(bgear); _physicsWorld->addJoint(PhysicsJointPin::construct(bgearBody, nodeBody, bgear->getPosition())); @@ -1035,8 +1035,8 @@ void PhysicsDemoPump::onEnter() this->addChild(plugger); sgearBody->setCollisionBitmask(0x04 | 0x01); - _physicsWorld->addJoint(PhysicsJointPin::construct(nodeBody, pluggerBody, VisibleRect::leftBottom() + Vec2(75, -90))); - _physicsWorld->addJoint(PhysicsJointDistance::construct(pluggerBody, sgearBody, Vec2::ZERO, Vec2(44, 0))); + _physicsWorld->addJoint(PhysicsJointPin::construct(nodeBody, pluggerBody, VisibleRect::leftBottom() + Vec2(75.0f, -90.0f))); + _physicsWorld->addJoint(PhysicsJointDistance::construct(pluggerBody, sgearBody, Vec2::ZERO, Vec2(44.0f, 0.0f))); } void PhysicsDemoPump::update(float delta) @@ -1047,10 +1047,10 @@ void PhysicsDemoPump::update(float delta) { if (body->getNode()!=nullptr) { - body->getNode()->setPosition(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0)); + body->getNode()->setPosition(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0.0f)); } - body->setVelocity(Vec2(0, 0)); + body->setVelocity(Vec2(0.0f, 0.0f)); } } @@ -1115,19 +1115,19 @@ void PhysicsDemoOneWayPlatform::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto ground = Node::create(); - ground->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), - VisibleRect::rightBottom() + Vec2(0, 50))); + ground->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0.0f, 50.0f), + VisibleRect::rightBottom() + Vec2(0.0f, 50.0f))); this->addChild(ground); - auto platform = makeBox(VisibleRect::center(), Size(200, 50)); + auto platform = makeBox(VisibleRect::center(), Size(200.0f, 50.0f)); auto platformBody = platform->getPhysicsBody(); platformBody->setDynamic(false); platformBody->setContactTestBitmask(0xFFFFFFFF); this->addChild(platform); - auto ball = makeBall(VisibleRect::center() - Vec2(0, 50), 20); + auto ball = makeBall(VisibleRect::center() - Vec2(0.0f, 50.0f), 20); auto ballBody = ball->getPhysicsBody(); - ballBody->setVelocity(Vec2(0, 150)); + ballBody->setVelocity(Vec2(0.0f, 150.0f)); ballBody->setTag(DRAG_BODYS_TAG); ballBody->setMass(1.0f); ballBody->setContactTestBitmask(0xFFFFFFFF); @@ -1161,11 +1161,11 @@ void PhysicsDemoSlice::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto ground = Node::create(); - ground->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); + ground->addComponent(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0.0f, 50.0f))); this->addChild(ground); auto box = Node::create(); - Vec2 points[4] = {Vec2(-100, -100), Vec2(-100, 100), Vec2(100, 100), Vec2(100, -100)}; + Vec2 points[4] = {Vec2(-100.0f, -100.0f), Vec2(-100.0f, 100.0f), Vec2(100.0f, 100.0f), Vec2(100.0f, -100.0f)}; box->addComponent(PhysicsBody::createPolygon(points, 4)); box->setPosition(VisibleRect::center()); box->getPhysicsBody()->setTag(_sliceTag); @@ -1259,11 +1259,11 @@ void PhysicsDemoBug3988::onEnter() _physicsWorld->setGravity(Vec2::ZERO); auto ball = Sprite::create("Images/YellowSquare.png"); - ball->setPosition(VisibleRect::center() - Vec2(100, 0)); + ball->setPosition(VisibleRect::center() - Vec2(100.0f, 0.0f)); ball->setRotation(30.0f); this->addChild(ball); - auto physicsBall = makeBox(VisibleRect::center() + Vec2(100, 0), Size(100, 100)); + auto physicsBall = makeBox(VisibleRect::center() + Vec2(100.0f, 0.0f), Size(100.0f, 100.0f)); physicsBall->setRotation(30.0f); this->addChild(physicsBall); } @@ -1298,14 +1298,16 @@ void PhysicsContactTest::onEnter() decrease1->setTag(1); increase1->setTag(1); + float prevMenuPos = getSubtitleLable()->getPosition().y - getSubtitleLable()->getContentSize().height; + float menuStep = (getSubtitleLable()->getPosition().y -getRestartTestItem()->getPosition().y)*0.25f; auto menu1 = Menu::create(decrease1, increase1, nullptr); menu1->alignItemsHorizontally(); - menu1->setPosition(Vec2(s.width / 2, s.height - 50)); + menu1->setPosition(Vec2(s.width / 2, prevMenuPos)); addChild(menu1, 1); auto label = Label::createWithTTF("yellow box", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width / 2 - 150, s.height - 50)); + label->setPosition(Vec2(s.width / 2 - 150, prevMenuPos)); auto decrease2 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); decrease2->setColor(Color3B(0, 200, 20)); @@ -1316,13 +1318,13 @@ void PhysicsContactTest::onEnter() auto menu2 = Menu::create(decrease2, increase2, nullptr); menu2->alignItemsHorizontally(); - menu2->setPosition(Vec2(s.width / 2, s.height - 90)); + menu2->setPosition(Vec2(s.width / 2, prevMenuPos -= menuStep)); addChild(menu2, 1); label = Label::createWithTTF("blue box", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width / 2 - 150, s.height - 90)); - + label->setPosition(Vec2(s.width / 2 - 150, prevMenuPos)); + auto decrease3 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); decrease3->setColor(Color3B(0, 200, 20)); auto increase3 = MenuItemFont::create(" + ", CC_CALLBACK_1(PhysicsContactTest::onIncrease, this)); @@ -1332,13 +1334,13 @@ void PhysicsContactTest::onEnter() auto menu3 = Menu::create(decrease3, increase3, nullptr); menu3->alignItemsHorizontally(); - menu3->setPosition(Vec2(s.width / 2, s.height - 130)); + menu3->setPosition(Vec2(s.width / 2, prevMenuPos -= menuStep)); addChild(menu3, 1); label = Label::createWithTTF("yellow triangle", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width / 2 - 150, s.height - 130)); - + label->setPosition(Vec2(s.width / 2 - 150, prevMenuPos)); + auto decrease4 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); decrease4->setColor(Color3B(0, 200, 20)); auto increase4 = MenuItemFont::create(" + ", CC_CALLBACK_1(PhysicsContactTest::onIncrease, this)); @@ -1348,13 +1350,13 @@ void PhysicsContactTest::onEnter() auto menu4 = Menu::create(decrease4, increase4, nullptr); menu4->alignItemsHorizontally(); - menu4->setPosition(Vec2(s.width / 2, s.height - 170)); + menu4->setPosition(Vec2(s.width / 2, prevMenuPos -= menuStep)); addChild(menu4, 1); label = Label::createWithTTF("blue triangle", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width / 2 - 150, s.height - 170)); - + label->setPosition(Vec2(s.width / 2 - 150, prevMenuPos)); + resetTest(); } @@ -1414,28 +1416,30 @@ void PhysicsContactTest::resetTest() this->addChild(root); auto s = VisibleRect::getVisibleRect().size; + float prevMenuPos = getSubtitleLable()->getPosition().y - getSubtitleLable()->getContentSize().height; + float menuStep = (getSubtitleLable()->getPosition().y - getRestartTestItem()->getPosition().y)*0.25f; std::string strNum; char buffer[10]; sprintf(buffer, "%d", _yellowBoxNum); auto label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width / 2, s.height - 50)); + label->setPosition(Vec2(s.width / 2, prevMenuPos)); sprintf(buffer, "%d", _blueBoxNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width / 2, s.height - 90)); + label->setPosition(Vec2(s.width / 2, prevMenuPos-=menuStep)); sprintf(buffer, "%d", _yellowTriangleNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width / 2, s.height - 130)); + label->setPosition(Vec2(s.width / 2, prevMenuPos-=menuStep)); sprintf(buffer, "%d", _blueTriangleNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width / 2, s.height - 170)); + label->setPosition(Vec2(s.width / 2, prevMenuPos-=menuStep)); auto wall = Node::create(); wall->addComponent(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f))); @@ -1455,7 +1459,7 @@ void PhysicsContactTest::resetTest() position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); - Vec2 velocity((CCRANDOM_0_1() - 0.5) * 200, (CCRANDOM_0_1() - 0.5) * 200); + Vec2 velocity((float)(CCRANDOM_0_1() - 0.5) * 200, (float)(CCRANDOM_0_1() - 0.5) * 200); auto box = makeBox(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f)); auto boxBody = box->getPhysicsBody(); boxBody->setVelocity(velocity); @@ -1474,7 +1478,7 @@ void PhysicsContactTest::resetTest() position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); - Vec2 velocity((CCRANDOM_0_1() - 0.5) * 200, (CCRANDOM_0_1() - 0.5) * 200); + Vec2 velocity((float)(CCRANDOM_0_1() - 0.5) * 200, (float)(CCRANDOM_0_1() - 0.5) * 200); auto box = makeBox(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f)); auto boxBody = box->getPhysicsBody(); boxBody->setVelocity(velocity); @@ -1493,7 +1497,7 @@ void PhysicsContactTest::resetTest() position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); - Vec2 velocity((CCRANDOM_0_1() - 0.5) * 300, (CCRANDOM_0_1() - 0.5) * 300); + Vec2 velocity((float)(CCRANDOM_0_1() - 0.5) * 300, (float)(CCRANDOM_0_1() - 0.5) * 300); auto triangle = makeTriangle(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f)); auto triangleBody = triangle->getPhysicsBody(); triangleBody->setVelocity(velocity); @@ -1512,7 +1516,7 @@ void PhysicsContactTest::resetTest() position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); - Vec2 velocity((CCRANDOM_0_1() - 0.5) * 300, (CCRANDOM_0_1() - 0.5) * 300); + Vec2 velocity((float)(CCRANDOM_0_1() - 0.5) * 300, (float)(CCRANDOM_0_1() - 0.5) * 300); auto triangle = makeTriangle(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f)); auto triangleBody = triangle->getPhysicsBody(); triangleBody->setVelocity(velocity); @@ -1846,12 +1850,12 @@ void PhysicsTransformTest::onEnter() auto bullet = Sprite::create("Images/ball.png"); bullet->setPosition(200, 200); bullet->addComponent(PhysicsBody::createCircle(bullet->getContentSize().width/2, PhysicsMaterial(0.1f, 1.0f, 0.0f))); - bullet->getPhysicsBody()->setVelocity(Vec2(100, 100)); + bullet->getPhysicsBody()->setVelocity(Vec2(100.0f, 100.0f)); _rootLayer->addChild(bullet); - MoveBy* move = MoveBy::create(2.0f, Vec2(100, 100)); - MoveBy* move2 = MoveBy::create(2.0f, Vec2(-200, 0)); - MoveBy* move3 = MoveBy::create(2.0f, Vec2(100, -100)); + MoveBy* move = MoveBy::create(2.0f, Vec2(100.0f, 100.0f)); + MoveBy* move2 = MoveBy::create(2.0f, Vec2(-200.0f, 0.0f)); + MoveBy* move3 = MoveBy::create(2.0f, Vec2(100.0f, -100.0f)); ScaleTo* scale = ScaleTo::create(3.0f, 0.3f); ScaleTo* scale2 = ScaleTo::create(3.0f, 1.0f); diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp index 4cbcfa31bf..0847ef2ab4 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -105,7 +105,7 @@ void RenderTextureSave::saveImageWithPremultipliedAlpha(cocos2d::Ref* sender) auto sprite = Sprite::create(path); addChild(sprite); sprite->setScale(0.3f); - sprite->setPosition(Vec2(40, 40)); + sprite->setPosition(Vec2(40.0f, 40.0f)); sprite->setRotation(counter * 3); _target->release(); }; @@ -131,7 +131,7 @@ void RenderTextureSave::saveImageWithNonPremultipliedAlpha(cocos2d::Ref *sender) auto sprite = Sprite::create(path); addChild(sprite); sprite->setScale(0.3f); - sprite->setPosition(Vec2(40, 40)); + sprite->setPosition(Vec2(40.0f, 40.0f)); sprite->setRotation(counter * 3); rt->release(); }; @@ -456,7 +456,7 @@ RenderTexturePartTest::RenderTexturePartTest() _rend->end(); _spriteDraw = Sprite::createWithTexture(_rend->getSprite()->getTexture()); - FiniteTimeAction* baseAction = MoveBy::create(1, Vec2(size.width,0)); + FiniteTimeAction* baseAction = MoveBy::create(1, Vec2(size.width,0.0f)); _spriteDraw->setPosition(0,size.height/2); _spriteDraw->setScaleY(-1); _spriteDraw->runAction(RepeatForever::create(Sequence::create @@ -487,15 +487,15 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() _spriteDS = Sprite::create("Images/fire.png"); _spriteDS->retain(); - _spriteDS->setPosition(Vec2(s.width * 0.25f, 0)); + _spriteDS->setPosition(Vec2(s.width * 0.25f, 0.0f)); _spriteDS->setScale(10); _spriteDraw = Sprite::create("Images/fire.png"); _spriteDraw->retain(); - _spriteDraw->setPosition(Vec2(s.width * 0.25f, 0)); + _spriteDraw->setPosition(Vec2(s.width * 0.25f, 0.0f)); _spriteDraw->setScale(10); //! move sprite half width and height, and draw only where not marked - _spriteDraw->setPosition(_spriteDraw->getPosition() + Vec2(_spriteDraw->getContentSize().width * _spriteDraw->getScale() * 0.5, _spriteDraw->getContentSize().height * _spriteDraw->getScale() * 0.5)); + _spriteDraw->setPosition(_spriteDraw->getPosition() + Vec2(_spriteDraw->getContentSize().width * _spriteDraw->getScale() * 0.5f, _spriteDraw->getContentSize().height * _spriteDraw->getScale() * 0.5f)); _rend = RenderTexture::create(s.width, s.height, backend::PixelFormat::RGBA4444, PixelFormat::D24S8); @@ -814,7 +814,7 @@ RenderTextureWithSprite3DIssue16894::RenderTextureWithSprite3DIssue16894() // Ship - Model is from cocos2d-x test project auto ship = Sprite3D::create("Sprite3DTest/boss.c3b"); ship->setScale(6); - ship->setRotation3D(Vec3(180,45,0)); + ship->setRotation3D(Vec3(180.0f,45.0f,0.0f)); ship->setPosition(Vec2(visibleSize.width/4 + origin.x, visibleSize.height/2 + origin.y)); ship->setForce2DQueue(true); ship->retain(); @@ -823,7 +823,7 @@ RenderTextureWithSprite3DIssue16894::RenderTextureWithSprite3DIssue16894() { addChild(ship, 1); //// Rotate Ship - auto spin = RotateBy::create(4, Vec3(0,180,0)); + auto spin = RotateBy::create(4, Vec3(0.0f,180.0f,0.0f)); auto repeatspin = RepeatForever::create(spin); ship->runAction(repeatspin); } @@ -845,15 +845,15 @@ RenderTextureWithSprite3DIssue16894::RenderTextureWithSprite3DIssue16894() scheduleUpdate(); auto label1 = Label::createWithTTF("Normal Sprite3D\n", "fonts/arial.ttf", 10); - label1->setPosition(Vec2(visibleSize.width/4 * 1, 60)); + label1->setPosition(Vec2(visibleSize.width/4 * 1, 60.0f)); this->addChild(label1, 1); auto label2 = Label::createWithTTF("RenderTexture\nDefault - No depth buffer", "fonts/arial.ttf", 10); - label2->setPosition(Vec2(visibleSize.width/4 * 2, 60)); + label2->setPosition(Vec2(visibleSize.width/4 * 2, 60.0f)); this->addChild(label2, 1); auto label3 = Label::createWithTTF("RenderTexture\nGL_DEPTH24_STENCIL8", "fonts/arial.ttf", 10); - label3->setPosition(Vec2(visibleSize.width/4 * 3, 60)); + label3->setPosition(Vec2(visibleSize.width/4 * 3, 60.0f)); this->addChild(label3, 1); } diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h index ebd8904605..680b06d834 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h @@ -176,10 +176,6 @@ public: Issue16113Test(); virtual std::string title() const override; virtual std::string subtitle() const override; - -private: - cocos2d::RenderTexture* _rend; - cocos2d::Sprite* _spriteDraw; }; class RenderTextureWithSprite3DIssue16894 : public RenderTextureTest diff --git a/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp b/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp index 9f60d74239..405cf7f2be 100644 --- a/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp +++ b/tests/cpp-tests/Classes/RotateWorldTest/RotateWorldTest.cpp @@ -81,7 +81,7 @@ void SpriteLayer::onEnter() spriteSister2->setScale(1.5f); sprite->setPosition(Vec2(x/2,y/2)); - spriteSister1->setPosition(Vec2(40,y/2)); + spriteSister1->setPosition(Vec2(40.0f,y/2)); spriteSister2->setPosition(Vec2(x-40,y/2)); auto rot = RotateBy::create(16, -3600); @@ -162,7 +162,7 @@ bool RotateWorldTest::init() auto layer = RotateWorldMainLayer::create(); addChild(layer); - runAction(RotateBy::create(4, -360)); + runAction(RotateBy::create(4.0f, -360.0f)); return true; } diff --git a/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp b/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp index 7e9de73e07..2b1e7375d8 100644 --- a/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp +++ b/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp @@ -199,7 +199,7 @@ bool SceneTestLayer3::init() auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); - sprite->setPosition( Vec2(s.width/2, 40) ); + sprite->setPosition( Vec2(s.width/2, 40.0f) ); auto rotate = RotateBy::create(2, 360); auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp index 9831f4ffa1..ea6128ca6c 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp @@ -166,7 +166,7 @@ void SchedulerPauseResumeAll::onEnter() auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(VisibleRect::center()); this->addChild(sprite); - sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); + sprite->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); sprite->setTag(123); scheduleUpdate(); schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAll::tick1), 0.5f); @@ -258,7 +258,7 @@ void SchedulerPauseResumeAllUser::onEnter() sprite->setPosition(Vec2(s.width/2, s.height/2)); sprite->setTag(123); this->addChild(sprite); - sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); + sprite->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAllUser::tick1), 1.0f); schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAllUser::tick2), 1.0f); @@ -379,7 +379,7 @@ void SchedulerUnscheduleAllHard::onEnter() auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Vec2(s.width/2, s.height/2)); this->addChild(sprite); - sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); + sprite->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); _actionManagerActive = true; @@ -451,7 +451,7 @@ void SchedulerUnscheduleAllUserLevel::onEnter() auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Vec2(s.width/2, s.height/2)); this->addChild(sprite); - sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); + sprite->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::tick1), 0.5f); schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::tick2), 1.0f); @@ -810,7 +810,7 @@ void SchedulerTimeScale::onEnter() auto s = Director::getInstance()->getWinSize(); // rotate and jump - auto jump1 = JumpBy::create(4, Vec2(-s.width+80,0), 100, 4); + auto jump1 = JumpBy::create(4, Vec2(-s.width+80,0.0f), 100, 4); auto jump2 = jump1->reverse(); auto rot1 = RotateBy::create(4, 360*2); auto rot2 = rot1->reverse(); @@ -827,9 +827,9 @@ void SchedulerTimeScale::onEnter() auto tamara = Sprite::create("Images/grossinis_sister1.png"); auto kathia = Sprite::create("Images/grossinis_sister2.png"); - grossini->setPosition(Vec2(40,80)); - tamara->setPosition(Vec2(40,80)); - kathia->setPosition(Vec2(40,80)); + grossini->setPosition(Vec2(40.0f,80.0f)); + tamara->setPosition(Vec2(40.0f,80.0f)); + kathia->setPosition(Vec2(40.0f,80.0f)); addChild(grossini); addChild(tamara); @@ -917,7 +917,7 @@ void TwoSchedulers::onEnter() // auto grossini = Sprite::create("Images/grossini.png"); addChild(grossini); - grossini->setPosition(Vec2(s.width/2,100)); + grossini->setPosition(Vec2(s.width/2,100.0f)); grossini->runAction(action->clone()); auto defaultScheduler = Director::getInstance()->getScheduler(); @@ -943,7 +943,7 @@ void TwoSchedulers::onEnter() sprite->setActionManager(actionManager1); addChild(sprite); - sprite->setPosition(Vec2(30+15*i,100)); + sprite->setPosition(Vec2(30+15*i,100.0f)); sprite->runAction(action->clone()); } @@ -968,7 +968,7 @@ void TwoSchedulers::onEnter() sprite->setActionManager(actionManager2); addChild(sprite); - sprite->setPosition(Vec2(s.width-30-15*i,100)); + sprite->setPosition(Vec2(s.width-30-15*i,100.0f)); sprite->runAction(action->clone()); } @@ -1091,7 +1091,7 @@ void SchedulerIssueWithReschedule::onEnter() _scheduler->schedule([this, verified](float dt){ log("SchedulerIssueWithReschedule - first timer"); - _scheduler->schedule([this, verified](float dt){ + _scheduler->schedule([verified](float dt){ log("SchedulerIssueWithReschedule - second timer. OK"); *verified = true; }, this, 0.1f, 0, 0, false, "test_timer"); @@ -1422,10 +1422,9 @@ void SchedulerRemoveEntryWhileUpdate::onExit() } SchedulerRemoveEntryWhileUpdate::TestClass::TestClass(int index, TestClass *nextObj, cocos2d::Scheduler* scheduler) -: _index(index) -, _nextObj(nextObj) +: _nextObj(nextObj) +, _index(index) , _scheduler(scheduler) -, _cleanedUp(false) { } diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h index 34ccb9d408..4156e2e3b6 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h @@ -431,10 +431,10 @@ private: TestClass(int index, TestClass *nextObj, cocos2d::Scheduler* scheduler); void update(float dt); private: - TestClass *_nextObj; - int _index; - cocos2d::Scheduler *_scheduler; - bool _cleanedUp; + TestClass *_nextObj = nullptr; + int _index = 0; + cocos2d::Scheduler *_scheduler = nullptr; + bool _cleanedUp = false; }; std::vector _testvector; }; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index e842702975..f3c1114a88 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -26,6 +26,7 @@ #include "../testResource.h" #include "cocos2d.h" #include "renderer/ccShaders.h" +#include "renderer/backend/Device.h" USING_NS_CC; USING_NS_CC_EXT; @@ -111,7 +112,7 @@ bool ShaderNode::initWithVertex(const std::string &vert, const std::string &frag layout->setAttribute("a_position", 0, backend::VertexFormat::FLOAT2, 0, false); float w = SIZE_X, h = SIZE_Y; - Vec2 vertices[6] = { Vec2(0,0), Vec2(w,0), Vec2(w,h), Vec2(0,0), Vec2(0,h), Vec2(w,h) }; + Vec2 vertices[6] = { Vec2(0.0f,0.0f), Vec2(w,0.0f), Vec2(w,h), Vec2(0.0f,0.0f), Vec2(0.0f,h), Vec2(w,h) }; layout->setLayout(sizeof(Vec2)); /* @@ -144,10 +145,11 @@ void ShaderNode::loadShaderVertex(const std::string &vert, const std::string &fr std::string vertexFilePath = fileUtiles->fullPathForFilename(vert); vertSource = fileUtiles->getStringFromFile(vertexFilePath); } - - auto programState = new backend::ProgramState(vertSource.c_str(), fragSource.c_str()); + auto program = backend::Device::getInstance()->newProgram(vertSource.c_str(), fragSource.c_str()); + auto programState = new backend::ProgramState(program); setProgramState(programState); CC_SAFE_RELEASE(programState); + CC_SAFE_RELEASE(program); } void ShaderNode::update(float dt) @@ -472,9 +474,11 @@ void SpriteBlur::initProgram() std::string fragSource = FileUtils::getInstance()->getStringFromFile( FileUtils::getInstance()->fullPathForFilename("Shaders/example_Blur.fsh")); - auto programState = new backend::ProgramState(positionTextureColor_vert, fragSource.data()); + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource.data()); + auto programState = new backend::ProgramState(program); setProgramState(programState); - CC_SAFE_RELEASE_NULL(programState); + CC_SAFE_RELEASE(programState); + CC_SAFE_RELEASE(program); auto size = getTexture()->getContentSizeInPixels(); @@ -603,7 +607,8 @@ bool ShaderRetroEffect::init() auto fragStr = FileUtils::getInstance()->getStringFromFile(FileUtils::getInstance()->fullPathForFilename("Shaders/example_HorizontalColor.fsh")); char * fragSource = (char*)fragStr.c_str(); - auto p = new backend::ProgramState(positionTextureColor_vert, fragSource); + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource); + auto p = new backend::ProgramState(program); auto director = Director::getInstance(); const auto& screenSizeLocation = p->getUniformLocation("u_screenSize"); const auto& frameSize = director->getOpenGLView()->getFrameSize(); @@ -623,6 +628,7 @@ bool ShaderRetroEffect::init() addChild(_label); scheduleUpdate(); + CC_SAFE_RELEASE(program); return true; } @@ -793,8 +799,8 @@ bool ShaderMultiTexture::init() auto * fu = FileUtils::getInstance(); auto vertexShader = fu->getStringFromFile("Shaders/example_MultiTexture.vsh"); auto fragmentShader = fu->getStringFromFile("Shaders/example_MultiTexture.fsh"); - - auto programState = new backend::ProgramState(vertexShader.c_str(), fragmentShader.c_str() ); + auto program = backend::Device::getInstance()->newProgram(vertexShader.c_str(), fragmentShader.c_str()); + auto programState = new backend::ProgramState(program); _sprite->setProgramState(programState); SET_TEXTURE(programState, "u_texture1", 1, right->getTexture()->getBackendTexture()); @@ -811,6 +817,7 @@ bool ShaderMultiTexture::init() menu->setPosition(s.width * 7 / 8, s.height / 2); CC_SAFE_RELEASE(programState); + CC_SAFE_RELEASE(program); return true; } diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index b56f0ea33d..484a619317 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -27,6 +27,7 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" +#include "renderer/backend/Device.h" #include USING_NS_CC; @@ -178,10 +179,10 @@ bool Effect::initProgramState(const std::string &fragmentFilename) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _fragSource = fragSource; #endif - - auto programState = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str()); - + auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, fragSource.c_str()); + auto programState = new backend::ProgramState(program); CC_SAFE_RELEASE(_programState); + CC_SAFE_RELEASE(program); _programState = programState; return _programState != nullptr; @@ -488,15 +489,15 @@ bool EffectSpriteTest::init() auto menu = Menu::create(itemPrev, itemNext, nullptr); menu->alignItemsHorizontally(); menu->setScale(0.5); - menu->setAnchorPoint(Vec2(0,0)); - menu->setPosition(Vec2(s.width/2,70)); + menu->setAnchorPoint(Vec2(0.0f,0.0f)); + menu->setPosition(Vec2(s.width/2,70.0f)); addChild(menu); _sprite = EffectSprite::create("Images/grossini.png"); - _sprite->setPosition(Vec2(0, s.height/2)); + _sprite->setPosition(Vec2(0.0f, s.height/2)); addChild(_sprite); - auto jump = JumpBy::create(4, Vec2(s.width,0), 100, 4); + auto jump = JumpBy::create(4, Vec2(s.width,0.0f), 100, 4); auto rot = RotateBy::create(4, 720); auto spawn = Spawn::create(jump, rot, nullptr); auto rev = spawn->reverse(); @@ -549,7 +550,7 @@ bool EffectSpriteLamp::init() Mat4 mat = _sprite->getNodeToWorldTransform(); Point lightPosInLocalSpace = PointApplyAffineTransform(Vec2(pos.x, pos.y), _sprite->getWorldToNodeAffineTransform()); lampEffect->setLightColor(Color4F(1,1,1,1)); - lampEffect->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50)); + lampEffect->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50.0f)); lampEffect->setKBump(2); _sprite->setEffect(lampEffect); _effect = lampEffect; @@ -575,7 +576,7 @@ void EffectSpriteLamp::onTouchesBegan(const std::vector& touches, Event Vec3 pos(loc_winSpace.x,loc_winSpace.y, 50); Mat4 mat = _sprite->getNodeToWorldTransform(); Point lightPosInLocalSpace = PointApplyAffineTransform(Vec2(pos.x, pos.y), _sprite->getWorldToNodeAffineTransform()); - ((EffectNormalMapped*)_effect)->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50)); + ((EffectNormalMapped*)_effect)->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50.0f)); } } @@ -590,7 +591,7 @@ void EffectSpriteLamp::onTouchesMoved(const std::vector& touches, Event Vec3 pos(loc_winSpace.x,loc_winSpace.y, 50); Mat4 mat = _sprite->getNodeToWorldTransform(); Point lightPosInLocalSpace = PointApplyAffineTransform(Vec2(pos.x, pos.y), _sprite->getWorldToNodeAffineTransform()); - ((EffectNormalMapped*)_effect)->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50)); + ((EffectNormalMapped*)_effect)->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50.0f)); } } @@ -605,6 +606,6 @@ void EffectSpriteLamp::onTouchesEnded(const std::vector& touches, Event Vec3 pos(loc_winSpace.x,loc_winSpace.y, 50); Mat4 mat = _sprite->getNodeToWorldTransform(); Point lightPosInLocalSpace = PointApplyAffineTransform(Vec2(pos.x, pos.y), _sprite->getWorldToNodeAffineTransform()); - ((EffectNormalMapped*)_effect)->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50)); + ((EffectNormalMapped*)_effect)->setLightPos(Vec3(lightPosInLocalSpace.x, lightPosInLocalSpace.y, 50.0f)); } } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp b/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp index 9476a1f28f..50013b1061 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp @@ -58,7 +58,7 @@ void DrawNode3D::ensureCapacity(int count) { CCASSERT(count>=0, "capacity must be >= 0"); - const int EXTENDED_SIZE = _bufferLines.size() + count; + auto EXTENDED_SIZE = _bufferLines.size() + count; _bufferLines.reserve(EXTENDED_SIZE); @@ -73,7 +73,8 @@ bool DrawNode3D::init() { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; auto &pd = _customCommand.getPipelineDescriptor(); - _programStateLine = new backend::ProgramState(lineColor3D_vert, lineColor3D_frag); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::LINE_COLOR_3D); + _programStateLine = new backend::ProgramState(program); pd.programState = _programStateLine; _locMVPMatrix = _programStateLine->getUniformLocation("u_MVPMatrix"); diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index a860d5f85c..b9be4c87dd 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -99,7 +99,7 @@ Sprite3DForceDepthTest::Sprite3DForceDepthTest() orc->setScale(5); orc->setPositionNormalized(Vec2(.5f, .3f)); orc->setPositionZ(40); - orc->setRotation3D(Vec3(0, 180, 0)); + orc->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); orc->setGlobalZOrder(-1); addChild(orc); @@ -107,8 +107,8 @@ Sprite3DForceDepthTest::Sprite3DForceDepthTest() auto ship = Sprite3D::create("Sprite3DTest/boss1.obj"); ship->setScale(5); ship->setTexture("Sprite3DTest/boss.png"); - ship->setPositionNormalized(Vec2(.5, .5)); - ship->setRotation3D(Vec3(90, 0, 0)); + ship->setPositionNormalized(Vec2(.5f, .5f)); + ship->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); ship->setForceDepthWrite(true); addChild(ship); @@ -132,7 +132,7 @@ std::string Sprite3DForceDepthTest::subtitle() const Sprite3DEmptyTest::Sprite3DEmptyTest() { auto s = Sprite3D::create(); - s->setPositionNormalized(Vec2(.5, .5)); + s->setPositionNormalized(Vec2(.5f, .5f)); auto l = Label::create(); l->setString("Test"); s->addChild(l); @@ -254,8 +254,8 @@ Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() this->addChild(camera); //adjust cylinder's position & rotation - cylinder->setPosition3D(Vec3(0, -15, -50)); - cylinder->setRotation3D(Vec3(-90, 0, 0)); + cylinder->setPosition3D(Vec3(0.0f, -15.0f, -50.0f)); + cylinder->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); //the callback function update cylinder's texcoord schedule(CC_SCHEDULE_SELECTOR(Sprite3DUVAnimationTest::cylinderUpdate)); @@ -335,12 +335,12 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() //create Camera _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200); _camera->setCameraFlag(CameraFlag::USER1); - _camera->setPosition3D(Vec3(0, 20, 25)); - _camera->setRotation3D(Vec3(-60, 0, 0)); + _camera->setPosition3D(Vec3(0.0f, 20.0f, 25.0f)); + _camera->setRotation3D(Vec3(-60.0f, 0.0f, 0.0f)); //create a plane _plane = Sprite3D::create("Sprite3DTest/plane.c3t"); - _plane->setRotation3D(Vec3(90, 0, 0)); + _plane->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/FakeShadow.material"); @@ -357,8 +357,8 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() //create the orc _orc = Sprite3D::create("Sprite3DTest/orc.c3b"); _orc->setScale(0.2f); - _orc->setRotation3D(Vec3(0, 180, 0)); - _orc->setPosition3D(Vec3(0, 0, 10)); + _orc->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + _orc->setPosition3D(Vec3(0.0f, 0.0f, 10.0f)); _targetPos = _orc->getPosition3D(); location = _state->getUniformLocation("u_target_pos"); _state->setUniform(location, &_targetPos, sizeof(_targetPos)); @@ -570,9 +570,9 @@ Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest() _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); teapot->setMaterial(mat); - teapot->setPosition3D(Vec3(0, -5, -20)); - teapot->setRotation3D(Vec3(-90, 180, 0)); - auto rotate_action = RotateBy::create(1.5, Vec3(0, 30, 0)); + teapot->setPosition3D(Vec3(0.0f, -5.0f, -20.0f)); + teapot->setRotation3D(Vec3(-90.0f, 180.0f, 0.0f)); + auto rotate_action = RotateBy::create(1.5f, Vec3(0.0f, 30.0f, 0.0f)); teapot->runAction(RepeatForever::create(rotate_action)); addChild(teapot); addChild(_camera); @@ -619,8 +619,8 @@ Sprite3DLightMapTest::Sprite3DLightMapTest() Size visibleSize = Director::getInstance()->getVisibleSize(); _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200); _camera->setCameraFlag(CameraFlag::USER1); - _camera->setPosition3D(Vec3(0, 25, 15)); - _camera->setRotation3D(Vec3(-35, 0, 0)); + _camera->setPosition3D(Vec3(0.0f, 25.0f, 15.0f)); + _camera->setRotation3D(Vec3(-35.0f, 0.0f, 0.0f)); auto LightMapScene = Sprite3D::create("Sprite3DTest/LightMapScene.c3b"); LightMapScene->setScale(0.1f); addChild(LightMapScene); @@ -695,18 +695,18 @@ Sprite3DHitTest::Sprite3DHitTest() //add to scene addChild(sprite1); - sprite1->runAction(RepeatForever::create(RotateBy::create(3, 360))); + sprite1->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); auto sprite2 = Sprite3D::create("Sprite3DTest/boss1.obj"); sprite2->setScale(4.f); sprite2->setTexture("Sprite3DTest/boss.png"); sprite2->setPosition(Vec2(s.width / 2, s.height / 2)); - sprite2->setAnchorPoint(Vec2(0.5, 0.5)); + sprite2->setAnchorPoint(Vec2(0.5f, 0.5f)); //add to scene addChild(sprite2); - sprite2->runAction(RepeatForever::create(RotateBy::create(3, -360))); + sprite2->runAction(RepeatForever::create(RotateBy::create(3.0f, -360.0f))); // Make sprite1 touchable @@ -852,7 +852,7 @@ AsyncLoadSprite3DTest::AsyncLoadSprite3DTest() item1->setPosition(s.width * .5f, s.height * .8f); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); auto node = Node::create(); @@ -939,7 +939,7 @@ void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p) std::string fileName = "Sprite3DTest/orc.c3b"; auto sprite = Sprite3D::create(fileName); sprite->setScale(3); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); sprite->setPosition(Vec2(p.x, p.y)); addChild(sprite); _sprits.push_back(sprite); @@ -1057,7 +1057,7 @@ void Sprite3DWithSkinOutlineTest::addNewSpriteWithCoords(Vec2 p) sprite->setMaterial(material); sprite->setScale(3); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); addChild(sprite); sprite->setPosition(Vec2(p.x, p.y)); @@ -1254,7 +1254,7 @@ void AttachmentTest::addNewSpriteWithCoords(Vec2 p) std::string fileName = "Sprite3DTest/orc.c3b"; auto sprite = Sprite3D::create(fileName); sprite->setScale(5); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); addChild(sprite); sprite->setPosition(Vec2(p.x, p.y)); @@ -1318,7 +1318,7 @@ Sprite3DReskinTest::Sprite3DReskinTest() item4->setUserData((void*)SkinType::PANTS); item5->setUserData((void*)SkinType::SHOES); auto pMenu1 = Menu::create(item1, item2, item3, item4, item5, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); } @@ -1346,7 +1346,7 @@ void Sprite3DReskinTest::addNewSpriteWithCoords(Vec2 p) std::string fileName = "Sprite3DTest/ReskinGirl.c3b"; auto sprite = Sprite3D::create(fileName); sprite->setScale(4); - sprite->setRotation3D(Vec3(0, 0, 0)); + sprite->setRotation3D(Vec3(0.0f, 0.0f, 0.0f)); addChild(sprite); sprite->setPosition(Vec2(p.x, p.y - 60)); auto animation = Animation3D::create(fileName); @@ -1686,7 +1686,7 @@ void Sprite3DMirrorTest::addNewSpriteWithCoords(Vec2 p) std::string fileName = "Sprite3DTest/orc.c3b"; auto sprite = Sprite3D::create(fileName); sprite->setScale(5); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); addChild(sprite); sprite->setPosition(Vec2(p.x - 80, p.y)); @@ -1709,7 +1709,7 @@ void Sprite3DMirrorTest::addNewSpriteWithCoords(Vec2 p) sprite->setScale(5); sprite->setScaleX(-5); sprite->setCullFace(CullFaceSide::FRONT); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); addChild(sprite); sprite->setPosition(Vec2(p.x + 80, p.y)); @@ -1804,8 +1804,8 @@ UseCaseSprite3D::UseCaseSprite3D() auto menu = Menu::create(itemPrev, itemNext, nullptr); menu->alignItemsHorizontally(); menu->setScale(0.5); - menu->setAnchorPoint(Vec2(0, 0)); - menu->setPosition(Vec2(s.width / 2, 70)); + menu->setAnchorPoint(Vec2(0.0f, 0.0f)); + menu->setPosition(Vec2(s.width / 2, 70.0f)); _label = Label::create(); _label->setPosition(s.width * 0.5f, s.height * 0.8f); @@ -1857,7 +1857,7 @@ void UseCaseSprite3D::switchCase() circleBack->addChild(circle); circle->runAction(RepeatForever::create(RotateBy::create(3, Vec3(0.f, 0.f, 360.f)))); - circleBack->setRotation3D(Vec3(-90, -90, 0)); + circleBack->setRotation3D(Vec3(-90.0f, -90.0f, 0.0f)); auto pos = sprite->getPosition3D(); circleBack->setPosition3D(Vec3(pos.x, pos.y, pos.z - 1)); @@ -1906,7 +1906,7 @@ void UseCaseSprite3D::switchCase() item2->setPosition(Vec2(s.width * 0.5f - item1->getContentSize().width * 0.5f, s.height * 0.5f - item1->getContentSize().height * 2.f)); auto pMenu1 = Menu::create(item1, item2, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); layer->addChild(pMenu1); layer->setTag(101); @@ -1991,9 +1991,9 @@ NodeAnimationTest::NodeAnimationTest() auto menu = Menu::create(itemPrev, itemNext, nullptr); menu->alignItemsHorizontally(); - menu->setScale(0.5); - menu->setAnchorPoint(Vec2(0, 0)); - menu->setPosition(Vec2(s.width / 2, 70)); + menu->setScale(0.5f); + menu->setAnchorPoint(Vec2(0.0f, 0.0f)); + menu->setPosition(Vec2(s.width / 2, 70.0f)); addChild(menu); addNewSpriteWithCoords(Vec2(s.width / 2.f, s.height / 2.f)); @@ -2014,7 +2014,7 @@ void NodeAnimationTest::addNewSpriteWithCoords(Vec2 p) // add jumping ball std::string fileName = "Sprite3DTest/ball.c3b"; auto sprite = Sprite3D::create(fileName); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); sprite->setScale(3); sprite->setPosition(Vec2(s.width / 2.f, s.height / 3.f)); sprite->setTexture("Sprite3DTest/teapot.png"); @@ -2038,7 +2038,7 @@ void NodeAnimationTest::addNewSpriteWithCoords(Vec2 p) // add jumping orc fileName = "Sprite3DTest/orc_jump.c3t"; sprite = Sprite3D::create(fileName); - sprite->setRotation3D(Vec3(0, 180, 0)); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); sprite->setScale(3); sprite->setPosition(Vec2(s.width / 2.f, s.height / 3.f)); sprite->setVisible(false); @@ -2123,10 +2123,10 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) auto cubeTexLoc = state->getUniformLocation("u_cubeTex"); state->setTexture(cubeTexLoc, 0, _textureCube->getBackendTexture()); - _teapot->setPosition3D(Vec3(0, -5, 0)); - _teapot->setRotation3D(Vec3(-90, 180, 0)); + _teapot->setPosition3D(Vec3(0.0f, -5.0f, 0.0f)); + _teapot->setRotation3D(Vec3(-90.0f, 180.0f, 0.0f)); - auto rotate_action = RotateBy::create(1.5, Vec3(0, 30, 0)); + auto rotate_action = RotateBy::create(1.5, Vec3(0.0f, 30.0f, 0.0f)); _teapot->runAction(RepeatForever::create(rotate_action)); addChild(_teapot); @@ -2206,7 +2206,7 @@ Issue9767::Issue9767() item1->setPosition(Vec2(s.width * 0.9f - item1->getContentSize().width * 0.5f, s.height * 0.5f - item1->getContentSize().height)); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); addChild(pMenu1); } @@ -2221,14 +2221,14 @@ void Issue9767::menuCallback_SwitchShader(cocos2d::Ref* sender) if (_shaderType == Issue9767::ShaderType::SHADER_TEX) { _shaderType = Issue9767::ShaderType::SHADER_COLOR; - //programState = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_POSITION); - _programState = new backend::ProgramState(CC3D_positionTexture_vert, CC3D_color_frag); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_3D); + _programState = new backend::ProgramState(program); } else { _shaderType = Issue9767::ShaderType::SHADER_TEX; - //programState = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_POSITION_TEXTURE); - _programState = new backend::ProgramState(CC3D_positionTexture_vert, CC3D_colorTexture_frag); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_3D); + _programState = new backend::ProgramState(program); } _sprite->setProgramState(_programState); } @@ -2351,7 +2351,7 @@ Sprite3DVertexColorTest::Sprite3DVertexColorTest() auto s = Director::getInstance()->getWinSize(); auto sprite = Sprite3D::create("Sprite3DTest/box_VertexCol.c3t"); - sprite->setPosition(Vec2(0, 0)); + sprite->setPosition(Vec2(0.0f, 0.0f)); sprite->setScale(1.0f); sprite->setCameraMask(2); auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/VertexColor.material"); @@ -2405,7 +2405,7 @@ CameraBackgroundClearTest::CameraBackgroundClearTest() item1->setPosition( Vec2(VisibleRect::left().x+50, VisibleRect::bottom().y+item1->getContentSize().height*4 ) ); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0,0)); + pMenu1->setPosition(Vec2(0.0f,0.0f)); this->addChild(pMenu1, 10); //setup camera @@ -2522,7 +2522,7 @@ Sprite3DNormalMappingTest::Sprite3DNormalMappingTest() { auto sprite = Sprite3D::create("Sprite3DTest/sphere.c3b"); - sprite->setPosition(Vec2(-30, 0)); + sprite->setPosition(Vec2(-30.0f, 0.0f)); sprite->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); sprite->setScale(2.0); sprite->setCameraMask(2); @@ -2535,7 +2535,7 @@ Sprite3DNormalMappingTest::Sprite3DNormalMappingTest() if (maxAttributes > 8) { auto sprite = Sprite3D::create("Sprite3DTest/sphere_bumped.c3b"); - sprite->setPosition(Vec2(30, 0)); + sprite->setPosition(Vec2(30.0f, 0.0f)); sprite->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); sprite->setScale(20.0); sprite->setCameraMask(2); @@ -2607,7 +2607,7 @@ Sprite3DPropertyTest::Sprite3DPropertyTest() _sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); _sprite->setPosition(20.f, 0.f); - _sprite->setRotation3D(Vec3(0, 180, 0)); + _sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); _meshTex = _sprite->getMesh()->getTexture(); _texFile = _meshTex->getPath(); addChild(_sprite); @@ -2632,7 +2632,7 @@ Sprite3DPropertyTest::Sprite3DPropertyTest() item3->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 6)); auto pMenu1 = Menu::create(item1, item2, item3,nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); scheduleUpdate(); diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp index 84722b6a62..c35cff5c53 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp @@ -97,7 +97,7 @@ bool SpritePolygonTestCase::init() auto menu = Menu::create(menuItem, nullptr); menu->setPosition(Vec2::ZERO); menuItem->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); - menuItem->setPosition( VisibleRect::leftBottom() + Vec2(0, VisibleRect::leftTop().y/4)); + menuItem->setPosition( VisibleRect::leftBottom() + Vec2(0.0f, VisibleRect::leftTop().y/4)); this->addChild(menu, 9999); } return true; @@ -370,9 +370,9 @@ Sprite* SpritePolygonTestSlider::makeSprite(const std::string &filename, const V auto ttfConfig = TTFConfig("fonts/arial.ttf", 8); auto spArea = Label::createWithTTF(ttfConfig, filename+"\nVerts: "+Value((int)pinfo.getVertCount()).asString()+ "\nPixels: "+Value((int)(pinfo.getArea()/originalSize*100)).asString()+"%"); ret->addChild(spArea); - spArea->setAnchorPoint(Vec2(0,1)); + spArea->setAnchorPoint(Vec2(0.0f,1.0f)); spArea->setName(filename); - ret->setAnchorPoint(Vec2(0.5, 0)); + ret->setAnchorPoint(Vec2(0.5f, 0.0f)); updateDrawNode(); @@ -473,7 +473,7 @@ void SpritePolygonTest5::loadDefaultSprites() sprites[0]->setColor(Color3B::RED); sprites[1]->setOpacity(100); sprites[2]->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png")); - sprites[3]->setTextureRect(Rect(0,0,100,30)); + sprites[3]->setTextureRect(Rect(0.0f,0.0f,100.0f,30.0f)); sprites[4]->setScale(0.5f, 2.0f); sprites[5]->setFlippedY(true); sprites[6]->setSkewX(60); @@ -639,7 +639,7 @@ SpritePolygonPerformanceTestDynamic::SpritePolygonPerformanceTestDynamic() Sprite* SpritePolygonPerformanceTestDynamic::makeSprite() { auto ret = Sprite::create(_pinfo); - ret->runAction(RepeatForever::create(RotateBy::create(1.0,360.0))); + ret->runAction(RepeatForever::create(RotateBy::create(1.0f,360.0f))); return ret; } @@ -660,7 +660,7 @@ void SpritePerformanceTestDynamic::initIncrementStats() Sprite* SpritePerformanceTestDynamic::makeSprite() { auto ret = Sprite::create(s_pathGrossini); - ret->runAction(RepeatForever::create(RotateBy::create(1.0,360.0))); + ret->runAction(RepeatForever::create(RotateBy::create(1.0f,360.0f))); return ret; } diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index 7f9fb93fef..63ff16fa3f 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -683,7 +683,7 @@ SpriteBatchNodeReorder::SpriteBatchNodeReorder() for(int i=0; i<10; i++) { - auto s1 = Sprite::createWithTexture(asmtest->getTexture(), Rect(0, 0, 50, 50)); + auto s1 = Sprite::createWithTexture(asmtest->getTexture(), Rect(0.0f, 0.0f, 50.0f, 50.0f)); a.pushBack(s1); asmtest->addChild(s1, 10); } @@ -806,13 +806,13 @@ SpriteBatchNodeReorderIssue766::SpriteBatchNodeReorderIssue766() addChild(batchNode, 1, 0); sprite1 = makeSpriteZ(2); - sprite1->setPosition(Vec2(200,160)); + sprite1->setPosition(Vec2(200.0f,160.0f)); sprite2 = makeSpriteZ(3); - sprite2->setPosition(Vec2(264,160)); + sprite2->setPosition(Vec2(264.0f,160.0f)); sprite3 = makeSpriteZ(4); - sprite3->setPosition(Vec2(328,160)); + sprite3->setPosition(Vec2(328.0f,160.0f)); schedule(CC_CALLBACK_1(SpriteBatchNodeReorderIssue766::reorderSprite, this), 2, "issue_766_key"); } @@ -2529,10 +2529,10 @@ SpriteBatchNodeChildren::SpriteBatchNodeChildren() sprite1->setPosition(Vec2( s.width/3, s.height/2)); auto sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(50,50)); + sprite2->setPosition(Vec2(50.0f,50.0f)); auto sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-50,-50)); + sprite3->setPosition(Vec2(-50.0f,-50.0f)); batch->addChild(sprite1); sprite1->addChild(sprite2); @@ -2552,10 +2552,10 @@ SpriteBatchNodeChildren::SpriteBatchNodeChildren() sprite1->runAction(RepeatForever::create( Animate::create(animation) ) ); // END NEW CODE - auto action = MoveBy::create(2, Vec2(200,0)); + auto action = MoveBy::create(2, Vec2(200.0f,0.0f)); auto action_back = action->reverse(); - auto action_rot = RotateBy::create(2, 360); - auto action_s = ScaleBy::create(2, 2); + auto action_rot = RotateBy::create(2.0f, 360.0f); + auto action_s = ScaleBy::create(2.0f, 2.0f); auto action_s_back = action_s->reverse(); auto seq2 = action_rot->reverse(); @@ -2602,10 +2602,10 @@ SpriteBatchNodeChildrenZ::SpriteBatchNodeChildrenZ() sprite1->setPosition(Vec2( s.width/3, s.height/2)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); batch->addChild(sprite1); sprite1->addChild(sprite2, 2); @@ -2619,10 +2619,10 @@ SpriteBatchNodeChildrenZ::SpriteBatchNodeChildrenZ() sprite1->setPosition(Vec2( 2*s.width/3, s.height/2)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); batch->addChild(sprite1); sprite1->addChild(sprite2, -2); @@ -2699,19 +2699,19 @@ SpriteChildrenVisibility::SpriteChildrenVisibility() sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vec2(0,0)); + sprite1->setPosition(Vec2(0.0f,0.0f)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); aParent->addChild(sprite1); sprite1->addChild(sprite2, -2); sprite1->addChild(sprite3, 2); - sprite1->runAction(Blink::create(5, 10)); + sprite1->runAction(Blink::create(5.0f, 10.0f)); // // Sprite @@ -2721,19 +2721,19 @@ SpriteChildrenVisibility::SpriteChildrenVisibility() addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vec2(0,0)); + sprite1->setPosition(Vec2(0.0f,0.0f)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); aParent->addChild(sprite1); sprite1->addChild(sprite2, -2); sprite1->addChild(sprite3, 2); - sprite1->runAction(Blink::create(5, 10)); + sprite1->runAction(Blink::create(5.0f, 10.0f)); } void SpriteChildrenVisibility::onExit() @@ -2769,13 +2769,13 @@ SpriteChildrenVisibilityIssue665::SpriteChildrenVisibilityIssue665() addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vec2(0,0)); + sprite1->setPosition(Vec2(0.0f,0.0f)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); // test issue #665 sprite1->setVisible(false); @@ -2792,13 +2792,13 @@ SpriteChildrenVisibilityIssue665::SpriteChildrenVisibilityIssue665() addChild(aParent, 0); sprite1 = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); - sprite1->setPosition(Vec2(0,0)); + sprite1->setPosition(Vec2(0.0f,0.0f)); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); // test issue #665 sprite1->setVisible(false); @@ -2851,13 +2851,13 @@ SpriteChildrenAnchorPoint::SpriteChildrenAnchorPoint() sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vec2(0,0)); + sprite4->setPosition(Vec2(0.0f,0.0f)); sprite4->setScale( 0.5f ); @@ -2878,13 +2878,13 @@ SpriteChildrenAnchorPoint::SpriteChildrenAnchorPoint() sprite1->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vec2(0,0)); + sprite4->setPosition(Vec2(0.0f,0.0f)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2905,13 +2905,13 @@ SpriteChildrenAnchorPoint::SpriteChildrenAnchorPoint() sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vec2(0,0)); + sprite4->setPosition(Vec2(0.0f,0.0f)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2968,13 +2968,13 @@ SpriteBatchNodeChildrenAnchorPoint::SpriteBatchNodeChildrenAnchorPoint() sprite1->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vec2(0,0)); + sprite4->setPosition(Vec2(0.0f,0.0f)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -2994,13 +2994,13 @@ SpriteBatchNodeChildrenAnchorPoint::SpriteBatchNodeChildrenAnchorPoint() sprite1->setAnchorPoint( Vec2::ANCHOR_MIDDLE ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vec2(0,0)); + sprite4->setPosition(Vec2(0.0f,0.0f)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -3020,13 +3020,13 @@ SpriteBatchNodeChildrenAnchorPoint::SpriteBatchNodeChildrenAnchorPoint() sprite1->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT ); sprite2 = Sprite::createWithSpriteFrameName("grossini_dance_02.png"); - sprite2->setPosition(Vec2(20,30)); + sprite2->setPosition(Vec2(20.0f,30.0f)); sprite3 = Sprite::createWithSpriteFrameName("grossini_dance_03.png"); - sprite3->setPosition(Vec2(-20,30)); + sprite3->setPosition(Vec2(-20.0f,30.0f)); sprite4 = Sprite::createWithSpriteFrameName("grossini_dance_04.png"); - sprite4->setPosition(Vec2(0,0)); + sprite4->setPosition(Vec2(0.0f,0.0f)); sprite4->setScale( 0.5f ); aParent->addChild(sprite1); @@ -3484,7 +3484,7 @@ SpriteNilTexture::SpriteNilTexture() addChild(sprite, 100); sprite = Sprite::create(); - sprite->setTextureRect(Rect(0, 0, 300,300)); + sprite->setTextureRect(Rect(0.0f, 0.0f, 300.0f,300.0f)); sprite->setColor(Color3B::BLUE); sprite->setOpacity(128); sprite->setPosition(Vec2(1*s.width/4, s.height/2)); @@ -3745,19 +3745,19 @@ SpriteBatchBug1217::SpriteBatchBug1217() { auto bn = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 15); - auto s1 = Sprite::createWithTexture(bn->getTexture(), Rect(0, 0, 57, 57)); - auto s2 = Sprite::createWithTexture(bn->getTexture(), Rect(0, 0, 57, 57)); - auto s3 = Sprite::createWithTexture(bn->getTexture(), Rect(0, 0, 57, 57)); + auto s1 = Sprite::createWithTexture(bn->getTexture(), Rect(0.0f, 0.0f, 57.0f, 57.0f)); + auto s2 = Sprite::createWithTexture(bn->getTexture(), Rect(0.0f, 0.0f, 57.0f, 57.0f)); + auto s3 = Sprite::createWithTexture(bn->getTexture(), Rect(0.0f, 0.0f, 57.0f, 57.0f)); s1->setColor(Color3B(255, 0, 0)); s2->setColor(Color3B(0, 255, 0)); s3->setColor(Color3B(0, 0, 255)); - s1->setPosition(Vec2(20,200)); - s2->setPosition(Vec2(100,0)); - s3->setPosition(Vec2(100,0)); + s1->setPosition(Vec2(20.0f,200.0f)); + s2->setPosition(Vec2(100.0f,0.0f)); + s3->setPosition(Vec2(100.0f,0.0f)); - bn->setPosition(Vec2(0,0)); + bn->setPosition(Vec2(0.0f,0.0f)); //!!!!! s1->addChild(s2); @@ -4285,24 +4285,24 @@ NodeSort::NodeSort() _node = Node::create(); addChild(_node, 0, 0); - _sprite1 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite1->setPosition(Vec2(100, 160)); + _sprite1 = Sprite::create("Images/piece.png", Rect(128.0f, 0.0f, 64.0f, 64.0f)); + _sprite1->setPosition(Vec2(100.0f, 160.0f)); _node->addChild(_sprite1, -6, 1); - _sprite2 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite2->setPosition(Vec2(164, 160)); + _sprite2 = Sprite::create("Images/piece.png", Rect(128.0f, 0.0f, 64.0f, 64.0f)); + _sprite2->setPosition(Vec2(164.0f, 160.0f)); _node->addChild(_sprite2, -6, 2); - _sprite4 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite4->setPosition(Vec2(292, 160)); + _sprite4 = Sprite::create("Images/piece.png", Rect(128.0f, 0.0f, 64.0f, 64.0f)); + _sprite4->setPosition(Vec2(292.0f, 160.0f)); _node->addChild(_sprite4, -3, 4); - _sprite3 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite3->setPosition(Vec2(228, 160)); + _sprite3 = Sprite::create("Images/piece.png", Rect(128.0f, 0.0f, 64.0f, 64.0f)); + _sprite3->setPosition(Vec2(228.0f, 160.0f)); _node->addChild(_sprite3, -4, 3); - _sprite5 = Sprite::create("Images/piece.png", Rect(128, 0, 64, 64)); - _sprite5->setPosition(Vec2(356, 160)); + _sprite5 = Sprite::create("Images/piece.png", Rect(128.0f, 0.0f, 64.0f, 64.0f)); + _sprite5->setPosition(Vec2(356.0f, 160.0f)); _node->addChild(_sprite5, -3, 5); schedule(CC_CALLBACK_1(NodeSort::reorderSprite, this), "reorder_sprite_key"); @@ -4346,24 +4346,24 @@ SpriteBatchNodeReorderSameIndex::SpriteBatchNodeReorderSameIndex() _batchNode = SpriteBatchNode::create("Images/piece.png", 15); addChild(_batchNode, 1, 0); - _sprite1 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite1->setPosition(Vec2(100,160)); + _sprite1 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128.0f,0.0f,64.0f,64.0f)); + _sprite1->setPosition(Vec2(100.0f,160.0f)); _batchNode->addChild(_sprite1, 3, 1); - _sprite2= Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite2->setPosition(Vec2(164,160)); + _sprite2= Sprite::createWithTexture(_batchNode->getTexture(), Rect(128.0f,0.0f,64.0f,64.0f)); + _sprite2->setPosition(Vec2(164.0f,160.0f)); _batchNode->addChild(_sprite2, 4, 2); - _sprite3 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite3->setPosition(Vec2(228,160)); + _sprite3 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128.0f,0.0f,64.0f,64.0f)); + _sprite3->setPosition(Vec2(228.0f,160.0f)); _batchNode->addChild(_sprite3, 4, 3); - _sprite4 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite4->setPosition(Vec2(292,160)); + _sprite4 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128.0f,0.0f,64.0f,64.0f)); + _sprite4->setPosition(Vec2(292.0f,160.0f)); _batchNode->addChild(_sprite4, 5, 4); - _sprite5 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128,0,64,64)); - _sprite5->setPosition(Vec2(356,160)); + _sprite5 = Sprite::createWithTexture(_batchNode->getTexture(), Rect(128.0f,0.0f,64.0f,64.0f)); + _sprite5->setPosition(Vec2(356.0f,160.0f)); _batchNode->addChild(_sprite5, 6, 5); @@ -4965,13 +4965,13 @@ SpriteCullTest1::SpriteCullTest1() grossini->setPosition(s.width/2, s.height/2); - auto right = MoveBy::create(3, Vec2(s.width*2,0)); + auto right = MoveBy::create(3, Vec2(s.width*2,0.0f)); auto back1 = right->reverse(); - auto left = MoveBy::create(3, Vec2(-s.width*2,0)); + auto left = MoveBy::create(3, Vec2(-s.width*2,0.0f)); auto back2 = left->reverse(); - auto up = MoveBy::create(3, Vec2(0,s.height*2)); + auto up = MoveBy::create(3, Vec2(0.0f,s.height*2)); auto back3 = up->reverse(); - auto down = MoveBy::create(3, Vec2(0,-s.height*2)); + auto down = MoveBy::create(3, Vec2(0.0f,-s.height*2)); auto back4 = down->reverse(); auto seq = Sequence::create(right, back1, left, back2, up, back3, down, back4, nullptr); @@ -5004,13 +5004,13 @@ SpriteCullTest2::SpriteCullTest2() grossini->setPosition(s.width/2, s.height/2); - auto right = MoveBy::create(3, Vec2(s.width*2,0)); + auto right = MoveBy::create(3, Vec2(s.width*2,0.0f)); auto back1 = right->reverse(); - auto left = MoveBy::create(3, Vec2(-s.width*2,0)); + auto left = MoveBy::create(3, Vec2(-s.width*2,0.0f)); auto back2 = left->reverse(); - auto up = MoveBy::create(3, Vec2(0,s.height*2)); + auto up = MoveBy::create(3, Vec2(0.0f,s.height*2)); auto back3 = up->reverse(); - auto down = MoveBy::create(3, Vec2(0,-s.height*2)); + auto down = MoveBy::create(3, Vec2(0.0f,-s.height*2)); auto back4 = down->reverse(); grossini->setScale(0.1f); @@ -5043,18 +5043,18 @@ Sprite3DRotationTest::Sprite3DRotationTest() //Create reference sprite that's rotating based on there anchor point auto s1 = Sprite::create("Images/grossini.png"); s1->setPosition(s.width/4, s.height/4 * 3); - s1->setAnchorPoint(Vec2(0, 0)); - s1->runAction(RepeatForever::create(RotateBy::create(6, 360))); + s1->setAnchorPoint(Vec2(0.0f, 0.0f)); + s1->runAction(RepeatForever::create(RotateBy::create(6.0f, 360.0f))); addChild(s1); auto s2 = Sprite::create("Images/grossini.png"); s2->setPosition(s.width/4 * 3, s.height/4 * 3); - s2->runAction(RepeatForever::create(RotateBy::create(6, 360))); + s2->runAction(RepeatForever::create(RotateBy::create(6.0f, 360.0f))); addChild(s2); sprite1 = Sprite::create("Images/grossini.png"); sprite1->setPosition(s.width/4, s.height/4); - sprite1->setAnchorPoint(Vec2(0,0)); + sprite1->setAnchorPoint(Vec2(0.0f,0.0f)); addChild(sprite1); @@ -5125,8 +5125,8 @@ SpriteSlice9Test1::SpriteSlice9Test1() addChild(s1); s1->setPosition(s.width*1/4, s.height*i/3); s1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); - s1->setContentSize(Size(s1->getContentSize().width, 200)); - auto action1 = RepeatForever::create(RotateBy::create(5, 360)); + s1->setContentSize(Size(s1->getContentSize().width, 200.0f)); + auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s1->runAction(action1); //Create reference sprite that's rotating based on there anchor point @@ -5134,8 +5134,8 @@ SpriteSlice9Test1::SpriteSlice9Test1() addChild(s2); s2->setPosition(s.width*2/4, s.height*i/3); s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - s2->setContentSize(Size(s2->getContentSize().width, 200)); - auto action2 = RepeatForever::create(RotateBy::create(5, 360)); + s2->setContentSize(Size(s2->getContentSize().width, 200.0f)); + auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s2->runAction(action2); //Create reference sprite that's rotating based on there anchor point @@ -5143,14 +5143,14 @@ SpriteSlice9Test1::SpriteSlice9Test1() addChild(s3); s3->setPosition(s.width*3/4, s.height*i/3); s3->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); - s3->setContentSize(Size(s3->getContentSize().width, 200)); - auto action3 = RepeatForever::create(RotateBy::create(5, 360)); + s3->setContentSize(Size(s3->getContentSize().width, 200.0f)); + auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s3->runAction(action3); if (i==2) { - s3->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); - s2->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); - s1->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); + s3->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); + s2->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); + s1->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); } // "anchor points" @@ -5190,8 +5190,8 @@ SpriteSlice9Test2::SpriteSlice9Test2() addChild(s1); s1->setPosition(s.width*1/4, s.height*i/3); s1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); - s1->setContentSize(Size(80, s1->getContentSize().height)); - auto action1 = RepeatForever::create(RotateBy::create(5, 360)); + s1->setContentSize(Size(80.0f, s1->getContentSize().height)); + auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s1->runAction(action1); //Create reference sprite that's rotating based on there anchor point @@ -5199,8 +5199,8 @@ SpriteSlice9Test2::SpriteSlice9Test2() addChild(s2); s2->setPosition(s.width*2/4, s.height*i/3); s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - s2->setContentSize(Size(80, s2->getContentSize().height)); - auto action2 = RepeatForever::create(RotateBy::create(5, 360)); + s2->setContentSize(Size(80.0f, s2->getContentSize().height)); + auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s2->runAction(action2); //Create reference sprite that's rotating based on there anchor point @@ -5208,14 +5208,14 @@ SpriteSlice9Test2::SpriteSlice9Test2() addChild(s3); s3->setPosition(s.width*3/4, s.height*i/3); s3->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); - s3->setContentSize(Size(80, s3->getContentSize().height)); - auto action3 = RepeatForever::create(RotateBy::create(5, 360)); + s3->setContentSize(Size(80.0f, s3->getContentSize().height)); + auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s3->runAction(action3); if (i==2) { - s3->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); - s2->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); - s1->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); + s3->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); + s2->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); + s1->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); } // "anchor points" @@ -5254,7 +5254,7 @@ SpriteSlice9Test3::SpriteSlice9Test3() s1->setPosition(s.width*1/4, s.height*i/3); s1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); s1->setContentSize(s1->getContentSize()); - auto action1 = RepeatForever::create(RotateBy::create(5, 360)); + auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s1->runAction(action1); //Create reference sprite that's rotating based on there anchor point @@ -5263,7 +5263,7 @@ SpriteSlice9Test3::SpriteSlice9Test3() s2->setPosition(s.width*2/4, s.height*i/3); s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); s2->setContentSize(s2->getContentSize() * 2); - auto action2 = RepeatForever::create(RotateBy::create(5, 360)); + auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s2->runAction(action2); //Create reference sprite that's rotating based on there anchor point @@ -5272,7 +5272,7 @@ SpriteSlice9Test3::SpriteSlice9Test3() s3->setPosition(s.width*3/4, s.height*i/3); s3->setAnchorPoint(Vec2::ANCHOR_MIDDLE); s3->setContentSize(s3->getContentSize() * 3); - auto action3 = RepeatForever::create(RotateBy::create(5, 360)); + auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s3->runAction(action3); // enable slice 9, only in the first row @@ -5319,7 +5319,7 @@ SpriteSlice9Test4::SpriteSlice9Test4() s1->setPosition(s.width*1/4, s.height*i/3); s1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); s1->setContentSize(s1->getContentSize() * 2); - auto action1 = RepeatForever::create(RotateBy::create(5, 360)); + auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s1->runAction(action1); //Create reference sprite that's rotating based on there anchor point @@ -5328,7 +5328,7 @@ SpriteSlice9Test4::SpriteSlice9Test4() s2->setPosition(s.width*2/4, s.height*i/3); s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); s2->setContentSize(s2->getContentSize() * 3); - auto action2 = RepeatForever::create(RotateBy::create(5, 360)); + auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s2->runAction(action2); //Create reference sprite that's rotating based on there anchor point @@ -5337,7 +5337,7 @@ SpriteSlice9Test4::SpriteSlice9Test4() s3->setPosition(s.width*3/4, s.height*i/3); s3->setAnchorPoint(Vec2::ANCHOR_MIDDLE); s3->setContentSize(s3->getContentSize() * 4); - auto action3 = RepeatForever::create(RotateBy::create(5, 360)); + auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); s3->runAction(action3); // enable slice 9, only in the first row diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp index 500affd0ea..8e5bd68e29 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp @@ -147,7 +147,7 @@ TileMapTest::TileMapTest() addChild(map, 0, kTagTileMap); - map->setAnchorPoint( Vec2(0, 0.5f) ); + map->setAnchorPoint( Vec2(0.0f, 0.5f) ); auto scale = ScaleBy::create(4, 0.8f); auto scaleBack = scale->reverse(); @@ -383,7 +383,7 @@ TMXOrthoTest4::TMXOrthoTest4() child->getTexture()->setAntiAliasTexParameters(); } - map->setAnchorPoint(Vec2(0, 0)); + map->setAnchorPoint(Vec2(0.0f, 0.0f)); auto layer = map->getLayer("Layer 0"); auto s = layer->getLayerSize(); @@ -391,11 +391,11 @@ TMXOrthoTest4::TMXOrthoTest4() layer->setOpacity(128); Sprite* sprite; - sprite = layer->getTileAt(Vec2(0,0)); + sprite = layer->getTileAt(Vec2(0.0f,0.0f)); sprite->setScale(2); - sprite = layer->getTileAt(Vec2(s.width-1,0)); + sprite = layer->getTileAt(Vec2(s.width-1,0.0f)); sprite->setScale(2); - sprite = layer->getTileAt(Vec2(0,s.height-1)); + sprite = layer->getTileAt(Vec2(0.0f,s.height-1)); sprite->setScale(2); sprite = layer->getTileAt(Vec2(s.width-1,s.height-1)); sprite->setScale(2); @@ -412,10 +412,10 @@ void TMXOrthoTest4::removeSprite(float dt) auto layer = map->getLayer("Layer 0"); auto s = layer->getLayerSize(); - auto sprite = layer->getTileAt( Vec2(s.width-1,0) ); + auto sprite = layer->getTileAt( Vec2(s.width-1,0.0f) ); auto sprite2 = layer->getTileAt(Vec2(s.width-1, s.height-1)); layer->removeChild(sprite, true); - auto sprite3 = layer->getTileAt(Vec2(2, s.height-1)); + auto sprite3 = layer->getTileAt(Vec2(2.0f, s.height-1)); layer->removeChild(sprite3, true); layer->removeChild(sprite2, true); } @@ -462,7 +462,7 @@ TMXReadWriteTest::TMXReadWriteTest() tile2->setAnchorPoint( Vec2(0.5f, 0.5f) ); tile3->setAnchorPoint( Vec2(0.5f, 0.5f) ); - auto move = MoveBy::create(0.5f, Vec2(0,160)); + auto move = MoveBy::create(0.5f, Vec2(0.0f,160.0f)); auto rotate = RotateBy::create(2, 360); auto scale = ScaleBy::create(2, 5); auto opacity = FadeOut::create(2); @@ -882,7 +882,7 @@ TMXResizeTest::TMXResizeTest() { for (unsigned int x = 0; x < ls.width; x++) { - layer->setTileGID(1, Vec2( x, y ) ); + layer->setTileGID(1, Vec2( (float)x, (float)y ) ); } } } @@ -911,19 +911,19 @@ TMXIsoZorder::TMXIsoZorder() auto s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - map->setPosition(Vec2(-s.width/2,0)); + map->setPosition(Vec2(-s.width/2,0.0f)); _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, (int)map->getChildren().size() ); _tamara->retain(); int mapWidth = map->getMapSize().width * map->getTileSize().width; - _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2,0))); + _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2.0f,0.0f))); _tamara->setScale(0.5); - _tamara->setAnchorPoint(Vec2(0.5f,0)); + _tamara->setAnchorPoint(Vec2(0.5f,0.0f)); - auto move = MoveBy::create(10, Vec2(300,250)); + auto move = MoveBy::create(10, Vec2(300.0f,250.0f)); auto back = move->reverse(); auto seq = Sequence::create(move, back,nullptr); _tamara->runAction( RepeatForever::create(seq) ); @@ -986,10 +986,10 @@ TMXOrthoZorder::TMXOrthoZorder() _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, (int)map->getChildren().size()); _tamara->retain(); - _tamara->setAnchorPoint(Vec2(0.5f,0)); + _tamara->setAnchorPoint(Vec2(0.5f,0.0f)); - auto move = MoveBy::create(10, Vec2(400,450)); + auto move = MoveBy::create(10, Vec2(400.0f,450.0f)); auto back = move->reverse(); auto seq = Sequence::create(move, back,nullptr); _tamara->runAction( RepeatForever::create(seq)); @@ -1042,7 +1042,7 @@ TMXIsoVertexZ::TMXIsoVertexZ() addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); - map->setPosition( Vec2(-s.width/2,0) ); + map->setPosition( Vec2(-s.width/2,0.0f) ); CCLOG("ContentSize: %f, %f", s.width,s.height); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you @@ -1190,7 +1190,7 @@ TMXIsoMoveLayer::TMXIsoMoveLayer() auto map = TMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); - map->setPosition(Vec2(-700,-50)); + map->setPosition(Vec2(-700.0f,-50.0f)); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); @@ -1451,9 +1451,9 @@ TMXBug987::TMXBug987() node->getTexture()->setAntiAliasTexParameters(); } - map->setAnchorPoint(Vec2(0, 0)); + map->setAnchorPoint(Vec2(0.0f, 0.0f)); auto layer = map->getLayer("Tile Layer 1"); - layer->setTileGID(3, Vec2(2,2)); + layer->setTileGID(3, Vec2(2.0f,2.0f)); } std::string TMXBug987::title() const diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp b/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp index 727b7a316c..19b731abc3 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp @@ -132,7 +132,7 @@ TileMapTestNew::TileMapTestNew() addChild(map, 0, kTagTileMap); - map->setAnchorPoint( Vec2(0, 0.5f) ); + map->setAnchorPoint( Vec2(0.0f, 0.5f) ); auto scale = ScaleBy::create(4, 0.8f); auto scaleBack = scale->reverse(); @@ -224,7 +224,7 @@ TMXOrthoTestNew::TMXOrthoTestNew() //auto color = LayerColor::create( Color4B(64,64,64,255) ); //addChild(color, -1); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); addChild(map, 0, kTagTileMap); @@ -267,7 +267,7 @@ std::string TMXOrthoTestNew::title() const //------------------------------------------------------------------ TMXOrthoTest2New::TMXOrthoTest2New() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test1.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test1.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -288,7 +288,7 @@ std::string TMXOrthoTest2New::title() const //------------------------------------------------------------------ TMXOrthoTest3New::TMXOrthoTest3New() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test3.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test3.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -310,23 +310,23 @@ std::string TMXOrthoTest3New::title() const //------------------------------------------------------------------ TMXOrthoTest4New::TMXOrthoTest4New() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test4.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test4.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s1 = map->getContentSize(); CCLOG("ContentSize: %f, %f", s1.width,s1.height); - map->setAnchorPoint(Vec2(0, 0)); + map->setAnchorPoint(Vec2(0.0f, 0.0f)); auto layer = map->getLayer("Layer 0"); auto s = layer->getLayerSize(); Sprite* sprite; - sprite = layer->getTileAt(Vec2(0,0)); + sprite = layer->getTileAt(Vec2(0.0f,0.0f)); sprite->setScale(2); - sprite = layer->getTileAt(Vec2(s.width-1,0)); + sprite = layer->getTileAt(Vec2(s.width-1,0.0f)); sprite->setScale(2); - sprite = layer->getTileAt(Vec2(0,s.height-1)); + sprite = layer->getTileAt(Vec2(0.0f,s.height-1)); sprite->setScale(2); sprite = layer->getTileAt(Vec2(s.width-1,s.height-1)); sprite->setScale(2); @@ -339,14 +339,14 @@ void TMXOrthoTest4New::removeSprite(float dt) { unschedule(CC_SCHEDULE_SELECTOR(TMXOrthoTest4New::removeSprite)); - auto map = static_cast( getChildByTag(kTagTileMap) ); + auto map = static_cast( getChildByTag(kTagTileMap) ); auto layer = map->getLayer("Layer 0"); auto s = layer->getLayerSize(); - auto sprite = layer->getTileAt( Vec2(s.width-1,0) ); + auto sprite = layer->getTileAt( Vec2(s.width-1,0.0f) ); auto sprite2 = layer->getTileAt(Vec2(s.width-1, s.height-1)); layer->removeChild(sprite, true); - auto sprite3 = layer->getTileAt(Vec2(2, s.height-1)); + auto sprite3 = layer->getTileAt(Vec2(2.0f, s.height-1)); layer->removeChild(sprite3, true); layer->removeChild(sprite2, true); } @@ -372,7 +372,7 @@ TMXReadWriteTestNew::TMXReadWriteTestNew() { _gid = 0; - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -392,7 +392,7 @@ TMXReadWriteTestNew::TMXReadWriteTestNew() tile2->setAnchorPoint( Vec2(0.5f, 0.5f) ); tile3->setAnchorPoint( Vec2(0.5f, 0.5f) ); - auto move = MoveBy::create(0.5f, Vec2(0,160)); + auto move = MoveBy::create(0.5f, Vec2(0.0f,160.0f)); auto rotate = RotateBy::create(2, 360); auto scale = ScaleBy::create(2, 5); auto opacity = FadeOut::create(2); @@ -438,8 +438,8 @@ void TMXReadWriteTestNew::removeSprite(Node* sender) void TMXReadWriteTestNew::updateCol(float dt) { - auto map = (cocos2d::experimental::TMXTiledMap*)getChildByTag(kTagTileMap); - auto layer = (cocos2d::experimental::TMXLayer*)map->getChildByTag(0); + auto map = (cocos2d::FastTMXTiledMap*)getChildByTag(kTagTileMap); + auto layer = (cocos2d::FastTMXLayer*)map->getChildByTag(0); ////----CCLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads()); ////----CCLOG("++++children: %d", layer->getChildren()->count() ); @@ -459,8 +459,8 @@ void TMXReadWriteTestNew::repaintWithGID(float dt) { // unschedule:_cmd); - auto map = (cocos2d::experimental::TMXTiledMap*)getChildByTag(kTagTileMap); - auto layer = (cocos2d::experimental::TMXLayer*)map->getChildByTag(0); + auto map = (cocos2d::FastTMXTiledMap*)getChildByTag(kTagTileMap); + auto layer = (cocos2d::FastTMXLayer*)map->getChildByTag(0); auto s = layer->getLayerSize(); for( int x=0; xgetChildByTag(0); + auto map = (cocos2d::FastTMXTiledMap*)getChildByTag(kTagTileMap); + auto layer = (cocos2d::FastTMXLayer*)map->getChildByTag(0); auto s = layer->getLayerSize(); for( int y=0; y< s.height; y++ ) @@ -502,7 +502,7 @@ TMXHexTestNew::TMXHexTestNew() auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/hexa-test.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/hexa-test.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -524,7 +524,7 @@ TMXIsoTestNew::TMXIsoTestNew() auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test.tmx"); addChild(map, 0, kTagTileMap); // move map to the center of the screen @@ -548,7 +548,7 @@ TMXIsoTest1New::TMXIsoTest1New() auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test1.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test1.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -572,7 +572,7 @@ TMXIsoTest2New::TMXIsoTest2New() auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test2.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test2.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -599,7 +599,7 @@ TMXUncompressedTestNew::TMXUncompressedTestNew() auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test2-uncompressed.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test2-uncompressed.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -634,7 +634,7 @@ std::string TMXUncompressedTestNew::title() const //------------------------------------------------------------------ TMXTilesetTestNew::TMXTilesetTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -653,7 +653,7 @@ std::string TMXTilesetTestNew::title() const //------------------------------------------------------------------ TMXOrthoObjectsTestNew::TMXOrthoObjectsTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/ortho-objects.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/ortho-objects.tmx"); addChild(map, -1, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -703,7 +703,7 @@ std::string TMXOrthoObjectsTestNew::subtitle() const TMXIsoObjectsTestNew::TMXIsoObjectsTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-objectgroup.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test-objectgroup.tmx"); addChild(map, -1, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -754,13 +754,13 @@ std::string TMXIsoObjectsTestNew::subtitle() const TMXResizeTestNew::TMXResizeTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - cocos2d::experimental::TMXLayer* layer; + cocos2d::FastTMXLayer* layer; layer = map->getLayer("Layer 0"); auto ls = layer->getLayerSize(); @@ -768,7 +768,7 @@ TMXResizeTestNew::TMXResizeTestNew() { for (unsigned int x = 0; x < ls.width; x++) { - layer->setTileGID(1, Vec2( x, y ) ); + layer->setTileGID(1, Vec2((float)x, (float)y ) ); } } } @@ -792,22 +792,22 @@ std::string TMXResizeTestNew::subtitle() const TMXIsoZorderNew::TMXIsoZorderNew() { Director::getInstance()->getRenderer()->setDepthTest(false); - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-zorder.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test-zorder.tmx"); addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - map->setPosition(Vec2(-s.width/2,0)); + map->setPosition(Vec2(-s.width/2,0.0f)); _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, (int)map->getChildren().size() ); _tamara->retain(); int mapWidth = map->getMapSize().width * map->getTileSize().width; - _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2,0))); - _tamara->setAnchorPoint(Vec2(0.5f,0)); + _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2.0f,0.0f))); + _tamara->setAnchorPoint(Vec2(0.5f,0.0f)); - auto move = MoveBy::create(10, Vec2(300,250)); + auto move = MoveBy::create(10, Vec2(300.0f,250.0f)); auto back = move->reverse(); auto seq = Sequence::create(move, back,nullptr); _tamara->runAction( RepeatForever::create(seq) ); @@ -861,7 +861,7 @@ std::string TMXIsoZorderNew::subtitle() const //------------------------------------------------------------------ TMXOrthoZorderNew::TMXOrthoZorderNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test-zorder.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test-zorder.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -870,10 +870,10 @@ TMXOrthoZorderNew::TMXOrthoZorderNew() _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, (int)map->getChildren().size()); _tamara->retain(); - _tamara->setAnchorPoint(Vec2(0.5f,0)); + _tamara->setAnchorPoint(Vec2(0.5f,0.0f)); - auto move = MoveBy::create(10, Vec2(400,450)); + auto move = MoveBy::create(10, Vec2(400.0f,450.0f)); auto back = move->reverse(); auto seq = Sequence::create(move, back,nullptr); _tamara->runAction( RepeatForever::create(seq)); @@ -922,17 +922,17 @@ std::string TMXOrthoZorderNew::subtitle() const //------------------------------------------------------------------ TMXIsoVertexZNew::TMXIsoVertexZNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-vertexz.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test-vertexz.tmx"); addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); - map->setPosition( Vec2(-s.width/2,0) ); + map->setPosition( Vec2(-s.width/2,0.0f) ); CCLOG("ContentSize: %f, %f", s.width,s.height); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any Sprite and it will work OK. auto layer = map->getLayer("Trees"); - _tamara = layer->getTileAt( Vec2(29,29) ); + _tamara = layer->getTileAt( Vec2(29.0f,29.0f) ); _tamara->retain(); auto move = MoveBy::create(10, Vec2(300,250) * (1/CC_CONTENT_SCALE_FACTOR())); @@ -996,7 +996,7 @@ std::string TMXIsoVertexZNew::subtitle() const //------------------------------------------------------------------ TMXOrthoVertexZNew::TMXOrthoVertexZNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test-vertexz.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test-vertexz.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -1069,10 +1069,10 @@ std::string TMXOrthoVertexZNew::subtitle() const //------------------------------------------------------------------ TMXIsoMoveLayerNew::TMXIsoMoveLayerNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); - map->setPosition(Vec2(-700,-50)); + map->setPosition(Vec2(-700.0f,-50.0f)); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); @@ -1096,7 +1096,7 @@ std::string TMXIsoMoveLayerNew::subtitle() const //------------------------------------------------------------------ TMXOrthoMoveLayerNew::TMXOrthoMoveLayerNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test-movelayer.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -1121,7 +1121,7 @@ std::string TMXOrthoMoveLayerNew::subtitle() const TMXTilePropertyTestNew::TMXTilePropertyTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/ortho-tile-property.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/ortho-tile-property.tmx"); addChild(map ,0 ,kTagTileMap); for(int i=1;i<=20;i++){ @@ -1150,7 +1150,7 @@ std::string TMXTilePropertyTestNew::subtitle() const TMXOrthoFlipTestNew::TMXOrthoFlipTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -1173,7 +1173,7 @@ std::string TMXOrthoFlipTestNew::title() const TMXOrthoFlipRunTimeTestNew::TMXOrthoFlipRunTimeTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); @@ -1197,7 +1197,7 @@ std::string TMXOrthoFlipRunTimeTestNew::subtitle() const void TMXOrthoFlipRunTimeTestNew::flipIt(float dt) { - auto map = (cocos2d::experimental::TMXTiledMap*) getChildByTag(kTagTileMap); + auto map = (cocos2d::FastTMXTiledMap*) getChildByTag(kTagTileMap); auto layer = map->getLayer("Layer 0"); //blue diamond @@ -1245,7 +1245,7 @@ TMXOrthoFromXMLTestNew::TMXOrthoFromXMLTestNew() auto fileUtils = FileUtils::getInstance(); std::string str = fileUtils->getStringFromFile(fileUtils->fullPathForFilename(file.c_str())); - auto map = cocos2d::experimental::TMXTiledMap::createWithXML(str ,resources.c_str()); + auto map = cocos2d::FastTMXTiledMap::createWithXML(str ,resources.c_str()); addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); @@ -1271,7 +1271,7 @@ TMXOrthoXMLFormatTestNew::TMXOrthoXMLFormatTestNew() // 1. load xml format tilemap // 2. gid lower than firstgid is ignored // 3. firstgid in tsx is ignored, tile property in tsx loaded correctly. - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/xml-test.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/xml-test.tmx"); addChild(map, 0, kTagTileMap); auto s = map->getContentSize(); @@ -1297,13 +1297,13 @@ std::string TMXOrthoXMLFormatTestNew::title() const //------------------------------------------------------------------ TMXBug987New::TMXBug987New() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/orthogonal-test6.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/orthogonal-test6.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s1 = map->getContentSize(); CCLOG("ContentSize: %f, %f", s1.width,s1.height); - map->setAnchorPoint(Vec2(0, 0)); + map->setAnchorPoint(Vec2(0.0f, 0.0f)); auto layer = map->getLayer("Tile Layer 1"); layer->setTileGID(3, Vec2(2,2)); } @@ -1325,7 +1325,7 @@ std::string TMXBug987New::subtitle() const //------------------------------------------------------------------ TMXBug787New::TMXBug787New() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-bug787.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/iso-test-bug787.tmx"); addChild(map, 0, kTagTileMap); map->setScale(0.25f); @@ -1348,7 +1348,7 @@ std::string TMXBug787New::subtitle() const //------------------------------------------------------------------ TMXGIDObjectsTestNew::TMXGIDObjectsTestNew() { - auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/test-object-layer.tmx"); + auto map = cocos2d::FastTMXTiledMap::create("TileMaps/test-object-layer.tmx"); addChild(map, -1, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 0af09265f8..66c6a762ff 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -109,7 +109,7 @@ bool UIButtonTest::init() auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); return true; @@ -198,9 +198,9 @@ bool UIButtonTest_Scale9::init() Button* button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); // open scale9 render button->setScale9Enabled(true); - button->setContentSize(Size(150, 70)); + button->setContentSize(Size(150.0f, 70.0f)); button->setPosition(Vec2(-button->getContentSize().width - 10, widgetSize.height / 2.0f)); - auto moveBy = MoveBy::create(1.0, Vec2(widgetSize.width/2, 0)); + auto moveBy = MoveBy::create(1.0f, Vec2(widgetSize.width/2, 0.0f)); auto moveByReverse = moveBy->reverse()->clone(); button->runAction(RepeatForever::create( Sequence::create(moveBy,moveByReverse, NULL))); @@ -290,7 +290,7 @@ bool UIButtonTest_Scale9_State_Change::init() button->ignoreContentAdaptWithSize(false); button->setScale9Enabled(true); button->setPosition(Vec2(widgetSize.width / 2.0f - 100, widgetSize.height / 2.0f)); - button->setContentSize(Size(180, 60)); + button->setContentSize(Size(180.0f, 60.0f)); button->setTitleText("Hello Scale9"); button->setPressedActionEnabled(false); button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9_State_Change::touchEvent, this)); @@ -302,7 +302,7 @@ bool UIButtonTest_Scale9_State_Change::init() button2->setScale9Enabled(true); button2->setTitleText("Hello scale9"); button2->setPosition(Vec2(widgetSize.width / 2.0f + 100, widgetSize.height / 2.0f)); - button2->setContentSize(Size(180, 60)); + button2->setContentSize(Size(180.0f, 60.0f)); button2->setPressedActionEnabled(true); button2->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9_State_Change::touchEvent, this)); _uiLayer->addChild(button2); @@ -387,7 +387,7 @@ bool UIButtonTest_PressedAction::init() _uiLayer->addChild(button); Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); - button2->setPosition(button->getPosition() + Vec2(100,0)); + button2->setPosition(button->getPosition() + Vec2(100.0f,0.0f)); button2->setName("button2"); _uiLayer->addChild(button2); @@ -447,7 +447,7 @@ bool UIButtonTest_Title::init() // Add a label in which the text button events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -475,7 +475,7 @@ bool UIButtonTest_Title::init() TextBMFont *text = TextBMFont::create("BMFont", "cocosui/bitmapFontTest2.fnt"); - text->setPosition(button->getPosition() + Vec2(button->getContentSize().width/2 + 50,0)); + text->setPosition(button->getPosition() + Vec2(button->getContentSize().width/2 + 50,0.0f)); text->setColor(Color3B::YELLOW); text->setOpacity(50); text->setName("text"); @@ -485,7 +485,7 @@ bool UIButtonTest_Title::init() button2->setTitleText("BMFont"); //the change of font size will take no effect. button2->setTitleFontSize(30); - button2->setPosition(Vec2(button->getPosition() + Vec2(50,-80))); + button2->setPosition(Vec2(button->getPosition() + Vec2(50.0f,-80.0f))); this->addChild(button2); _uiLayer->addChild(text); @@ -676,7 +676,7 @@ void UIButtonTestSwitchScale9::touchEvent(Ref *pSender, Widget::TouchEventType t _displayValueLabel->setString(StringUtils::format("Touch Up")); auto btn = ((Button*)pSender); btn->setScale9Enabled(!btn->isScale9Enabled()); - btn->setContentSize(Size(200,100)); + btn->setContentSize(Size(200.0f,100.0f)); } break; @@ -787,7 +787,7 @@ bool UIButtonTextOnly::init() button->getContentSize().height); button->setZoomScale(0.3f); button->setPressedActionEnabled(true); - button->addClickEventListener([this](Ref* sender) { + button->addClickEventListener([](Ref* sender) { CCLOG("clicked!"); }); _uiLayer->addChild(button); @@ -825,7 +825,7 @@ bool UIButtonIgnoreContentSizeTest::init() auto button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); button->ignoreContentAdaptWithSize(false); - button->setContentSize(Size(200,100)); + button->setContentSize(Size(200.0f,100.0f)); button->setPositionNormalized(Vec2(0.3f, 0.5f)); button->setTitleText("PLAY GAME"); button->setZoomScale(0.3f); @@ -840,7 +840,7 @@ bool UIButtonIgnoreContentSizeTest::init() auto button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); button2->ignoreContentAdaptWithSize(false); - button2->setContentSize(Size(200,100)); + button2->setContentSize(Size(200.0f,100.0f)); button2->setPositionNormalized(Vec2(0.8f, 0.5f)); button2->setTitleText("PLAY GAME"); button2->setZoomScale(0.3f); @@ -1008,7 +1008,7 @@ bool UIButtonNormalDefaultTest::init() // open scale9 render buttonScale9->setScale9Enabled(true); buttonScale9->setPosition(Vec2(widgetSize.width / 2.0f + 50, widgetSize.height / 2.0f + 40)); - buttonScale9->setContentSize(Size(150, 70)); + buttonScale9->setContentSize(Size(150.0f, 70.0f)); buttonScale9->setPressedActionEnabled(true); _uiLayer->addChild(buttonScale9); @@ -1071,7 +1071,7 @@ bool UIButtonDisableDefaultTest::init() // open scale9 render buttonScale9->setScale9Enabled(true); buttonScale9->setPosition(Vec2(widgetSize.width / 2.0f + 50, widgetSize.height / 2.0f + 40)); - buttonScale9->setContentSize(Size(150, 70)); + buttonScale9->setContentSize(Size(150.0f, 70.0f)); buttonScale9->setPressedActionEnabled(true); buttonScale9->setEnabled(false); buttonScale9->setBright(false); @@ -1138,16 +1138,16 @@ bool UIButtonCloneTest::init() auto buttonScale9Copy = (Button*)button->clone(); - buttonScale9Copy->setPosition(button->getPosition() + Vec2(0, -60)); + buttonScale9Copy->setPosition(button->getPosition() + Vec2(0.0f, -60.0f)); buttonScale9Copy->setScale9Enabled(true); - buttonScale9Copy->setContentSize(button->getContentSize() * 1.5); + buttonScale9Copy->setContentSize(button->getContentSize() * 1.5f); this->addChild(buttonScale9Copy); auto buttonScale9Copy2 = (Button*)buttonScale9Copy->clone(); - buttonScale9Copy2->setPosition(buttonCopy->getPosition() + Vec2(0, -60)); + buttonScale9Copy2->setPosition(buttonCopy->getPosition() + Vec2(0.0f, -60.0f)); buttonScale9Copy2->setScale9Enabled(true); - buttonScale9Copy2->setContentSize(buttonCopy->getContentSize() * 1.5); + buttonScale9Copy2->setContentSize(buttonCopy->getContentSize() * 1.5f); this->addChild(buttonScale9Copy2); @@ -1278,13 +1278,13 @@ bool UIButtonScale9ChangeSpriteFrame::init() sprite->setScale9Enabled(true); sprite->setCapInsets(Rect(32, 32, 32, 32)); sprite->setContentSize(Size(96 * 1.5, 96)); - sprite->setNormalizedPosition(Vec2(0.2, 0.5)); + sprite->setNormalizedPosition(Vec2(0.2f, 0.5f)); this->addChild(sprite); auto button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button->setScale9Enabled(true); - button->setContentSize(Size(100, 50)); - button->setNormalizedPosition(Vec2(0.6, 0.5)); + button->setContentSize(Size(100.0f, 50.0f)); + button->setNormalizedPosition(Vec2(0.6f, 0.5f)); button->setTitleText("Press me"); addChild(button); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index e1f0b09eaa..bcc85ec7e0 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -53,7 +53,7 @@ bool UICheckBoxTest::init() // Add a label in which the checkbox events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -79,7 +79,7 @@ bool UICheckBoxTest::init() auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); return true; @@ -139,7 +139,7 @@ bool UICheckBoxDefaultBehaviorTest::init() // Add a label in which the checkbox events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -163,8 +163,8 @@ bool UICheckBoxDefaultBehaviorTest::init() "cocosui/check_box_active.png"); checkBox2->setPosition(Vec2(widgetSize.width / 2.0f - 150, widgetSize.height / 2.0f)); checkBox2->ignoreContentAdaptWithSize(false); - checkBox2->setZoomScale(0.5); - checkBox2->setContentSize(Size(80,80)); + checkBox2->setZoomScale(0.5f); + checkBox2->setContentSize(Size(80.0f,80.0f)); checkBox2->setName("bigCheckBox"); _uiLayer->addChild(checkBox2); @@ -208,7 +208,7 @@ bool UICheckBoxCopyTest::init() // Add a label in which the checkbox events will be displayed _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -227,7 +227,7 @@ bool UICheckBoxCopyTest::init() _uiLayer->addChild(checkBox); auto checkboxCopy = checkBox->clone(); - checkboxCopy->setPosition(checkBox->getPosition() + Vec2(50,0)); + checkboxCopy->setPosition(checkBox->getPosition() + Vec2(50.0f,0.0f)); _uiLayer->addChild(checkboxCopy); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp index 08d00547b4..03f53b4acc 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp @@ -78,7 +78,7 @@ bool UIEditBoxTest::init() "cocosui/animationbuttonpressed.png"); auto buttonSize = button->getContentSize(); button->setTitleText("Single Line"); - button->setPosition(_editName->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + button->setPosition(_editName->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0.0f)); button->addClickEventListener([=](Ref* ref){ _editName->setInputMode(ui::EditBox::InputMode::SINGLE_LINE); }); @@ -100,7 +100,7 @@ bool UIEditBoxTest::init() auto buttonPassword = (ui::Button*)button->clone(); buttonPassword->setTitleText("Multiline"); - buttonPassword->setPosition(_editPassword->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + buttonPassword->setPosition(_editPassword->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0.0f)); buttonPassword->addClickEventListener([=](Ref* ref){ _editPassword->setInputMode(ui::EditBox::InputMode::ANY); }); @@ -126,7 +126,7 @@ bool UIEditBoxTest::init() auto buttonEmail = (ui::Button*)button->clone(); buttonEmail->setTitleText("Multiline"); - buttonEmail->setPosition(_editEmailParent->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + buttonEmail->setPosition(_editEmailParent->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0.0f)); buttonEmail->addClickEventListener([=](Ref* ref){ _editEmail->setInputMode(ui::EditBox::InputMode::ANY); }); @@ -211,7 +211,7 @@ bool UIEditBoxTestToggleVisibility::init() "cocosui/animationbuttonpressed.png"); auto buttonSize = button->getContentSize(); button->setTitleText("Toggle Visibility"); - button->setPosition(_editName->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + button->setPosition(_editName->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0.0f)); button->addClickEventListener([=](Ref* ref){ _editName->setVisible(!_editName->isVisible()); }); @@ -232,7 +232,7 @@ bool UIEditBoxTestToggleVisibility::init() auto buttonPassword = (ui::Button*)button->clone(); buttonPassword->setTitleText("Toggle Visibility"); - buttonPassword->setPosition(_editPassword->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + buttonPassword->setPosition(_editPassword->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0.0f)); buttonPassword->addClickEventListener([=](Ref* ref){ _editPassword->setVisible(!_editPassword->isVisible()); }); @@ -258,7 +258,7 @@ bool UIEditBoxTestToggleVisibility::init() auto buttonEmail = (ui::Button*)button->clone(); buttonEmail->setTitleText("Toggle Visibility"); - buttonEmail->setPosition(_editEmailParent->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + buttonEmail->setPosition(_editEmailParent->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0.0f)); buttonEmail->addClickEventListener([=](Ref* ref){ _editEmail->setVisible(!_editEmail->isVisible()); }); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp index fbfe0aa1cc..96d3638ce1 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp @@ -95,7 +95,7 @@ bool UIFocusTestBase::init() _toggleButton = Button::create("cocosui/switch-mask.png"); _toggleButton->setTitleText("Toggle Loop"); - _toggleButton->setPosition(Vec2(60, winSize.height - 50)); + _toggleButton->setPosition(Vec2(60.0f, winSize.height - 50)); _toggleButton->setTitleColor(Color3B::RED); _toggleButton->setFocusEnabled(false); this->addChild(_toggleButton); @@ -184,7 +184,7 @@ bool UIFocusTestHorizontal::init() Size winSize = Director::getInstance()->getVisibleSize(); _horizontalLayout = HBox::create(); - _horizontalLayout->setPosition(Vec2(20, winSize.height/2 + 40)); + _horizontalLayout->setPosition(Vec2(20.0f, winSize.height/2 + 40)); _uiLayer->addChild(_horizontalLayout); _horizontalLayout->setFocused(true); @@ -500,7 +500,7 @@ bool UIFocusTestNestedLayout3::init() Size winSize = Director::getInstance()->getVisibleSize(); _verticalLayout = VBox::create(); - _verticalLayout->setPosition(Vec2(40, winSize.height - 70)); + _verticalLayout->setPosition(Vec2(40.0f, winSize.height - 70)); _uiLayer->addChild(_verticalLayout); _verticalLayout->setScale(0.8f); @@ -515,10 +515,10 @@ bool UIFocusTestNestedLayout3::init() _verticalLayout->addChild(upperHBox); LinearLayoutParameter *params = LinearLayoutParameter::create(); - params->setMargin(Margin(0,0,50,0)); + params->setMargin(Margin(0.0f,0.0f,50.0f,0.0f)); LinearLayoutParameter *vparams = LinearLayoutParameter::create(); - vparams->setMargin(Margin(10, 0, 0, 140)); + vparams->setMargin(Margin(10.0f, 0.0f, 0.0f, 140.0f)); upperHBox->setLayoutParameter(vparams); int count = 3; @@ -548,7 +548,7 @@ bool UIFocusTestNestedLayout3::init() bottomHBox->setLayoutParameter(vparams); count = 3; LinearLayoutParameter *bottomParams = LinearLayoutParameter::create(); - bottomParams->setMargin(Margin(0, 0, 8, 0)); + bottomParams->setMargin(Margin(0.0f, 0.0f, 8.0f, 0.0f)); for (int i=0; i < count; ++i) { ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); w->setLayoutParameter(bottomParams); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index 4f315b5359..c58ec5c895 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -66,7 +66,7 @@ bool UIImageViewTest::init() auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); return true; @@ -133,8 +133,8 @@ bool UIImageViewTest_Scale9_State_Change::init() ImageView* imageView = ImageView::create("cocosui/ccicon.png"); imageView->ignoreContentAdaptWithSize(false); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(100, 100)); - imageView->setCapInsets(Rect(20,20,20,20)); + imageView->setContentSize(Size(100.0f, 100.0f)); + imageView->setCapInsets(Rect(20.0f,20.0f,20.0f,20.0f)); imageView->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); @@ -181,7 +181,7 @@ bool UIImageViewTest_ContentSize::init() // Create the imageview ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png"); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(200, 80)); + imageView->setContentSize(Size(200.0f, 80.0f)); imageView->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f )); @@ -257,7 +257,7 @@ bool UIImageViewFlipTest::init() auto toggleButton = Button::create(); toggleButton->setTitleText("Toggle FlipX"); - toggleButton->setPosition(imageView->getPosition() + Vec2(-50, - imageView->getContentSize().height/2 - 20)); + toggleButton->setPosition(imageView->getPosition() + Vec2(-50.0f, - imageView->getContentSize().height/2 - 20)); this->addChild(toggleButton); toggleButton->addClickEventListener([=](Ref*){ imageView->setFlippedX(!imageView->isFlippedX()); @@ -265,7 +265,7 @@ bool UIImageViewFlipTest::init() auto toggleScale9 = Button::create(); toggleScale9->setTitleText("Toggle Scale9"); - toggleScale9->setPosition(imageView->getPosition() + Vec2(+50, - imageView->getContentSize().height/2- 20)); + toggleScale9->setPosition(imageView->getPosition() + Vec2(+50.0f, - imageView->getContentSize().height/2- 20)); this->addChild(toggleScale9); toggleScale9->addClickEventListener([=](Ref*){ imageView->setScale9Enabled(!imageView->isScale9Enabled()); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index 9011512ef8..02ea37b7ef 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -46,16 +46,7 @@ UIListViewTests::UIListViewTests() // UIListViewTest_Vertical UIListViewTest_Vertical::UIListViewTest_Vertical() -: _displayValueLabel(nullptr), -_spawnCount(5), //spawnCount should > listview.width / templateWidth + 2 -_totalCount(50), -_bufferZone(45), //bufferZone should be larger than List item width -_updateTimer(0), -_updateInterval(1.0f / 24), // you could tweak this value to adjust ListView data update rate -_lastContentPosY(0), //use this value to detect if we are scrolling left or right -_itemTemplateHeight(0) { - } UIListViewTest_Vertical::~UIListViewTest_Vertical() @@ -104,7 +95,7 @@ bool UIListViewTest_Vertical::init() _listView->setBackGroundImage("cocosui/green_edit.png"); _listView->setGlobalZOrder(200); _listView->setBackGroundImageScale9Enabled(true); - _listView->setContentSize(Size(240, 130)); + _listView->setContentSize(Size(240.0f, 130.0f)); _listView->setPosition(Vec2((widgetSize - _listView->getContentSize()) / 2.0f)); _listView->addEventListener((ui::ListView::ccListViewCallback)CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEvent, this)); _listView->addEventListener((ui::ListView::ccScrollViewCallback)CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEventScrollView,this)); @@ -171,15 +162,15 @@ bool UIListViewTest_Vertical::init() // Labels _indexLabels[0] = Text::create(" ", "fonts/Marker Felt.ttf", 12); _indexLabels[0]->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, position)); + _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(0.0f, position)); _uiLayer->addChild(_indexLabels[0]); _indexLabels[1] = Text::create(" ", "fonts/Marker Felt.ttf", 12); _indexLabels[1]->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(140, 0)); + _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(140.0f, 0.0f)); _uiLayer->addChild(_indexLabels[1]); _indexLabels[2] = Text::create(" ", "fonts/Marker Felt.ttf", 12); _indexLabels[2]->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, -position)); + _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0.0f, -position)); _uiLayer->addChild(_indexLabels[2]); // Callback @@ -303,14 +294,6 @@ void UIListViewTest_Vertical::selectedItemEventScrollView(Ref* pSender, ui::Scro // UIListViewTest_Horizontal UIListViewTest_Horizontal::UIListViewTest_Horizontal() -: _displayValueLabel(nullptr), -_spawnCount(4), //spawnCount should > listview.width / templateWidth + 2 -_totalCount(50), -_bufferZone(140), //bufferZone should be larger than List item width -_updateTimer(0), -_updateInterval(1.0f / 24), // you could tweak this value to adjust ListView data update rate -_lastContentPosX(0), //use this value to detect if we are scrolling left or right -_itemTemplateWidth(0) { } @@ -365,7 +348,7 @@ bool UIListViewTest_Horizontal::init() _listView->setBounceEnabled(true); _listView->setBackGroundImage("cocosui/green_edit.png"); _listView->setBackGroundImageScale9Enabled(true); - _listView->setContentSize(Size(240, 130)); + _listView->setContentSize(Size(240.0f, 130.0f)); _listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - _listView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + @@ -533,7 +516,7 @@ bool Issue12692::init() listView->setBounceEnabled(true); listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); - listView->setContentSize(Size(240, 130)); + listView->setContentSize(Size(240.0f, 130.0f)); listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + @@ -627,7 +610,7 @@ bool Issue8316::init() listView->setTouchEnabled(false); listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); - listView->setContentSize(Size(240, 130)); + listView->setContentSize(Size(240.0f, 130.0f)); listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + @@ -679,7 +662,7 @@ bool UIListViewTest_ScrollToItem::init() _nextIndex = 0; _titleLabel = Text::create("Scroll to item", "fonts/Marker Felt.ttf", 32); _titleLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - _titleLabel->setPosition(Vec2(layerSize / 2) + Vec2(0, _titleLabel->getContentSize().height * 3.15f)); + _titleLabel->setPosition(Vec2(layerSize / 2) + Vec2(0.0f, _titleLabel->getContentSize().height * 3.15f)); _uiLayer->addChild(_titleLabel, 3); // Create the list view @@ -717,7 +700,7 @@ bool UIListViewTest_ScrollToItem::init() auto pButton = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); pButton->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); pButton->setScale(0.8f); - pButton->setPosition(Vec2(layerSize / 2) + Vec2(120, -60)); + pButton->setPosition(Vec2(layerSize / 2) + Vec2(120.0f, -60.0f)); pButton->setTitleText(StringUtils::format("Go to '%d'", _nextIndex)); pButton->addClickEventListener([this, pButton](Ref*) { _listView->scrollToItem(_nextIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); @@ -753,7 +736,7 @@ bool UIListViewTest_Magnetic::init() _titleLabel = Text::create("Magnetic scroll", "fonts/Marker Felt.ttf", 32); _titleLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - _titleLabel->setPosition(Vec2(layerSize / 2) + Vec2(0, _titleLabel->getContentSize().height * 3.15f)); + _titleLabel->setPosition(Vec2(layerSize / 2) + Vec2(0.0f, _titleLabel->getContentSize().height * 3.15f)); _uiLayer->addChild(_titleLabel, 3); // Create the list view @@ -796,10 +779,10 @@ bool UIListViewTest_Magnetic::init() _uiLayer->addChild(_indexLabels[i]); } float deltaX = 145, deltaY = 90; - _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(-deltaX, 0)); // left - _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(deltaX, 0)); // right - _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, deltaY)); // top - _indexLabels[3]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, -deltaY)); // bottom + _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(-deltaX, 0.0f)); // left + _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(deltaX, 0.0f)); // right + _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0.0f, deltaY)); // top + _indexLabels[3]->setPosition(_uiLayer->getContentSize() / 2 + Size(0.0f, -deltaY)); // bottom _indexLabels[4]->setPosition(_uiLayer->getContentSize() / 2 + Size(deltaX, deltaY)); // center // Callback @@ -831,11 +814,11 @@ bool UIListViewTest_Magnetic::init() auto pButton = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); pButton->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); pButton->setScale(0.8f); - pButton->setPosition(Vec2(layerSize / 2) + Vec2(130, -60)); + pButton->setPosition(Vec2(layerSize / 2) + Vec2(130.0f, -60.0f)); pButton->setTitleText("Next Magnetic"); pButton->addClickEventListener([this](Ref*) { ListView::MagneticType eCurrentType = _listView->getMagneticType(); - ListView::MagneticType eNextType; + ListView::MagneticType eNextType = ListView::MagneticType::NONE; std::string sString; if(eCurrentType == ListView::MagneticType::NONE) { @@ -912,7 +895,7 @@ bool UIListViewTest_Padding::init() _titleLabel = Text::create("Set Padding", "fonts/Marker Felt.ttf", 32); _titleLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - _titleLabel->setPosition(Vec2(layerSize / 2) + Vec2(0, _titleLabel->getContentSize().height * 3.15f)); + _titleLabel->setPosition(Vec2(layerSize / 2) + Vec2(0.0f, _titleLabel->getContentSize().height * 3.15f)); _uiLayer->addChild(_titleLabel, 3); // Create the list view @@ -952,7 +935,7 @@ bool UIListViewTest_Padding::init() { auto title = Text::create("Padding", "fonts/Marker Felt.ttf", 14); title->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - title->setPosition(Vec2(30, 170)); + title->setPosition(Vec2(30.0f, 170.0f)); _uiLayer->addChild(title); for (int i = 0; i < 4; ++i) { @@ -961,9 +944,9 @@ bool UIListViewTest_Padding::init() slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosui/sliderProgress.png"); slider->setScale9Enabled(true); - slider->setCapInsets(Rect(0, 0, 0, 0)); - slider->setContentSize(Size(30, 10)); - slider->setPosition(Vec2(60, 150 - (25 * i))); + slider->setCapInsets(Rect(0.0f, 0.0f, 0.0f, 0.0f)); + slider->setContentSize(Size(30.0f, 10.0f)); + slider->setPosition(Vec2(60.0f, 150.0f - (25 * i))); slider->addEventListener(CC_CALLBACK_2(UIListViewTest_Padding::sliderEvent, this)); slider->setTag(i); _uiLayer->addChild(slider); @@ -985,7 +968,7 @@ bool UIListViewTest_Padding::init() { auto text = Text::create(str + "\nPadding=0", "fonts/Marker Felt.ttf", 12); text->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); - text->setPosition(Vec2(layerSize.width - 65, 200 - (40 * i))); + text->setPosition(Vec2(layerSize.width - 65, 200.0f - (40 * i))); _uiLayer->addChild(text); _paddingLabels[i] = text; @@ -1002,10 +985,10 @@ bool UIListViewTest_Padding::init() _uiLayer->addChild(_indexLabels[i]); } float deltaX = 145, deltaY = 90; - _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(-deltaX, 0)); // left - _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(deltaX, 0)); // right - _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, deltaY)); // top - _indexLabels[3]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, -deltaY)); // bottom + _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(-deltaX, 0.0f)); // left + _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(deltaX, 0.0f)); // right + _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0.0f, deltaY)); // top + _indexLabels[3]->setPosition(_uiLayer->getContentSize() / 2 + Size(0.0f, -deltaY)); // bottom _indexLabels[4]->setPosition(_uiLayer->getContentSize() / 2 + Size(deltaX, deltaY)); // center // Callback diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h index 7e59e40ba3..179486f996 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h @@ -48,21 +48,25 @@ protected: float getItemPositionYInView(cocos2d::ui::Widget* item) const; void updateItem(int itemID, int templateID); - cocos2d::ui::Text* _displayValueLabel; - //how many items we actually spawn, these items will be reused. - int _spawnCount; - // how many items we need for the ListView. Usually this is a big number. - int _totalCount; - //when item is away from bufferSzone, we relocate it. - float _bufferZone; - float _itemTemplateHeight; - float _updateInterval; - float _updateTimer; - float _lastContentPosY; - float _reuseItemOffset; - cocos2d::ui::ListView* _listView; + cocos2d::ui::Text* _displayValueLabel = nullptr; + // How many items we actually spawn, these items will be reused. + // Should > listview.width / templateWidth + 2. + int _spawnCount = 5; + // How many items we need for the ListView. Usually this is a big number. + int _totalCount = 50; + // when item is away from bufferSzone, we relocate it. + // Should be larger than List item width. + float _bufferZone = 45.f; + float _itemTemplateHeight = 0.f; + // Could tweak this value to adjust ListView data update rate. + float _updateInterval = (1.0f / 24); + float _updateTimer = 0.f; + // Use this value to detect if we are scrolling left or right + float _lastContentPosY = 0.f; + float _reuseItemOffset = 0.f; + cocos2d::ui::ListView* _listView =nullptr; std::vector _array; - cocos2d::ui::Text* _indexLabels[3]; + cocos2d::ui::Text* _indexLabels[3] = {nullptr}; }; class UIListViewTest_Horizontal : public UIScene @@ -80,19 +84,21 @@ protected: float getItemPositionXInView(cocos2d::ui::Widget* item) const; void updateItem(int itemID, int templateID); - cocos2d::ui::Text* _displayValueLabel; - //how many items we actually spawn, these items will be reused. - int _spawnCount; - // how many items we need for the ListView. Usually this is a big number. - int _totalCount; - //when item is away from bufferSzone, we relocate it. - float _bufferZone; - float _itemTemplateWidth; - float _updateInterval; - float _updateTimer; - float _lastContentPosX; - float _reuseItemOffset; - cocos2d::ui::ListView* _listView; + cocos2d::ui::Text* _displayValueLabel = nullptr; + // How many items we actually spawn, these items will be reused. + // Should > listview.width / templateWidth + 2. + int _spawnCount = 4; + // How many items we need for the ListView. Usually this is a big number. + int _totalCount = 50; + // when item is away from bufferSzone, we relocate it. + float _bufferZone = 140.f; + float _itemTemplateWidth = 0.f; + // Could tweak this value to adjust ListView data update rate. + float _updateInterval = 1.0f / 24; + float _updateTimer = 0.f; + float _lastContentPosX = 0.f; + float _reuseItemOffset = 0.f; + cocos2d::ui::ListView* _listView = nullptr; std::vector _array; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index ea7ce86832..8897df3bbf 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -204,7 +204,7 @@ bool UIPageViewButtonTest::init() } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); - parameter->setMargin(Margin(0,0,100,0)); + parameter->setMargin(Margin(0.0f,0.0f,100.0f,0.0f)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); @@ -289,7 +289,7 @@ bool UIPageViewTouchPropagationTest::init() // Create the page view PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 130.0f)); - pageView->setAnchorPoint(Vec2(0.5,0.5)); + pageView->setAnchorPoint(Vec2(0.5f,0.5f)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2(widgetSize.width / 2.0f ,widgetSize.height / 2.0f)); pageView->setBackGroundColor(Color3B::GREEN); @@ -314,7 +314,7 @@ bool UIPageViewTouchPropagationTest::init() } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); - parameter->setMargin(Margin(0,0,100,0)); + parameter->setMargin(Margin(0.0f,0.0f,100.0f,0.0f)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); @@ -347,15 +347,15 @@ bool UIPageViewTouchPropagationTest::init() _uiLayer->addChild(pageView); Text *propagationText = Text::create("Allow Propagation", "Arial", 10); - propagationText->setAnchorPoint(Vec2(0,0.5)); + propagationText->setAnchorPoint(Vec2(0.0f,0.5f)); propagationText->setTextColor(Color4B::RED); - propagationText->setPosition(Vec2(0, pageView->getPosition().y + 50)); + propagationText->setPosition(Vec2(0.0f, pageView->getPosition().y + 50)); _uiLayer->addChild(propagationText); Text *swallowTouchText = Text::create("Swallow Touches", "Arial", 10); - swallowTouchText->setAnchorPoint(Vec2(0,0.5)); + swallowTouchText->setAnchorPoint(Vec2(0.f,0.5f)); swallowTouchText->setTextColor(Color4B::RED); - swallowTouchText->setPosition(Vec2(0, pageView->getPosition().y)); + swallowTouchText->setPosition(Vec2(0.0f, pageView->getPosition().y)); _uiLayer->addChild(swallowTouchText); // Create the checkbox @@ -364,7 +364,7 @@ bool UIPageViewTouchPropagationTest::init() "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); - checkBox1->setPosition(propagationText->getPosition() + Vec2(propagationText->getContentSize().width/2, -20)); + checkBox1->setPosition(propagationText->getPosition() + Vec2(propagationText->getContentSize().width/2, -20.0f)); checkBox1->setName("propagation"); _uiLayer->addChild(checkBox1); @@ -376,7 +376,7 @@ bool UIPageViewTouchPropagationTest::init() "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); - checkBox2->setPosition(swallowTouchText->getPosition() + Vec2(swallowTouchText->getContentSize().width/2, -20)); + checkBox2->setPosition(swallowTouchText->getPosition() + Vec2(swallowTouchText->getContentSize().width/2, -20.0f)); checkBox2->setName("swallow"); _uiLayer->addChild(checkBox2); @@ -486,7 +486,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() PageView* pageView = PageView::create(); pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setContentSize(Size(240.0f, 130.0f)); - pageView->setAnchorPoint(Vec2(0.5,0.5)); + pageView->setAnchorPoint(Vec2(0.5f,0.5f)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2(widgetSize.width / 2.0f ,widgetSize.height / 2.0f)); pageView->setBackGroundColor(Color3B::GREEN); @@ -514,7 +514,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); - parameter->setMargin(Margin(0,0,100,0)); + parameter->setMargin(Margin(0.0f,0.0f,100.0f,0.0f)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); @@ -552,7 +552,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); - parameter->setMargin(Margin(0,0,100,0)); + parameter->setMargin(Margin(0.0f,0.0f,100.0f,0.0f)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); } @@ -687,7 +687,7 @@ bool UIPageViewJumpToPageTest::init() ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(240, 130)); + imageView->setContentSize(Size(240.0f, 130.0f)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); @@ -796,7 +796,7 @@ bool UIPageViewVerticalTest::init() ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(240, 130)); + imageView->setContentSize(Size(240.0f, 130.0f)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); @@ -889,7 +889,7 @@ bool UIPageViewDisableTouchTest::init() ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(240, 130)); + imageView->setContentSize(Size(240.0f, 130.0f)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); @@ -1053,7 +1053,7 @@ bool UIPageViewIndicatorTest::init() ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(240, 130)); + imageView->setContentSize(Size(240.0f, 130.0f)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp index 34a9b0769c..05796254ab 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp @@ -165,17 +165,17 @@ bool UIRadioButtonTwoGroupsTest::init() // Add a label in which the radio button events will be displayed _groupEventLabel = Text::create("RadioButtonGroup : No Event", "fonts/Marker Felt.ttf", 25); - _groupEventLabel->setAnchorPoint(Vec2(0.5f, -1)); + _groupEventLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _groupEventLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 70)); _uiLayer->addChild(_groupEventLabel); _buttonEventLabel = Text::create("RadioButton : No Event", "fonts/Marker Felt.ttf", 25); - _buttonEventLabel->setAnchorPoint(Vec2(0.5f, -1)); + _buttonEventLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _buttonEventLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 35)); _uiLayer->addChild(_buttonEventLabel); _logConsole = Text::create("", "fonts/Marker Felt.ttf", 10); - _logConsole->setAnchorPoint(Vec2(0, 1)); + _logConsole->setAnchorPoint(Vec2(0.0f, 1.0f)); _logConsole->setPosition(Vec2(widgetSize.width / 2.0f + 110, widgetSize.height / 2.0f + 55)); _uiLayer->addChild(_logConsole); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 217d51704f..6f770269d8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -79,10 +79,10 @@ bool UIScale9SpriteTest::init() { Size widgetSize = _widget->getContentSize(); - auto moveTo = MoveBy::create(1.0, Vec2(30,0)); + auto moveTo = MoveBy::create(1.0f, Vec2(30.0f,0.0f)); auto moveBack = moveTo->reverse(); - auto rotateBy = RotateBy::create(1.0, 180); - auto scaleBy = ScaleTo::create(1.0, -2.0); + auto rotateBy = RotateBy::create(1.0f, 180.0f); + auto scaleBy = ScaleTo::create(1.0f, -2.0f); auto action = Sequence::create(moveTo,moveBack, rotateBy,scaleBy, NULL); @@ -107,16 +107,16 @@ bool UIScale9SpriteTest::init() ui::Scale9Sprite *sp1 = ui::Scale9Sprite::create("cocosui/animationbuttonnormal.png"); sp1->setPosition(100, 160); sp1->setScale(1.2f); - sp1->setContentSize(Size(100,100)); + sp1->setContentSize(Size(100.0f,100.0f)); sp1->setColor(Color3B::GREEN); this->addChild(sp1); sp1->runAction((FiniteTimeAction*)action2); cocos2d::ui::Scale9Sprite *sp2 = ui::Scale9Sprite::create("cocosui/animationbuttonnormal.png"); - sp2->setPosition(350, 160); + sp2->setPosition(350.0f, 160.0f); sp2->setPreferredSize(sp1->getContentSize() * 1.2f); sp2->setColor(Color3B::GREEN); - sp2->setContentSize(Size(100,100)); + sp2->setContentSize(Size(100.0f,100.0f)); this->addChild(sp2); auto action3 = action->clone(); @@ -143,11 +143,11 @@ bool UIScale9SpriteHierarchialTest::init() { Size widgetSize = _widget->getContentSize(); - auto moveTo = MoveBy::create(1.0f, Vec2(30,0)); + auto moveTo = MoveBy::create(1.0f, Vec2(30.0f,0.0f)); auto moveBack = moveTo->reverse(); - auto rotateBy = RotateBy::create(1.0f, 180); + auto rotateBy = RotateBy::create(1.0f, 180.0f); auto fadeOut = FadeOut::create(2.0f); - auto scaleTo = ScaleTo::create(1.0, 2.0); + auto scaleTo = ScaleTo::create(1.0f, 2.0f); auto action = Sequence::create(moveTo,moveBack, rotateBy,fadeOut,scaleTo, NULL); Sprite *normalSprite1 = Sprite::create("cocosui/animationbuttonnormal.png"); @@ -166,9 +166,9 @@ bool UIScale9SpriteHierarchialTest::init() auto action2 = action->clone(); ui::Scale9Sprite *sp1 = ui::Scale9Sprite::create("cocosui/animationbuttonnormal.png"); - sp1->setPosition(200, 160); + sp1->setPosition(200.0f, 160.0f); sp1->setScale(1.2f); - sp1->setContentSize(Size(100,100)); + sp1->setContentSize(Size(100.0f,100.0f)); sp1->setColor(Color3B::GREEN); this->addChild(sp1); sp1->runAction((FiniteTimeAction*)action2); @@ -177,7 +177,7 @@ bool UIScale9SpriteHierarchialTest::init() sp2->setPreferredSize(sp1->getContentSize() * 1.2f); sp2->setColor(Color3B::GREEN); sp2->setFlippedX(true); - sp2->setContentSize(Size(100,100)); + sp2->setContentSize(Size(100.0f,100.0f)); sp1->addChild(sp2); @@ -205,7 +205,7 @@ bool UIScale9SpriteTouchTest::init() auto containerForSprite1 = Node::create(); auto sprite1 = cocos2d::ui::Scale9Sprite::create("Images/CyanSquare.png"); - sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 80)); + sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80.0f, 80.0f)); containerForSprite1->addChild(sprite1); addChild(containerForSprite1, 10); @@ -216,7 +216,7 @@ bool UIScale9SpriteTouchTest::init() addChild(sprite2, 20); auto sprite3 = ui::Scale9Sprite::create("Images/YellowSquare.png"); - sprite3->setPosition(Vec2(0, 0)); + sprite3->setPosition(Vec2(0.0f, 0.0f)); sprite3->setCascadeOpacityEnabled(false); sprite2->addChild(sprite3, 1); @@ -310,7 +310,7 @@ bool UIS9FrameNameSpriteSheet::init() blocks->setInsetRight(0); blocks->setInsetTop(0); blocks->setInsetBottom(0); - blocks->setPreferredSize(Size(400,80)); + blocks->setPreferredSize(Size(400.0f,80.0f)); blocks->setPosition(Vec2(x, y)); this->addChild(blocks); @@ -334,7 +334,7 @@ bool UIS9FrameNameSpriteSheetRotated::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - blocks->setPreferredSize(Size(400,80)); + blocks->setPreferredSize(Size(400.0f,80.0f)); blocks->setPosition(Vec2(x, y)); @@ -356,12 +356,12 @@ bool UIS9FrameNameSpriteSheetCropped::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); - blocks->setPreferredSize(Size(400,80)); + blocks->setPreferredSize(Size(400.0f,80.0f)); blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); auto blocks2 = ui::Scale9Sprite::create("Images/blocks9c.png"); - blocks2->setPreferredSize(Size(400,80)); + blocks2->setPreferredSize(Size(400.0f,80.0f)); blocks2->setPosition(Vec2(x, y - 45)); this->addChild(blocks2); @@ -381,12 +381,12 @@ bool UIS9FrameNameSpriteSheetCroppedRotated::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); - blocks->setPreferredSize(Size(400,80)); + blocks->setPreferredSize(Size(400.0f,80.0f)); blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); auto blocks2 = ui::Scale9Sprite::create("Images/blocks9cr.png"); - blocks2->setPreferredSize(Size(400,80)); + blocks2->setPreferredSize(Size(400.0f,80.0f)); blocks2->setPosition(Vec2(x, y - 45)); this->addChild(blocks2); @@ -407,7 +407,7 @@ bool UIS9FrameNameSpriteSheetCroppedSimple::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); - blocks->setPreferredSize(Size(400,80)); + blocks->setPreferredSize(Size(400.0f,80.0f)); blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); @@ -433,7 +433,7 @@ bool UIS9FrameNameSpriteSheetCroppedRotatedSimple::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); - blocks->setPreferredSize(Size(400,80)); + blocks->setPreferredSize(Size(400.0f,80.0f)); blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); @@ -730,11 +730,11 @@ bool UIS9ZOrder::init() blocks_scaled_with_insets->addChild(normalSprite); auto topLabel = Label::createWithSystemFont("I Must be On the Top", "Arial", 15); - topLabel->setPosition(Vec2(20,20)); + topLabel->setPosition(Vec2(20.0f,20.0f)); blocks_scaled_with_insets->addChild(topLabel); auto bottomLabel = Label::createWithSystemFont("I Must be On the Bottom", "Arial", 15); - bottomLabel->setPosition(Vec2(80,80)); + bottomLabel->setPosition(Vec2(80.0f,80.0f)); bottomLabel->setColor(Color3B::BLUE); blocks_scaled_with_insets->addChild(bottomLabel,-1); @@ -763,7 +763,7 @@ bool UIS9Flip::init() auto normalLabel = Label::createWithSystemFont("Normal Sprite","Arial",10); - normalLabel->setPosition(normalSprite->getPosition() + Vec2(0, normalSprite->getContentSize().height/2 + 10)); + normalLabel->setPosition(normalSprite->getPosition() + Vec2(0.0f, normalSprite->getContentSize().height/2 + 10)); this->addChild(normalLabel); @@ -776,7 +776,7 @@ bool UIS9Flip::init() flipXSprite->setFlippedX(false); auto flipXLabel = Label::createWithSystemFont("sprite is not flipped!","Arial",10); - flipXLabel->setPosition(flipXSprite->getPosition() + Vec2(0, flipXSprite->getContentSize().height/2 + 10)); + flipXLabel->setPosition(flipXSprite->getPosition() + Vec2(0.0f, flipXSprite->getContentSize().height/2 + 10)); this->addChild(flipXLabel); @@ -789,13 +789,13 @@ bool UIS9Flip::init() flipYSprite->setFlippedY(true); auto flipYLabel = Label::createWithSystemFont("sprite is flipped!","Arial",10); - flipYLabel->setPosition(flipYSprite->getPosition() + Vec2(0, flipYSprite->getContentSize().height/2 + 10)); + flipYLabel->setPosition(flipYSprite->getPosition() + Vec2(0.0f, flipYSprite->getContentSize().height/2 + 10)); this->addChild(flipYLabel); auto toggleFlipXButton = Button::create(); toggleFlipXButton->setTitleText("Toggle FlipX"); - toggleFlipXButton->setPosition(flipXSprite->getPosition() + Vec2(0, - 20 - flipXSprite->getContentSize().height/2)); + toggleFlipXButton->setPosition(flipXSprite->getPosition() + Vec2(0.0f, - 20 - flipXSprite->getContentSize().height/2)); toggleFlipXButton->addClickEventListener([=](Ref*){ flipXSprite->setFlippedX(! flipXSprite->isFlippedX()); if (flipXSprite->isFlippedX()) { @@ -809,7 +809,7 @@ bool UIS9Flip::init() auto toggleFlipYButton = Button::create(); toggleFlipYButton->setTitleText("Toggle FlipY"); - toggleFlipYButton->setPosition(flipYSprite->getPosition() + Vec2(0, -20 - flipYSprite->getContentSize().height/2)); + toggleFlipYButton->setPosition(flipYSprite->getPosition() + Vec2(0.0f, -20 - flipYSprite->getContentSize().height/2)); toggleFlipYButton->addClickEventListener([=](Ref*){ flipYSprite->setFlippedY(!flipYSprite->isFlippedY()); if (flipYSprite->isFlippedY()) { @@ -823,7 +823,7 @@ bool UIS9Flip::init() auto toggleScale9Button = Button::create(); toggleScale9Button->setTitleText("Toggle Scale9"); - toggleScale9Button->setPosition(normalSprite->getPosition() + Vec2(0, -20 - normalSprite->getContentSize().height/2)); + toggleScale9Button->setPosition(normalSprite->getPosition() + Vec2(0.0f, -20 - normalSprite->getContentSize().height/2)); toggleScale9Button->addClickEventListener([=](Ref*){ flipXSprite->setScale9Enabled(!flipXSprite->isScale9Enabled()); flipYSprite->setScale9Enabled(!flipYSprite->isScale9Enabled()); @@ -967,8 +967,8 @@ bool UIS9NinePatchTest::init() auto spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("buttonnormal.9.png"); auto buttonScale9Sprite = Scale9Sprite::createWithSpriteFrame(spriteFrame); - buttonScale9Sprite->setContentSize(Size(150,80)); - buttonScale9Sprite->setPosition(Vec2(100,200)); + buttonScale9Sprite->setContentSize(Size(150.0f,80.0f)); + buttonScale9Sprite->setPosition(Vec2(100.0f,200.0f)); this->addChild(buttonScale9Sprite); return true; @@ -987,7 +987,7 @@ bool UIS9BatchTest::init() label->setPosition(Vec2(winSize.width/2, winSize.height - 60)); this->addChild(label); - auto preferedSize = Size(150,99); + auto preferedSize = Size(150.0f,99.0f); std::vector spriteFrameNameArray = {"blocks9.png", "blocks9r.png"}; auto addSpriteButton = ui::Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); addSpriteButton->setPosition(Vec2(winSize.width/2 - 50,winSize.height - 100)); @@ -996,7 +996,7 @@ bool UIS9BatchTest::init() addSpriteButton->addClickEventListener([=](Ref*){ auto spriteFrameName = spriteFrameNameArray[rand()%2]; auto sprite = Sprite::createWithSpriteFrameName(spriteFrameName); - sprite->setPosition(Vec2(rand() % (int)winSize.width + 50, winSize.height/2)); + sprite->setPosition(Vec2(rand() % (int)winSize.width + 50.0f, winSize.height/2)); this->addChild(sprite); }); this->addChild(addSpriteButton); @@ -1008,7 +1008,7 @@ bool UIS9BatchTest::init() int random = rand()%2; auto spriteFrameName = spriteFrameNameArray[random]; auto sprite = ui::Scale9Sprite::createWithSpriteFrameName(spriteFrameName); - sprite->setPosition(Vec2(rand() % (int)winSize.width + 50, winSize.height/3)); + sprite->setPosition(Vec2(rand() % (int)winSize.width + 50.0f, winSize.height/3)); if (random == 0) { sprite->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); }else{ @@ -1114,7 +1114,7 @@ bool UIS9EnableScale9FalseTest::init() auto blocks = ui::Scale9Sprite::create("Images/blocks9.png"); blocks->setScale9Enabled(false); blocks->setPosition(Vec2(x, y)); - blocks->setPreferredSize(Size(96*2, 96)); + blocks->setPreferredSize(Size(96*2.0f, 96.0f)); blocks->setColor(Color3B::RED); blocks->setGlobalZOrder(1); this->addChild(blocks); @@ -1122,16 +1122,16 @@ bool UIS9EnableScale9FalseTest::init() auto blocks2 = ui::Scale9Sprite::create("Images/blocks9.png"); blocks2->setScale9Enabled(false); - blocks2->setPosition(Vec2(0, 0)); - blocks2->setPreferredSize(Size(96*1.5, 96)); + blocks2->setPosition(Vec2(0.0f, 0.0f)); + blocks2->setPreferredSize(Size(96*1.5f, 96.0f)); blocks2->setGlobalZOrder(0); blocks2->setColor(Color3B::GREEN); blocks->addChild(blocks2); auto blocks3 = ui::Scale9Sprite::create("Images/blocks9.png"); blocks3->setScale9Enabled(false); - blocks3->setPosition(Vec2(0, 0)); - blocks3->setPreferredSize(Size(96, 96)); + blocks3->setPosition(Vec2(0.0f, 0.0f)); + blocks3->setPreferredSize(Size(96.0f, 96.0f)); blocks3->setGlobalZOrder(2); blocks3->setColor(Color3B::YELLOW); blocks2->addChild(blocks3); @@ -1168,9 +1168,9 @@ bool UIS9GrayStateOpacityTest::init() slider->loadBarTexture("cocosui/sliderTrack.png"); slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider->setContentSize(Size(300, slider->getContentSize().height * 1.5)); + slider->setContentSize(Size(300, slider->getContentSize().height * 1.5f)); slider->setMaxPercent(100); - slider->setPercent(100 * 100.0 / 255.0); + slider->setPercent(100 * 100.0f / 255.0); slider->setPosition(Vec2(winSize.width / 2.0f, winSize.height / 2.0f - 100)); slider->addEventListener(CC_CALLBACK_2(UIS9GrayStateOpacityTest::sliderEvent, this)); _uiLayer->addChild(slider); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp index 450e752c13..322eb99209 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp @@ -305,8 +305,8 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() sc->setBackGroundColor(Color3B::GREEN); sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID); sc->setDirection(ui::ScrollView::Direction::BOTH); - sc->setInnerContainerSize(Size(480, 320)); - sc->setContentSize(Size(100,100)); + sc->setInnerContainerSize(Size(480.0f, 320.0f)); + sc->setContentSize(Size(100.0f,100.0f)); sc->setScrollBarEnabled(false); Size backgroundSize = background->getContentSize(); sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + @@ -315,7 +315,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() (backgroundSize.height - sc->getContentSize().height) / 2.0f)); sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true); ImageView* iv = ImageView::create("cocosui/Hello.png"); - iv->setPosition(Vec2(240, 160)); + iv->setPosition(Vec2(240.0f, 160.0f)); sc->addChild(iv); _uiLayer->addChild(sc); @@ -362,19 +362,19 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init() sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID); sc->setBounceEnabled(true); sc->setDirection(ui::ScrollView::Direction::BOTH); - sc->setInnerContainerSize(Size(480, 320)); - sc->setContentSize(Size(100,100)); - sc->setScrollBarPositionFromCornerForHorizontal(Vec2(5, sc->getContentSize().height - 5)); - sc->setScrollBarPositionFromCornerForVertical(Vec2(sc->getContentSize().width - 5, 5)); + sc->setInnerContainerSize(Size(480.0f, 320.0f)); + sc->setContentSize(Size(100.0f,100.0f)); + sc->setScrollBarPositionFromCornerForHorizontal(Vec2(5.0f, sc->getContentSize().height - 5)); + sc->setScrollBarPositionFromCornerForVertical(Vec2(sc->getContentSize().width - 5, 5.0f)); sc->setScrollBarAutoHideEnabled(false); Size backgroundSize = background->getContentSize(); sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - sc->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - sc->getContentSize().height) / 2.0f)); - sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true); + sc->scrollToPercentBothDirection(Vec2(50.0f, 50.0f), 1, true); ImageView* iv = ImageView::create("cocosui/Hello.png"); - iv->setPosition(Vec2(240, 160)); + iv->setPosition(Vec2(240.0f, 160.0f)); sc->addChild(iv); _uiLayer->addChild(sc); return true; @@ -427,7 +427,7 @@ bool UIScrollViewNestTest::init() (backgroundSize.width - scrollView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - scrollView->getContentSize().height) / 2.0f)); - scrollView->setScrollBarPositionFromCornerForVertical(Vec2(scrollView->getContentSize().width - 4, 4)); + scrollView->setScrollBarPositionFromCornerForVertical(Vec2(scrollView->getContentSize().width - 4, 4.0f)); scrollView->setScrollBarColor(Color3B::BLUE); _uiLayer->addChild(scrollView); @@ -464,14 +464,14 @@ bool UIScrollViewNestTest::init() sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID); sc->setBounceEnabled(true); sc->setDirection(ui::ScrollView::Direction::BOTH); - sc->setInnerContainerSize(Size(480, 320)); - sc->setContentSize(Size(100,100)); + sc->setInnerContainerSize(Size(480.0f, 320.0f)); + sc->setContentSize(Size(100.0f,100.0f)); sc->setPropagateTouchEvents(false); - sc->setPosition(Vec2(180,100)); - sc->scrollToPercentBothDirection(Vec2(50, 50), 1, true); - sc->setScrollBarPositionFromCorner(Vec2(4, 4)); + sc->setPosition(Vec2(180.0f,100.0f)); + sc->scrollToPercentBothDirection(Vec2(50.0f, 50.0f), 1, true); + sc->setScrollBarPositionFromCorner(Vec2(4.0f, 4.0f)); ImageView* iv = ImageView::create("cocosui/Hello.png"); - iv->setPosition(Vec2(240, 160)); + iv->setPosition(Vec2(240.0f, 160.0f)); sc->addChild(iv); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index ea9da9f8ce..cc4a4e92dc 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -58,7 +58,7 @@ bool UISliderTest::init() // Add a label in which the slider alert will be displayed _displayValueLabel = TextBMFont::create("Move the slider thumb", "ccb/markerfelt24shadow.fnt"); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -85,7 +85,7 @@ bool UISliderTest::init() auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); - pMenu1->setPosition(Vec2(0, 0)); + pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); return true; @@ -137,7 +137,7 @@ bool UISliderTest_Scale9::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("Move the slider thumb","fonts/Marker Felt.ttf",32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -153,8 +153,8 @@ bool UISliderTest_Scale9::init() slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosui/slider_bar_active_9patch.png"); slider->setScale9Enabled(true); - slider->setCapInsets(Rect(0, 0, 0, 0)); - slider->setContentSize(Size(250.0f, 19)); + slider->setCapInsets(Rect(0.0f, 0.0f, 0.0f, 0.0f)); + slider->setContentSize(Size(250.0f, 19.0f)); slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 3.0f*/)); slider->addEventListener(CC_CALLBACK_2(UISliderTest_Scale9::sliderEvent, this)); _uiLayer->addChild(slider); @@ -195,7 +195,7 @@ bool UISliderTest_Scale9_State_Change::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("Click the slider thumb", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); @@ -212,8 +212,8 @@ bool UISliderTest_Scale9_State_Change::init() slider->loadProgressBarTexture("cocosui/slider_bar_active_9patch.png"); slider->ignoreContentAdaptWithSize(false); slider->setScale9Enabled(true); - slider->setCapInsets(Rect(0, 0, 0, 0)); - slider->setContentSize(Size(200.0f, 60)); + slider->setCapInsets(Rect(0.0f, 0.0f, 0.0f, 0.0f)); + slider->setContentSize(Size(200.0f, 60.0f)); slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 3.0f*/)); slider->addTouchEventListener([=](Ref* /*sender*/, Widget::TouchEventType type){ if (type == Widget::TouchEventType::ENDED) { @@ -263,7 +263,7 @@ bool UISliderNormalDefaultTest::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("","Arial",32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 100)); _uiLayer->addChild(_displayValueLabel); @@ -284,9 +284,9 @@ bool UISliderNormalDefaultTest::init() Slider* sliderScale9 = (Slider*)slider->clone(); sliderScale9->setScale9Enabled(true); - sliderScale9->setCapInsets(Rect(0, 0, 0, 0)); + sliderScale9->setCapInsets(Rect(0.0f, 0.0f, 0.0f, 0.0f)); sliderScale9->setZoomScale(1.0); - sliderScale9->setContentSize(Size(250.0f, 19)); + sliderScale9->setContentSize(Size(250.0f, 19.0f)); sliderScale9->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - 20)); _uiLayer->addChild(sliderScale9); @@ -316,7 +316,7 @@ bool UISliderDisabledDefaultTest::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("","Arial",32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 100)); _uiLayer->addChild(_displayValueLabel); @@ -341,8 +341,8 @@ bool UISliderDisabledDefaultTest::init() sliderScale9->setScale9Enabled(true); sliderScale9->setEnabled(false); sliderScale9->setBright(false); - sliderScale9->setCapInsets(Rect(0, 0, 0, 0)); - sliderScale9->setContentSize(Size(250.0f, 10)); + sliderScale9->setCapInsets(Rect(0.0f, 0.0f, 0.0f, 0.0f)); + sliderScale9->setContentSize(Size(250.0f, 10.0f)); sliderScale9->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - 20)); _uiLayer->addChild(sliderScale9); @@ -374,7 +374,7 @@ bool UISliderNewEventCallbackTest::init() // Add a label in which the slider alert will be displayed _displayValueLabel = Text::create("","Arial",32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 100)); _uiLayer->addChild(_displayValueLabel); @@ -439,7 +439,7 @@ bool UISliderIssue12249Test::init() // Add a label in which the slider alert will be displayed _displayValueLabel = TextBMFont::create("Move the slider thumb", "ccb/markerfelt24shadow.fnt"); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); _uiLayer->addChild(_displayValueLabel); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 9526962176..75c72866fb 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -298,7 +298,7 @@ bool UITextFieldTest_LineWrap::init() // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",30); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); + _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); @@ -312,7 +312,7 @@ bool UITextFieldTest_LineWrap::init() TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30); textField->ignoreContentAdaptWithSize(false); ((Label*)(textField->getVirtualRenderer()))->setLineBreakWithoutSpace(true); - textField->setContentSize(Size(240, 170)); + textField->setContentSize(Size(240.0f, 170.0f)); textField->setString("input words here"); textField->setTextHorizontalAlignment(TextHAlignment::CENTER); textField->setTextVerticalAlignment(TextVAlignment::CENTER); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp index 79e6c7e1dd..9ca3ef6155 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp @@ -85,7 +85,7 @@ bool UITextTest_LineWrap::init() Text* text = Text::create("TextArea Widget can line wrap", "AmericanTypewriter",32); text->ignoreContentAdaptWithSize(false); - text->setContentSize(Size(280, 150)); + text->setContentSize(Size(280.0f, 150.0f)); text->setTextHorizontalAlignment(TextHAlignment::CENTER); text->setTouchScaleChangeEnabled(true); text->setTouchEnabled(true); @@ -95,10 +95,10 @@ bool UITextTest_LineWrap::init() { if ((int)text->getContentSize().width == 280) { - text->setContentSize(Size(380,100)); + text->setContentSize(Size(380.0f,100.0f)); }else { - text->setContentSize(Size(280, 150)); + text->setContentSize(Size(280.0f, 150.0f)); } } }); @@ -178,8 +178,8 @@ bool UILabelTest_Effect::init() auto disableOutlineBtn= Button::create(); disableOutlineBtn->setTitleText("Disable outline"); disableOutlineBtn->setTitleFontName("fonts/Marker Felt.ttf"); - disableOutlineBtn->setPosition(Vec2(widgetSize.width * 0.3, - widgetSize.height * 0.7)); + disableOutlineBtn->setPosition(Vec2(widgetSize.width * 0.3f, + widgetSize.height * 0.7f)); disableOutlineBtn->setPressedActionEnabled(true); disableOutlineBtn->addClickEventListener([=](Ref*){ outline_label->disableEffect(LabelEffect::OUTLINE); @@ -193,7 +193,7 @@ bool UILabelTest_Effect::init() auto disableGlowBtn = (Button*)disableOutlineBtn->clone(); disableGlowBtn->setPosition(disableOutlineBtn->getPosition() - + Vec2(buttonWidth + 40,0)); + + Vec2(buttonWidth + 40,0.0f)); disableGlowBtn->setTitleText("Disable Glow"); disableGlowBtn->addClickEventListener([=](Ref*){ glow_label->disableEffect(LabelEffect::GLOW); @@ -202,7 +202,7 @@ bool UILabelTest_Effect::init() auto disableShadowBtn = (Button*)disableGlowBtn->clone(); disableShadowBtn->setPosition(disableGlowBtn->getPosition() - + Vec2(buttonWidth + 40,0)); + + Vec2(buttonWidth + 40,0.0f)); disableShadowBtn->setTitleText("Disable Shadow"); disableShadowBtn->addClickEventListener([=](Ref*){ shadow_label->disableEffect(LabelEffect::SHADOW); @@ -257,7 +257,7 @@ bool UITextTest_IgnoreContentSize::init() leftText->setPosition(Vec2(widgetSize.width / 2.0f - 50, widgetSize.height / 2.0f)); leftText->ignoreContentAdaptWithSize(false); - leftText->setTextAreaSize(Size(60,60)); + leftText->setTextAreaSize(Size(60.0f,60.0f)); leftText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n"); leftText->setTouchScaleChangeEnabled(true); leftText->setTouchEnabled(true); @@ -270,7 +270,7 @@ bool UITextTest_IgnoreContentSize::init() widgetSize.height / 2.0f)); rightText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n"); //note:setTextAreaSize must be used with ignoreContentAdaptWithSize(false) - rightText->setTextAreaSize(Size(100,30)); + rightText->setTextAreaSize(Size(100.0f,30.0f)); rightText->ignoreContentAdaptWithSize(false); _uiLayer->addChild(rightText); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp index 2e1ac03a6f..9ff8037307 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp @@ -26,7 +26,6 @@ USING_NS_CC; using namespace cocos2d::ui; -using namespace cocos2d::experimental::ui; VideoPlayerTests::VideoPlayerTests() { @@ -43,6 +42,10 @@ bool VideoPlayerTest::init() _visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect(); + // Should create video first to make sure video is destryed first. If not, then may crash. + // Because when destroying video, it will stop video which may trigger stopped event listener. + createVideo(); + MenuItemFont::setFontSize(16); auto fullSwitch = MenuItemFont::create("FullScreenSwitch", CC_CALLBACK_1(VideoPlayerTest::menuFullScreenCallback, this)); @@ -95,8 +98,6 @@ bool VideoPlayerTest::init() _loopStatusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); _loopStatusLabel->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 185)); _uiLayer->addChild(_loopStatusLabel); - - createVideo(); return true; } @@ -263,7 +264,7 @@ void VideoPlayerTest::videoEventCallback(Ref* sender, VideoPlayer::EventType eve SimpleVideoPlayerTest::SimpleVideoPlayerTest() { _videoPlayer = nullptr; - _style = cocos2d::experimental::ui::VideoPlayer::StyleType::NONE; + _style = cocos2d::ui::VideoPlayer::StyleType::NONE; _userInputEnabled = true; _switchUserInputEnabled = nullptr; @@ -283,12 +284,12 @@ void SimpleVideoPlayerTest::updateButtonsTexts() std::string str = " - "; switch(_style) { - case cocos2d::experimental::ui::VideoPlayer::StyleType::NONE: + case cocos2d::ui::VideoPlayer::StyleType::NONE: _switchUserInputEnabled->setVisible(false); str = "< NO Sytle >"; break; - case cocos2d::experimental::ui::VideoPlayer::StyleType::DEFAULT: + case cocos2d::ui::VideoPlayer::StyleType::DEFAULT: str = "< Default Style >"; _switchUserInputEnabled->setVisible(true); break; @@ -343,12 +344,12 @@ void SimpleVideoPlayerTest::menuCloseCallback(Ref* sender) void SimpleVideoPlayerTest::switchStyleCallback(Ref* sender) { switch (_style) { - case cocos2d::experimental::ui::VideoPlayer::StyleType::NONE: - _style = cocos2d::experimental::ui::VideoPlayer::StyleType::DEFAULT; + case cocos2d::ui::VideoPlayer::StyleType::NONE: + _style = cocos2d::ui::VideoPlayer::StyleType::DEFAULT; break; - case cocos2d::experimental::ui::VideoPlayer::StyleType::DEFAULT: - _style = cocos2d::experimental::ui::VideoPlayer::StyleType::NONE; + case cocos2d::ui::VideoPlayer::StyleType::DEFAULT: + _style = cocos2d::ui::VideoPlayer::StyleType::NONE; break; default: diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.h index 375a54ed25..6cdc84bc4f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.h @@ -51,20 +51,16 @@ public: void sliderCallback(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType eventType); - void videoEventCallback(cocos2d::Ref* sender, cocos2d::experimental::ui::VideoPlayer::EventType eventType); + void videoEventCallback(cocos2d::Ref* sender, cocos2d::ui::VideoPlayer::EventType eventType); private: void createVideo(); void createSlider(); - cocos2d::MenuItemFont* _hintItem; - cocos2d::experimental::ui::VideoPlayer* _videoPlayer; + cocos2d::ui::VideoPlayer* _videoPlayer; cocos2d::Label* _videoStateLabel; cocos2d::Label* _loopStatusLabel; cocos2d::Rect _visibleRect; - - cocos2d::Layer* _rootLayer; - }; @@ -85,14 +81,14 @@ private: void createVideo(); cocos2d::Rect _visibleRect; - cocos2d::experimental::ui::VideoPlayer* _videoPlayer; + cocos2d::ui::VideoPlayer* _videoPlayer; cocos2d::MenuItemFont* _switchUserInputEnabled; cocos2d::MenuItemFont* _switchStyle; bool _userInputEnabled; - cocos2d::experimental::ui::VideoPlayer::StyleType _style; + cocos2d::ui::VideoPlayer::StyleType _style; void updateButtonsTexts(); }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp index b2bf692538..97d97241ab 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp @@ -39,7 +39,7 @@ bool WebViewTest::init() Size winSize = Director::getInstance()->getVisibleSize(); - _webView = cocos2d::experimental::ui::WebView::create(); + _webView = cocos2d::ui::WebView::create(); _webView->setPosition(winSize/2); _webView->setContentSize(winSize * 0.5); _webView->loadURL("https://www.baidu.com"); @@ -188,21 +188,21 @@ bool WebViewTest::init() return false; } -bool WebViewTest::onWebViewShouldStartLoading(experimental::ui::WebView *sender, const std::string &url) +bool WebViewTest::onWebViewShouldStartLoading(ui::WebView *sender, const std::string &url) { CCLOG("onWebViewShouldStartLoading, url is %s", url.c_str()); //don't do any OpenGL operation here!! It's forbidden! return true; } -void WebViewTest::onWebViewDidFinishLoading(experimental::ui::WebView *sender, const std::string &url) +void WebViewTest::onWebViewDidFinishLoading(ui::WebView *sender, const std::string &url) { auto node = (ui::Button*)this->getChildByName("evalJs"); node->setTitleText("start loading..."); CCLOG("onWebViewDidFinishLoading, url is %s", url.c_str()); } -void WebViewTest::onWebViewDidFailLoading(experimental::ui::WebView *sender, const std::string &url) +void WebViewTest::onWebViewDidFailLoading(ui::WebView *sender, const std::string &url) { CCLOG("onWebViewDidFailLoading, url is %s", url.c_str()); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.h index 61290e0c2b..8eb41095df 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.h @@ -36,13 +36,13 @@ public: CREATE_FUNC(WebViewTest); virtual bool init() override; - bool onWebViewShouldStartLoading(cocos2d::experimental::ui::WebView *sender, const std::string &url); - void onWebViewDidFinishLoading(cocos2d::experimental::ui::WebView *sender, const std::string &url); - void onWebViewDidFailLoading(cocos2d::experimental::ui::WebView *sender, const std::string &url); + bool onWebViewShouldStartLoading(cocos2d::ui::WebView *sender, const std::string &url); + void onWebViewDidFinishLoading(cocos2d::ui::WebView *sender, const std::string &url); + void onWebViewDidFailLoading(cocos2d::ui::WebView *sender, const std::string &url); private: - cocos2d::experimental::ui::WebView *_webView; + cocos2d::ui::WebView *_webView; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp index 42b0fea321..fe20dfa920 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp @@ -64,7 +64,7 @@ bool UIWidgetAddNodeTest::init() _uiLayer->addChild(widget); Sprite* sprite = Sprite::create("cocosui/ccicon.png"); - sprite->setPosition(Vec2(0, sprite->getBoundingBox().size.height / 4)); + sprite->setPosition(Vec2(0.0f, sprite->getBoundingBox().size.height / 4)); widget->addChild(sprite); return true; diff --git a/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp b/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp index 5574dbe787..55d0ef32cc 100644 --- a/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp +++ b/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp @@ -143,7 +143,7 @@ void TemplateVectorTest::onEnter() // Test move constructor - auto createVector = [this](){ + auto createVector = [](){ Vector ret; for (int i = 0; i < 20; i++) @@ -372,7 +372,7 @@ void TemplateMapTest::onEnter() { UnitTestDemo::onEnter(); - auto createMap = [this](){ + auto createMap = [](){ Map ret; for (int i = 0; i < 20; ++i) { diff --git a/tests/cpp-tests/Classes/VibrateTest/VibrateTest.cpp b/tests/cpp-tests/Classes/VibrateTest/VibrateTest.cpp index 5e80ae7081..656e73c1ca 100644 --- a/tests/cpp-tests/Classes/VibrateTest/VibrateTest.cpp +++ b/tests/cpp-tests/Classes/VibrateTest/VibrateTest.cpp @@ -72,8 +72,6 @@ namespace { private: TextButton() - : _enabled(true) - , _onTriggered(nullptr) { auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); @@ -128,9 +126,9 @@ namespace { runAction(action); } - std::function _onTriggered; + std::function _onTriggered = nullptr; - bool _enabled; + bool _enabled = true; }; class SliderEx : public Slider diff --git a/tests/cpp-tests/Classes/VibrateTest/VibrateTest.h b/tests/cpp-tests/Classes/VibrateTest/VibrateTest.h index 1122039d80..fc05417e7f 100644 --- a/tests/cpp-tests/Classes/VibrateTest/VibrateTest.h +++ b/tests/cpp-tests/Classes/VibrateTest/VibrateTest.h @@ -51,11 +51,10 @@ public: virtual std::string title() const override; private: - float _duration; + float _duration = 0.f; - void* _durationLabel; - void* _durationSlider; - bool _updateTimeSlider; + void* _durationLabel = nullptr; + void* _durationSlider = nullptr; }; diff --git a/tests/cpp-tests/Classes/ZipTest/ZipTests.cpp b/tests/cpp-tests/Classes/ZipTest/ZipTests.cpp new file mode 100644 index 0000000000..5388c1d56e --- /dev/null +++ b/tests/cpp-tests/Classes/ZipTest/ZipTests.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** + Copyright (c) 2019 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "ZipTests.h" + +#include + +#include "unzip/unzip.h" +#include "unzip/crypt.h" + +using namespace cocos2d; + +ZipTests::ZipTests() { + ADD_TEST_CASE(UnZipNormalFile); + ADD_TEST_CASE(UnZipWithPassword); +} + +std::string ZipTest::title() const { + return "Unzip Test"; +} + + +static void unzipTest(Label *label, const std::string &originFile, const std::string &tmpName, const std::string &zipFile, const std::string& password = "") +{ + + auto fu = FileUtils::getInstance(); + cocos2d::Data origContent; + const int BUFF_SIZE = 1024; + char *buff = nullptr; + std::vector fileData; + bool hasError = false; + unz_file_info fileInfo = {0}; + char fileName[40] = {0}; + + auto newLocal = fu->getWritablePath() + tmpName; + //copy file to support android + + if(fu->isFileExist(newLocal)) { + CCLOG("Remove file %s", newLocal.c_str()); + fu->removeFile(newLocal); + } + + CCLOG("Copy %s to %s", zipFile.c_str(), newLocal.c_str()); + auto writeSuccess = fu->writeDataToFile(fu->getDataFromFile(zipFile), newLocal); + if(!writeSuccess) { + label->setString("Failed to copy zip file to writable path"); + return; + } + + unzFile fp = unzOpen(newLocal.c_str()); + if(!fp) { + CCLOG("Failed to open zip file %s", newLocal.c_str()); + label->setString("Failed to open zip file"); + return; + } + + int err = unzGoToFirstFile(fp); + if(err != UNZ_OK) { + label->setString("Failed to local first file"); + goto close_and_return; + } + + unzGetCurrentFileInfo(fp, &fileInfo, fileName, sizeof(fileName) -1, nullptr, 0, nullptr, 0 ); + + CCASSERT(strncmp("10k.txt", fileName, 7) == 0, "file name should be 10k.txt"); + + if(password.empty()) + { + err = unzOpenCurrentFile(fp); + } + else + { + err = unzOpenCurrentFilePassword(fp, password.c_str()); + } + + if(err != UNZ_OK) { + label->setString("failed to open zip file"); + goto close_and_return; + } + + buff = new char[BUFF_SIZE]; + + for(;;) { + int retSize = unzReadCurrentFile(fp, buff, BUFF_SIZE); + if(retSize < 0) { + hasError = true; + break; + } + else if(retSize == 0) { + break; + } + + fileData.insert(fileData.end(), buff, buff + retSize); + } + + delete[] buff; + + if(hasError) { + label->setString("unzip error! read error!"); + goto close_and_return; + } + + origContent = FileUtils::getInstance()->getDataFromFile(originFile); + + if(origContent.getSize() == fileData.size() && + memcmp(origContent.getBytes(), fileData.data(), fileData.size()) == 0) { + label->setString("unzip ok!"); + } else { + label->setString("unzip error! data mismatch!"); + } +close_and_return: + unzClose(fp); +} + + +void UnZipNormalFile::onEnter() { + TestCase::onEnter(); + + const auto winSize = Director::getInstance()->getWinSize(); + + Label *label = Label::createWithTTF("unziping file", "fonts/Marker Felt.ttf", 23); + label->setPosition(winSize.width/2, winSize.height/2); + addChild(label); + + unzipTest(label, "zip/10k.txt", "10-nopasswd.zip", "zip/10k-nopass.zip"); +} + +std::string UnZipNormalFile::subtitle() const { + return "unzip without password"; +} + +void UnZipWithPassword::onEnter() { + TestCase::onEnter(); + + const auto winSize = Director::getInstance()->getWinSize(); + + Label *label = Label::createWithTTF("unziping file", "fonts/Marker Felt.ttf", 23); + label->setPosition(winSize.width/2, winSize.height/2); + addChild(label); + + unzipTest(label, "zip/10k.txt", "10.zip", "zip/10k.zip", "123456"); +} + +std::string UnZipWithPassword::subtitle() const { + return "unzip with password"; +} diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp b/tests/cpp-tests/Classes/ZipTest/ZipTests.h similarity index 61% rename from cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp rename to tests/cpp-tests/Classes/ZipTest/ZipTests.h index 0bd585ba61..623c902f0c 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.hpp +++ b/tests/cpp-tests/Classes/ZipTest/ZipTests.h @@ -1,19 +1,18 @@ /**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - + Copyright (c) 2019 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,21 +21,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) -#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_VIDEO_MANUAL_H -#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_VIDEO_MANUAL_H +#pragma once -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif +#include "../BaseTest.h" -TOLUA_API int register_all_cocos2dx_experimental_video_manual(lua_State* L); +DEFINE_TEST_SUITE(ZipTests); + +class ZipTest : public TestCase +{ +public: + virtual std::string title() const override; +}; + +class UnZipNormalFile : public ZipTest +{ +public: + CREATE_FUNC(UnZipNormalFile); + virtual void onEnter() override; + virtual std::string subtitle() const override; +}; + +class UnZipWithPassword : public ZipTest +{ +public: + CREATE_FUNC(UnZipWithPassword); + virtual void onEnter() override; + virtual std::string subtitle() const override; +}; -#endif //#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_VIDEO_MANUAL_H -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 5b5573c71f..96608778fc 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -49,10 +49,6 @@ public: addTest("Actions - Ease", [](){return new (std::nothrow) ActionsEaseTests(); }); addTest("Actions - Progress", [](){return new (std::nothrow) ActionsProgressTests(); }); addTest("Audio - NewAudioEngine", []() { return new (std::nothrow) AudioEngineTests(); }); -#if CC_ENABLE_BOX2D_INTEGRATION - addTest("Box2d - Basic", []() { return new (std::nothrow) Box2DTests(); }); - addTest("Box2d - TestBed", []() { return new (std::nothrow) Box2dTestBedSuite(); }); -#endif #if CC_ENABLE_CHIPMUNK_INTEGRATION addTest("Chipmunk", []() { return new ChipmunkTests(); }); #endif @@ -120,6 +116,7 @@ public: addTest("Touches", [](){return new TouchesTests(); }); addTest("Transitions", [](){return new TransitionsTests(); }); addTest("Unit Test", []() { return new UnitTests(); }); + addTest("Unzip Test", []() {return new ZipTests();}); addTest("URL Open Test", []() { return new OpenURLTests(); }); addTest("UserDefault", []() { return new UserDefaultTests(); }); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) diff --git a/tests/cpp-tests/Classes/tests.h b/tests/cpp-tests/Classes/tests.h index 51111ea50a..fc109acd99 100644 --- a/tests/cpp-tests/Classes/tests.h +++ b/tests/cpp-tests/Classes/tests.h @@ -117,5 +117,5 @@ #include "VibrateTest/VibrateTest.h" #include "ZwoptexTest/ZwoptexTest.h" #include "SpriteFrameCacheTest/SpriteFrameCacheTest.h" - +#include "ZipTest/ZipTests.h" #endif diff --git a/tests/cpp-tests/Resources/zip/10k-nopass.zip b/tests/cpp-tests/Resources/zip/10k-nopass.zip new file mode 100644 index 0000000000..35a28a96b7 Binary files /dev/null and b/tests/cpp-tests/Resources/zip/10k-nopass.zip differ diff --git a/tests/cpp-tests/Resources/zip/10k.txt b/tests/cpp-tests/Resources/zip/10k.txt new file mode 100644 index 0000000000..95b559542e Binary files /dev/null and b/tests/cpp-tests/Resources/zip/10k.txt differ diff --git a/tests/cpp-tests/Resources/zip/10k.zip b/tests/cpp-tests/Resources/zip/10k.zip new file mode 100644 index 0000000000..7e34910191 Binary files /dev/null and b/tests/cpp-tests/Resources/zip/10k.zip differ diff --git a/tests/cpp-tests/proj.android/gradle.properties b/tests/cpp-tests/proj.android/gradle.properties index 83d8774574..ebbe920606 100644 --- a/tests/cpp-tests/proj.android/gradle.properties +++ b/tests/cpp-tests/proj.android/gradle.properties @@ -37,4 +37,6 @@ PROP_APP_ABI=armeabi-v7a #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false diff --git a/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm b/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm index e2a5ffcc5a..061027154b 100644 --- a/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm +++ b/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm @@ -86,7 +86,7 @@ static AppDelegate s_sharedApplication; [window makeKeyAndVisible]; #if !defined(CC_TARGET_OS_TVOS) - [[UIApplication sharedApplication] setStatusBarHidden:true]; + [viewController prefersStatusBarHidden]; #endif // IMPORTANT: Setting the GLView should be done after creating the RootViewController diff --git a/tests/cpp-tests/proj.ios/Info.plist b/tests/cpp-tests/proj.ios/Info.plist index de23973588..b340e7d833 100644 --- a/tests/cpp-tests/proj.ios/Info.plist +++ b/tests/cpp-tests/proj.ios/Info.plist @@ -7,31 +7,25 @@ CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} + Icon CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} + ${PRODUCT_NAME} CFBundlePackageType APPL - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + 1.0 CFBundleSignature ???? CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + 1 NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} - CFBundleIconFiles - - ${MACOSX_BUNDLE_ICON_FILE} - + Copyright © 2019. All rights reserved. LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/tests/cpp-tests/proj.mac/Info.plist b/tests/cpp-tests/proj.mac/Info.plist index 52ff14e9cf..ea5cd6d7d0 100644 --- a/tests/cpp-tests/proj.mac/Info.plist +++ b/tests/cpp-tests/proj.mac/Info.plist @@ -11,7 +11,7 @@ CFBundleIconFile Icon CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,15 +24,13 @@ ???? CFBundleVersion 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} NSAppTransportSecurity NSAllowsArbitraryLoads NSHumanReadableCopyright - Copyright © 2012. All rights reserved. + Copyright © 2019. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/tests/lua-empty-test/project/CMakeLists.txt b/tests/lua-empty-test/project/CMakeLists.txt index 7b5c3c94f0..98a46bbe6b 100644 --- a/tests/lua-empty-test/project/CMakeLists.txt +++ b/tests/lua-empty-test/project/CMakeLists.txt @@ -4,6 +4,12 @@ set(APP_NAME lua-empty-test) project(${APP_NAME}) +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + if(NOT DEFINED BUILD_ENGINE_DONE) set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) @@ -99,16 +105,19 @@ target_include_directories(${APP_NAME} PRIVATE Classes) setup_cocos_app_config(${APP_NAME}) if(APPLE) set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}") + if(MACOSX) + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.mac/Info.plist") set_target_properties(${APP_NAME} PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.mac/Info.plist" - ) + LINK_FLAGS "-pagezero_size 10000 -image_base 100000000" + ) elseif(IOS) - cocos_pak_xcode(${APP_NAME} INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios/Info.plist") + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon-${APP_NAME}") - set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "") - set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer") endif() + + # For code-signing, set the DEVELOPMENT_TEAM: + #set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") elseif(WINDOWS) cocos_copy_target_dll(${APP_NAME}) endif() diff --git a/tests/lua-empty-test/project/proj.android/gradle.properties b/tests/lua-empty-test/project/proj.android/gradle.properties index 83d8774574..df277e6673 100644 --- a/tests/lua-empty-test/project/proj.android/gradle.properties +++ b/tests/lua-empty-test/project/proj.android/gradle.properties @@ -37,4 +37,6 @@ PROP_APP_ABI=armeabi-v7a #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false \ No newline at end of file diff --git a/tests/lua-empty-test/project/proj.ios/AppController.mm b/tests/lua-empty-test/project/proj.ios/AppController.mm index 12172a818a..5f463bba4c 100644 --- a/tests/lua-empty-test/project/proj.ios/AppController.mm +++ b/tests/lua-empty-test/project/proj.ios/AppController.mm @@ -76,6 +76,12 @@ static AppDelegate s_sharedApplication; [[UIApplication sharedApplication] setStatusBarHidden: YES]; + //Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior. + if ( [[UIDevice currentDevice].systemVersion floatValue] >= 13.0f) + { + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"]; + } + // IMPORTANT: Setting the GLView should be done after creating the RootViewController cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); cocos2d::Director::getInstance()->setOpenGLView(glview); diff --git a/tests/lua-empty-test/project/proj.ios/Info.plist b/tests/lua-empty-test/project/proj.ios/Info.plist index 8efc91675c..1798164bd9 100644 --- a/tests/lua-empty-test/project/proj.ios/Info.plist +++ b/tests/lua-empty-test/project/proj.ios/Info.plist @@ -7,7 +7,7 @@ CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleIconFile Icon-57.png CFBundleIcons @@ -15,23 +15,21 @@ CFBundleIcons~ipad CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} + ${PRODUCT_NAME} CFBundlePackageType APPL - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + 1.0 CFBundleSignature ???? CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + 1 NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} + Copyright © 2019. All rights reserved. LSRequiresIPhoneOS UILaunchStoryboardName @@ -42,8 +40,6 @@ accelerometer - opengles-1 - UIStatusBarHidden diff --git a/tests/lua-empty-test/project/proj.mac/Info.plist b/tests/lua-empty-test/project/proj.mac/Info.plist index 608a82cdac..7734386383 100644 --- a/tests/lua-empty-test/project/proj.mac/Info.plist +++ b/tests/lua-empty-test/project/proj.mac/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile Icon CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -25,7 +25,7 @@ LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright - Copyright © 2012. All rights reserved. + Copyright © 2019. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/tests/lua-empty-test/src/hello.lua b/tests/lua-empty-test/src/hello.lua index de9fa8f3da..b4075c8186 100644 --- a/tests/lua-empty-test/src/hello.lua +++ b/tests/lua-empty-test/src/hello.lua @@ -172,14 +172,14 @@ local function main() local function menuCallbackClosePopup() -- stop test sound effect - ccexp.AudioEngine:stop(effectID) + cc.AudioEngine:stop(effectID) menuPopup:setVisible(false) end local function menuCallbackOpenPopup() -- loop test sound effect local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") - effectID = ccexp.AudioEngine:play2d(effectPath) + effectID = cc.AudioEngine:play2d(effectPath) menuPopup:setVisible(true) end @@ -207,9 +207,9 @@ local function main() -- play background music, preload effect local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3") - ccexp.AudioEngine:play2d(bgMusicPath, true) + cc.AudioEngine:play2d(bgMusicPath, true) local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") - ccexp.AudioEngine:preload(effectPath) + cc.AudioEngine:preload(effectPath) -- run local sceneGame = cc.Scene:create() diff --git a/tests/lua-tests/project/CMakeLists.txt b/tests/lua-tests/project/CMakeLists.txt index 8ec34ac8a4..653bbc55b7 100644 --- a/tests/lua-tests/project/CMakeLists.txt +++ b/tests/lua-tests/project/CMakeLists.txt @@ -4,6 +4,12 @@ set(APP_NAME lua-tests) project(${APP_NAME}) +if(XCODE) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) + SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0) + endif() +endif() + if(NOT DEFINED BUILD_ENGINE_DONE) set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..) set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) @@ -112,16 +118,19 @@ target_include_directories(${APP_NAME} PRIVATE Classes) setup_cocos_app_config(${APP_NAME}) if(APPLE) set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}") + if(MACOSX) + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist") set_target_properties(${APP_NAME} PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist" - ) + LINK_FLAGS "-pagezero_size 10000 -image_base 100000000" + ) elseif(IOS) - cocos_pak_xcode(${APP_NAME} INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist") + set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon-${APP_NAME}") - set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "") - set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer") endif() + + # For code-signing, set the DEVELOPMENT_TEAM: + #set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") elseif(WINDOWS) cocos_copy_target_dll(${APP_NAME}) endif() diff --git a/tests/lua-tests/project/Classes/lua_test_bindings.cpp b/tests/lua-tests/project/Classes/lua_test_bindings.cpp index fed816e629..d16c8e242e 100644 --- a/tests/lua-tests/project/Classes/lua_test_bindings.cpp +++ b/tests/lua-tests/project/Classes/lua_test_bindings.cpp @@ -151,8 +151,8 @@ bool DrawNode3D::init() { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - - _programState = new backend::ProgramState(lineColor3D_vert, lineColor3D_frag); + auto program = backend::Program::getBuiltinProgram(backend::ProgramType::LINE_COLOR_3D); + _programState = new backend::ProgramState(program); _locMVPMatrix = _programState->getUniformLocation("u_MVPMatrix"); diff --git a/tests/lua-tests/project/proj.android/gradle.properties b/tests/lua-tests/project/proj.android/gradle.properties index 83d8774574..ebbe920606 100644 --- a/tests/lua-tests/project/proj.android/gradle.properties +++ b/tests/lua-tests/project/proj.android/gradle.properties @@ -37,4 +37,6 @@ PROP_APP_ABI=armeabi-v7a #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false diff --git a/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm b/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm index 22818380c2..260767392c 100644 --- a/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm +++ b/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm @@ -84,6 +84,11 @@ static AppDelegate s_sharedApplication; [[UIApplication sharedApplication] setStatusBarHidden: YES]; #endif + //Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior. + if ( [[UIDevice currentDevice].systemVersion floatValue] >= 13.0f) + { + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"]; + } // IMPORTANT: Setting the GLView should be done after creating the RootViewController cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); diff --git a/tests/lua-tests/project/proj.ios_mac/ios/Info.plist b/tests/lua-tests/project/proj.ios_mac/ios/Info.plist index 64b0d48ad1..8539e9cd36 100644 --- a/tests/lua-tests/project/proj.ios_mac/ios/Info.plist +++ b/tests/lua-tests/project/proj.ios_mac/ios/Info.plist @@ -7,9 +7,9 @@ CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} + Icon CFBundleIconFiles Icon-57.png @@ -22,17 +22,19 @@ CFBundleIcons~ipad CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} + org.cocos2dx.$(PRODUCT_NAME) CFBundleInfoDictionaryVersion 6.0 CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} + $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleSignature ???? + CFBundleShortVersionString + 1.0 CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + 1 LSRequiresIPhoneOS NSAppTransportSecurity @@ -57,8 +59,6 @@ accelerometer - opengles-1 - UIStatusBarHidden @@ -68,6 +68,6 @@ UIInterfaceOrientationLandscapeLeft NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} + Copyright © 2019. All rights reserved. diff --git a/tests/lua-tests/project/proj.ios_mac/mac/Info.plist b/tests/lua-tests/project/proj.ios_mac/mac/Info.plist index 241c3b92f6..13d0fefb77 100644 --- a/tests/lua-tests/project/proj.ios_mac/mac/Info.plist +++ b/tests/lua-tests/project/proj.ios_mac/mac/Info.plist @@ -11,7 +11,7 @@ CFBundleIconFile Icon CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,10 +24,8 @@ ???? CFBundleVersion 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright - Copyright © 2012. All rights reserved. + Copyright © 2019. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua index 566abdd122..3a493f32a0 100644 --- a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua +++ b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua @@ -236,6 +236,11 @@ function Camera3DTestDemo:onEnter() local ndo = nearP.x * 0 + nearP.y * 1 + nearP.z * 0 dist= (0 - ndo) / ndd local p = cc.vec3add(nearP, cc.vec3mul(dir, dist)) + + if p.x > 100 then p.x = 100 end + if p.x < -100 then p.x = -100 end + if p.z > 100 then p.z = 100 end + if p.z < -100 then p.z = -100 end self._targetPos = p end end @@ -720,8 +725,10 @@ function FogTestDemo:createLayer3D() local vertexShader = cc.FileUtils:getInstance():getStringFromFile("Sprite3DTest/fog.vert") local fragmentShader = cc.FileUtils:getInstance():getStringFromFile("Sprite3DTest/fog.frag") - self._shader1 = ccb.ProgramState:new(vertexShader, fragmentShader) + local program = ccb.Device:getInstance():newProgram(vertexShader, fragmentShader) + self._shader1 = ccb.ProgramState:new(program) self._shader2 = self._shader1:clone() + program:release() self._sprite3D1 = cc.Sprite3D:create("Sprite3DTest/teapot.c3b") self._sprite3D2 = cc.Sprite3D:create("Sprite3DTest/teapot.c3b") diff --git a/tests/lua-tests/src/ComponentTest/main.lua b/tests/lua-tests/src/ComponentTest/main.lua index 69d59c252f..510c06af8b 100644 --- a/tests/lua-tests/src/ComponentTest/main.lua +++ b/tests/lua-tests/src/ComponentTest/main.lua @@ -22,7 +22,7 @@ local function ComponentTestLayer() layer:addChild(player); local function onEvent(event) - ccexp.AudioEngine:stopAll() + cc.AudioEngine:stopAll() local scene = cc.Scene:create() scene:addChild(ComponentTestLayer()) @@ -32,7 +32,7 @@ local function ComponentTestLayer() local function onNodeEvent(event) if "exit" == event then - ccexp.AudioEngine:stopAll() + cc.AudioEngine:stopAll() end end diff --git a/tests/lua-tests/src/ComponentTest/player.lua b/tests/lua-tests/src/ComponentTest/player.lua index 2a72c2bcd0..7955b48ef7 100644 --- a/tests/lua-tests/src/ComponentTest/player.lua +++ b/tests/lua-tests/src/ComponentTest/player.lua @@ -40,7 +40,7 @@ local player = { local function onTouchesEnded(touches, event) local location = touches[1]:getLocation() self:generateProjectile(location.x, location.y) - ccexp.AudioEngine:play2d("pew-pew-lei.wav") + cc.AudioEngine:play2d("pew-pew-lei.wav") end local listener = cc.EventListenerTouchAllAtOnce:create() diff --git a/tests/lua-tests/src/ComponentTest/scene.lua b/tests/lua-tests/src/ComponentTest/scene.lua index 87c8e3f806..35f98cbf44 100644 --- a/tests/lua-tests/src/ComponentTest/scene.lua +++ b/tests/lua-tests/src/ComponentTest/scene.lua @@ -10,7 +10,7 @@ local scene = { enemies = {}, onEnter = function(self) - ccexp.AudioEngine:play2d("background-music-aac.mp3", true) + cc.AudioEngine:play2d("background-music-aac.mp3", true) end, update = function(self, dt) diff --git a/tests/lua-tests/src/FastTiledMapTest/FastTiledMapTest.lua b/tests/lua-tests/src/FastTiledMapTest/FastTiledMapTest.lua index 1d962da08b..5701f04457 100644 --- a/tests/lua-tests/src/FastTiledMapTest/FastTiledMapTest.lua +++ b/tests/lua-tests/src/FastTiledMapTest/FastTiledMapTest.lua @@ -144,7 +144,7 @@ local function TMXOrthoTest() --local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) --addChild(color, -1) - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test2.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test2.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -178,7 +178,7 @@ end local function TMXOrthoTest2() local layer = createTileDemoLayer("TMX Ortho test2") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test1.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test1.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -195,7 +195,7 @@ end -------------------------------------------------------------------- local function TMXOrthoTest3() local layer = createTileDemoLayer("TMX anchorPoint test") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test3.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test3.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -214,7 +214,7 @@ end -------------------------------------------------------------------- local function TMXOrthoTest4() local ret = createTileDemoLayer("TMX width/height test") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test4.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test4.tmx") ret:addChild(map, 0, kTagTileMap) local s1 = map:getContentSize() @@ -277,7 +277,7 @@ local function TMXReadWriteTest() local ret = createTileDemoLayer("TMX Read/Write test") local m_gid = 0 local m_gid2 = 0 - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test2.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test2.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -437,7 +437,7 @@ local function TMXIsoTest() local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test.tmx") ret:addChild(map, 0, kTagTileMap) -- move map to the center of the screen @@ -457,7 +457,7 @@ local function TMXIsoTest1() local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test1.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test1.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -477,7 +477,7 @@ local function TMXIsoTest2() local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test2.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test2.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -500,7 +500,7 @@ local function TMXUncompressedTest() local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -521,7 +521,7 @@ end -------------------------------------------------------------------- local function TMXTilesetTest() local ret = createTileDemoLayer("TMX Tileset test") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test5.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test5.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -537,7 +537,7 @@ end -------------------------------------------------------------------- local function TMXOrthoObjectsTest() local ret = createTileDemoLayer("TMX Ortho object test", "You should see a white box around the 3 platforms") - local map = ccexp.TMXTiledMap:create("TileMaps/ortho-objects.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/ortho-objects.tmx") ret:addChild(map, -1, kTagTileMap) local s = map:getContentSize() @@ -595,7 +595,7 @@ end local function TMXIsoObjectsTest() local ret = createTileDemoLayer("TMX Iso object test", "You need to parse them manually. See bug #810") - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx") ret:addChild(map, -1, kTagTileMap) local s = map:getContentSize() @@ -646,7 +646,7 @@ end local function TMXResizeTest() local ret = createTileDemoLayer("TMX resize test", "Should not crash. Testing issue #740") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test5.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test5.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -672,7 +672,7 @@ end local function TMXIsoZorder() local m_tamara = nil local ret = createTileDemoLayer("TMX Iso Zorder", "Sprite should hide behind the trees") - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test-zorder.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test-zorder.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -733,7 +733,7 @@ end local function TMXOrthoZorder() local m_tamara = nil local ret = createTileDemoLayer("TMX Ortho Zorder", "Sprite should hide behind the trees") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -791,7 +791,7 @@ end local function TMXIsoVertexZ() local m_tamara = nil local ret = createTileDemoLayer("TMX Iso VertexZ", "Sprite should hide behind the trees") - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test-vertexz.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test-vertexz.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -850,7 +850,7 @@ end local function TMXOrthoVertexZ() local m_tamara = nil local ret = createTileDemoLayer("TMX Ortho vertexZ", "Sprite should hide behind the trees") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -908,7 +908,7 @@ end -------------------------------------------------------------------- local function TMXIsoMoveLayer() local ret = createTileDemoLayer("TMX Iso Move Layer", "Trees should be horizontally aligned") - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) map:setPosition(cc.p(-700,-50)) @@ -926,7 +926,7 @@ end -------------------------------------------------------------------- local function TMXOrthoMoveLayer() local ret = createTileDemoLayer("TMX Ortho Move Layer", "Trees should be horizontally aligned") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test-movelayer.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -959,7 +959,7 @@ end local function TMXOrthoFlipTest() local ret = createTileDemoLayer("TMX tile flip test") - local map = ccexp.TMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -978,7 +978,7 @@ end local function TMXOrthoFlipRunTimeTest() local ret = createTileDemoLayer("TMX tile flip run time test", "in 2 sec bottom left tiles will flip") - local map = ccexp.TMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -1052,7 +1052,7 @@ local function TMXOrthoFromXMLTest() cclog("Unable to open file") end - local map = ccexp.TMXTiledMap:createWithXML(str ,resources) + local map = cc.FastTMXTiledMap:createWithXML(str ,resources) ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -1072,7 +1072,7 @@ end local function TMXOrthoXMLFormatTest() local ret = createTileDemoLayer("you should see blue, green and yellow in console.") - local map = ccexp.TMXTiledMap:create("TileMaps/xml-test.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/xml-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -1094,7 +1094,7 @@ end -------------------------------------------------------------------- local function TMXBug987() local ret = createTileDemoLayer("TMX Bug 987", "You should see an square") - local map = ccexp.TMXTiledMap:create("TileMaps/orthogonal-test6.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/orthogonal-test6.tmx") ret:addChild(map, 0, kTagTileMap) local s1 = map:getContentSize() @@ -1113,7 +1113,7 @@ end -------------------------------------------------------------------- local function TMXBug787() local ret = createTileDemoLayer("TMX Bug 787", "You should see a map") - local map = ccexp.TMXTiledMap:create("TileMaps/iso-test-bug787.tmx") + local map = cc.FastTMXTiledMap:create("TileMaps/iso-test-bug787.tmx") ret:addChild(map, 0, kTagTileMap) map:setScale(0.25) return ret diff --git a/tests/lua-tests/src/NewAudioEngineTest/NewAudioEngineTest.lua b/tests/lua-tests/src/NewAudioEngineTest/NewAudioEngineTest.lua index d9c4423d87..1744fea745 100644 --- a/tests/lua-tests/src/NewAudioEngineTest/NewAudioEngineTest.lua +++ b/tests/lua-tests/src/NewAudioEngineTest/NewAudioEngineTest.lua @@ -123,7 +123,7 @@ function AudioControlTest.create() ------playItem local function playAudio(tag, sender) if AudioControlTest._audioID == cc.AUDIO_INVAILD_ID then - AudioControlTest._audioID = ccexp.AudioEngine:play2d("background.mp3", AudioControlTest._loopEnabled, AudioControlTest._volume) + AudioControlTest._audioID = cc.AudioEngine:play2d("background.mp3", AudioControlTest._loopEnabled, AudioControlTest._volume) if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then AudioControlTest._playItem:setEnabled(false) @@ -133,7 +133,7 @@ function AudioControlTest.create() AudioControlTest._playItem:setEnabled(true) end - ccexp.AudioEngine:setFinishCallback(AudioControlTest._audioID,finishCallback) + cc.AudioEngine:setFinishCallback(AudioControlTest._audioID,finishCallback) end end end @@ -145,7 +145,7 @@ function AudioControlTest.create() ------stopItem local function stopAudio(tag, sender) if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then - ccexp.AudioEngine:stop(AudioControlTest._audioID) + cc.AudioEngine:stop(AudioControlTest._audioID) AudioControlTest._audioID = cc.AUDIO_INVAILD_ID AudioControlTest._playItem:setEnabled(true) end @@ -158,7 +158,7 @@ function AudioControlTest.create() ------pauseItem local function pauseAudio(tag, sender) if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then - ccexp.AudioEngine:pause(AudioControlTest._audioID) + cc.AudioEngine:pause(AudioControlTest._audioID) end end @@ -169,7 +169,7 @@ function AudioControlTest.create() ------resumeItem local function resumeAudio(tag, sender) if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then - ccexp.AudioEngine:resume(AudioControlTest._audioID) + cc.AudioEngine:resume(AudioControlTest._audioID) end end @@ -181,7 +181,7 @@ function AudioControlTest.create() local function switchLoop(tag, sender) AudioControlTest._loopEnabled = not AudioControlTest._loopEnabled if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then - ccexp.AudioEngine:setLoop(AudioControlTest._audioID, AudioControlTest._loopEnabled) + cc.AudioEngine:setLoop(AudioControlTest._audioID, AudioControlTest._loopEnabled) end if AudioControlTest._loopEnabled then AudioControlTest.loopItem:setString("disable-loop") @@ -196,7 +196,7 @@ function AudioControlTest.create() ------uncacheItem local function uncache(tag, sender) - ccexp.AudioEngine:uncache("background.mp3") + cc.AudioEngine:uncache("background.mp3") AudioControlTest._audioID = cc.AUDIO_INVAILD_ID AudioControlTest._playItem:setEnabled(true) end @@ -218,7 +218,7 @@ function AudioControlTest.create() local function volumeSliderChangedEvent(sender,eventType) AudioControlTest._volume = sender:getPercent() / 100.0 if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then - ccexp.AudioEngine:setVolume(AudioControlTest._audioID, AudioControlTest._volume) + cc.AudioEngine:setVolume(AudioControlTest._audioID, AudioControlTest._volume) end end local volumeSlider = ccui.Slider:create() @@ -247,7 +247,7 @@ function AudioControlTest.create() AudioControlTest._updateTimeSlider = false else if (AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID and AudioControlTest._duration ~= cc.AUDIO_TIME_UNKNOWN) then - ccexp.AudioEngine:setCurrentTime(AudioControlTest._audioID,AudioControlTest._duration * ratio) + cc.AudioEngine:setCurrentTime(AudioControlTest._audioID,AudioControlTest._duration * ratio) end AudioControlTest._updateTimeSlider = true end @@ -261,10 +261,10 @@ function AudioControlTest.create() local function step(dt) if AudioControlTest._audioID ~= cc.AUDIO_INVAILD_ID then if AudioControlTest._duration == cc.AUDIO_TIME_UNKNOWN then - AudioControlTest._duration = ccexp.AudioEngine:getDuration(AudioControlTest._audioID) + AudioControlTest._duration = cc.AudioEngine:getDuration(AudioControlTest._audioID) end if AudioControlTest._duration ~= cc.AUDIO_TIME_UNKNOWN then - local time = ccexp.AudioEngine:getCurrentTime(AudioControlTest._audioID) + local time = cc.AudioEngine:getCurrentTime(AudioControlTest._audioID) AudioControlTest._timeRatio = time / AudioControlTest._duration if AudioControlTest._updateTimeSlider then AudioControlTest._timeSlider:setRatio(AudioControlTest._timeRatio) @@ -277,7 +277,7 @@ function AudioControlTest.create() function onNodeEvent(tag) if tag == "exit" then - ccexp.AudioEngine:stopAll() + cc.AudioEngine:stopAll() end end layer:registerScriptHandler(onNodeEvent) @@ -302,7 +302,7 @@ function PlaySimultaneouslyTest.create() local audioID = cc.AUDIO_INVAILD_ID --for k, v in pairs(PlaySimultaneouslyTest.files) do for index=1,10 do - audioID = ccexp.AudioEngine:play2d(PlaySimultaneouslyTest.files[index]) + audioID = cc.AudioEngine:play2d(PlaySimultaneouslyTest.files[index]) if audioID ~= cc.AUDIO_INVAILD_ID then PlaySimultaneouslyTest._playItem:setEnabled(false) @@ -315,7 +315,7 @@ function PlaySimultaneouslyTest.create() end end - ccexp.AudioEngine:setFinishCallback(audioID,finishCallback) + cc.AudioEngine:setFinishCallback(audioID,finishCallback) end end end @@ -330,7 +330,7 @@ function PlaySimultaneouslyTest.create() function onNodeEvent(tag) if tag == "exit" then - ccexp.AudioEngine:stopAll() + cc.AudioEngine:stopAll() end end layer:registerScriptHandler(onNodeEvent) @@ -356,7 +356,7 @@ function AudioProfileTest.create() AudioProfileTest._files[2] = "background.ogg" end - AudioProfileTest._profile = ccexp.AudioProfile:new() + AudioProfileTest._profile = cc.AudioProfile:new() AudioProfileTest._profile.name = "AudioProfileTest" AudioProfileTest._profile.maxInstances = 3 AudioProfileTest._profile.minDelay = 1.0 @@ -372,7 +372,7 @@ function AudioProfileTest.create() local heightRatio = 0.7 for index=1,2 do local function itemClickCallback(tag, sender) - local audioID = ccexp.AudioEngine:play2d(AudioProfileTest._files[tag],false,1.0,AudioProfileTest._profile) + local audioID = cc.AudioEngine:play2d(AudioProfileTest._files[tag],false,1.0,AudioProfileTest._profile) if audioID ~= cc.AUDIO_INVAILD_ID then AudioProfileTest._time = AudioProfileTest._minDelay AudioProfileTest._audioCount = AudioProfileTest._audioCount + 1 @@ -383,7 +383,7 @@ function AudioProfileTest.create() AudioProfileTest._showLabel:setString(string.format("audio count:%d",AudioProfileTest._audioCount)) end - ccexp.AudioEngine:setFinishCallback(audioID,finishCallback) + cc.AudioEngine:setFinishCallback(audioID,finishCallback) end end @@ -429,7 +429,7 @@ function AudioProfileTest.create() function onNodeEvent(tag) if tag == "exit" then - ccexp.AudioEngine:stopAll() + cc.AudioEngine:stopAll() end end layer:registerScriptHandler(onNodeEvent) @@ -450,10 +450,10 @@ function InvalidAudioFileTest.create() local function playUnsupportedAudio(tag, sender) local targetPlatform = cc.Application:getInstance():getTargetPlatform() if (cc.PLATFORM_OS_MAC == currPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) then - ccexp.AudioEngine:play2d("background.ogg") + cc.AudioEngine:play2d("background.ogg") end if (cc.PLATFORM_OS_ANDROID == targetPlatform) then - ccexp.AudioEngine:play2d("background.caf") + cc.AudioEngine:play2d("background.caf") end end @@ -463,7 +463,7 @@ function InvalidAudioFileTest.create() -- not-existent audio local function playNotExistentAudio(tag, sender) - ccexp.AudioEngine:play2d("not-existent file.mp3") + cc.AudioEngine:play2d("not-existent file.mp3") end local playItem2 = cc.MenuItemFont:create("play not-existent file") @@ -488,7 +488,7 @@ function LargeAudioFileTest.create() local layerSize = layer:getContentSize() local function playAudio(tag, sender) - ccexp.AudioEngine:play2d("audio/LuckyDay.mp3") + cc.AudioEngine:play2d("audio/LuckyDay.mp3") end local playItem = cc.MenuItemFont:create("play large audio file") @@ -501,7 +501,7 @@ function LargeAudioFileTest.create() function onNodeEvent(tag) if tag == "exit" then - ccexp.AudioEngine:stopAll() + cc.AudioEngine:stopAll() end end layer:registerScriptHandler(onNodeEvent) diff --git a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua index 6f45ba2962..16258d48f2 100644 --- a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua +++ b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua @@ -1154,26 +1154,33 @@ local function PhysicsContactTest() layer:addChild(root) local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height) - + local subtitleLabelPosX, subtitleLabelPosY = Helper.subtitleLabel:getPosition() + local restartTestItemPosX, restartTestItemPosY = Helper.restartTestItem:getPosition() + local prevMenuPos = subtitleLabelPosY - Helper.subtitleLabel:getContentSize().height; + local menuStep = (subtitleLabelPosY -restartTestItemPosY) * 0.25; + local label = cc.Label:createWithTTF(tostring(layer.yellowBoxNum), s_arialPath, 32) root:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2, s.height-50)) + label:setPosition(cc.p(s.width/2, prevMenuPos)) + prevMenuPos = prevMenuPos - menuStep label = cc.Label:createWithTTF(tostring(layer.blueBoxNum), s_arialPath, 32) root:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2, s.height-90)) + label:setPosition(cc.p(s.width/2, prevMenuPos)) + prevMenuPos = prevMenuPos - menuStep label = cc.Label:createWithTTF(tostring(layer.yellowTriangleNum), s_arialPath, 32) root:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2, s.height-130)) + label:setPosition(cc.p(s.width/2, prevMenuPos)) + prevMenuPos = prevMenuPos - menuStep label = cc.Label:createWithTTF(tostring(layer.blueTriangleNum), s_arialPath, 32) root:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2, s.height-170)) + label:setPosition(cc.p(s.width/2, prevMenuPos)) local wall = cc.Node:create() wall:setPhysicsBody(cc.PhysicsBody:createEdgeBox(s, cc.PhysicsMaterial(0.1, 1, 0.0))) @@ -1287,8 +1294,13 @@ local function PhysicsContactTest() resetTest() end - - cc.MenuItemFont:setFontSize(65) + + local subtitleLabelPosX, subtitleLabelPosY = Helper.subtitleLabel:getPosition() + local restartTestItemPosX, restartTestItemPosY = Helper.restartTestItem:getPosition() + local prevMenuPos = subtitleLabelPosY - Helper.subtitleLabel:getContentSize().height; + local menuStep = (subtitleLabelPosY -restartTestItemPosY) * 0.25; + + cc.MenuItemFont:setFontSize(30) local decrease1 = cc.MenuItemFont:create(" - ") decrease1:setColor(cc.c3b(0,200,20)) local increase1 = cc.MenuItemFont:create(" + ") @@ -1300,13 +1312,13 @@ local function PhysicsContactTest() local menu1 = cc.Menu:create(decrease1, increase1) menu1:alignItemsHorizontally() - menu1:setPosition(cc.p(s.width/2, s.height-50)) + menu1:setPosition(cc.p(s.width/2, prevMenuPos)) layer:addChild(menu1, 1) local label = cc.Label:createWithTTF("yellow box", s_arialPath, 32) layer:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2 - 150, s.height-50)) + label:setPosition(cc.p(s.width/2 - 150, prevMenuPos)) local decrease2 = cc.MenuItemFont:create(" - ") decrease2:setColor(cc.c3b(0,200,20)) @@ -1317,15 +1329,16 @@ local function PhysicsContactTest() decrease2:registerScriptTapHandler(onDecrease) increase2:registerScriptTapHandler(onIncrease) + prevMenuPos = prevMenuPos - menuStep local menu2 = cc.Menu:create(decrease2, increase2) menu2:alignItemsHorizontally() - menu2:setPosition(cc.p(s.width/2, s.height-90)) + menu2:setPosition(cc.p(s.width/2, prevMenuPos)) layer:addChild(menu2, 1) label = cc.Label:createWithTTF("blue box", s_arialPath, 32) layer:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2 - 150, s.height-90)) + label:setPosition(cc.p(s.width/2 - 150, prevMenuPos)) local decrease3 = cc.MenuItemFont:create(" - ") decrease3:setColor(cc.c3b(0,200,20)) @@ -1336,15 +1349,16 @@ local function PhysicsContactTest() decrease3:registerScriptTapHandler(onDecrease) increase3:registerScriptTapHandler(onIncrease) + prevMenuPos = prevMenuPos - menuStep local menu3 = cc.Menu:create(decrease3, increase3) menu3:alignItemsHorizontally() - menu3:setPosition(cc.p(s.width/2, s.height-130)) + menu3:setPosition(cc.p(s.width/2, prevMenuPos)) layer:addChild(menu3, 1) label = cc.Label:createWithTTF("yellow triangle", s_arialPath, 32) layer:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2 - 150, s.height-130)) + label:setPosition(cc.p(s.width/2 - 150, prevMenuPos)) local decrease4 = cc.MenuItemFont:create(" - ") decrease4:setColor(cc.c3b(0,200,20)) @@ -1355,15 +1369,16 @@ local function PhysicsContactTest() decrease4:registerScriptTapHandler(onDecrease) increase4:registerScriptTapHandler(onIncrease) + prevMenuPos = prevMenuPos - menuStep local menu4 = cc.Menu:create(decrease4, increase4) menu4:alignItemsHorizontally() - menu4:setPosition(cc.p(s.width/2, s.height-170)) + menu4:setPosition(cc.p(s.width/2, prevMenuPos)) layer:addChild(menu4, 1) label = cc.Label:createWithTTF("blue triangle", s_arialPath, 32) layer:addChild(label, 1) label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setPosition(cc.p(s.width/2 - 150, s.height-170)) + label:setPosition(cc.p(s.width/2 - 150, prevMenuPos)) local contactListener = cc.EventListenerPhysicsContact:create() diff --git a/tests/lua-tests/src/Scene3DTest/Scene3DTest.lua b/tests/lua-tests/src/Scene3DTest/Scene3DTest.lua index 030b42e59f..2dbe46e6dc 100644 --- a/tests/lua-tests/src/Scene3DTest/Scene3DTest.lua +++ b/tests/lua-tests/src/Scene3DTest/Scene3DTest.lua @@ -181,34 +181,16 @@ function TerrainWalkThru:init() local dir = cc.vec3sub(farP, nearP) dir = cc.vec3normalize(dir) - local rayStep = cc.vec3mul(dir, 15) - local rayPos = nearP - local rayStartPosition = nearP - local lastRayPosition = rayPos - rayPos = cc.vec3add(rayPos, rayStep) - -- Linear search - Loop until find a point inside and outside the terrain Vector3 - local height = self._terrain:getHeight(rayPos.x, rayPos.z) + local collisionPoint = cc.vec3(-999,-999,-999) + local ray = cc.Ray:new(nearP, dir) + local isInTerrain = true; + isInTerrain, collisionPoint = self._terrain:getIntersectionPoint(ray, collisionPoint) - while rayPos.y > height do - lastRayPosition = rayPos - rayPos = cc.vec3add(rayPos, rayStep) - height = self._terrain:getHeight(rayPos.x,rayPos.z) + if( not isInTerrain) then + self._player:idle() + return end - local startPosition = lastRayPosition - local endPosition = rayPos - - for i = 1, 32 do - -- Binary search pass - local middlePoint = cc.vec3mul(cc.vec3add(startPosition, endPosition), 0.5) - if (middlePoint.y < height) then - endPosition = middlePoint - else - startPosition = middlePoint - end - end - - local collisionPoint = cc.vec3mul(cc.vec3add(startPosition, endPosition), 0.5) local playerPos = self._player:getPosition3D() dir = cc.vec3sub(collisionPoint, playerPos) dir.y = 0 @@ -217,7 +199,6 @@ function TerrainWalkThru:init() self._player._headingAxis = vec3_cross(dir, cc.vec3(0, 0, -1), self._player._headingAxis) self._player._targetPos = collisionPoint - -- self._player:forward() self._player._playerState = PLAER_STATE.FORWARD end end @@ -333,9 +314,9 @@ function Scene3DTest:create3DWorld() local cmVert = cc.FileUtils:getInstance():getStringFromFile("Sprite3DTest/cube_map.vert") local cmFrag = cc.FileUtils:getInstance():getStringFromFile("Sprite3DTest/cube_map.frag") - - local state = ccb.ProgramState:new(cmVert, cmFrag) - + local program = ccb.Device:getInstance():newProgram(cmVert, cmFrag) + local state = ccb.ProgramState:new(program) + program:release() --create the second texture for cylinder self._textureCube = cc.TextureCube:create("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg", "Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg", @@ -492,26 +473,26 @@ function Scene3DTest:createDetailDlg() self._detailDlg:addChild(title) -- add a spine ffd animation on it - -- TODO: spine is not enable in V4.0 - local skeletonNode = sp.SkeletonAnimation:create("spine/goblins-pro.json", "spine/goblins.atlas", 1.5) - skeletonNode:setAnimation(0, "walk", true) - skeletonNode:setSkin("goblin") - - skeletonNode:setScale(0.25) - local windowSize = cc.Director:getInstance():getWinSize() - skeletonNode:setPosition(cc.p(dlgSize.width / 2, 20)) - self._detailDlg:addChild(skeletonNode) + -- TODO coulsonwang: spine is not enable in V4.0 +-- local skeletonNode = sp.SkeletonAnimation:create("spine/goblins-pro.json", "spine/goblins.atlas", 1.5) +-- skeletonNode:setAnimation(0, "walk", true) +-- skeletonNode:setSkin("goblin") +-- +-- skeletonNode:setScale(0.25) +-- local windowSize = cc.Director:getInstance():getWinSize() +-- skeletonNode:setPosition(cc.p(dlgSize.width / 2, 20)) +-- self._detailDlg:addChild(skeletonNode) local listener = cc.EventListenerTouchOneByOne:create() listener:registerScriptHandler(function (touch, event) - if (not skeletonNode:getDebugBonesEnabled()) then - skeletonNode:setDebugBonesEnabled(true) - elseif skeletonNode:getTimeScale() == 1 then - skeletonNode:setTimeScale(0.3) - else - skeletonNode:setTimeScale(1) - skeletonNode:setDebugBonesEnabled(false) - end +-- if (not skeletonNode:getDebugBonesEnabled()) then +-- skeletonNode:setDebugBonesEnabled(true) +-- elseif skeletonNode:getTimeScale() == 1 then +-- skeletonNode:setTimeScale(0.3) +-- else +-- skeletonNode:setTimeScale(1) +-- skeletonNode:setDebugBonesEnabled(false) +-- end return true end,cc.Handler.EVENT_TOUCH_BEGAN ) diff --git a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua index a81b52c70d..47f44d926a 100644 --- a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua +++ b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua @@ -1125,9 +1125,10 @@ function Sprite3DCubeMapTest:addNewSpriteWithCoords(pos) local vertexShader = cc.FileUtils:getInstance():getStringFromFile("Sprite3DTest/cube_map.vert") local fragmentShader = cc.FileUtils:getInstance():getStringFromFile("Sprite3DTest/cube_map.frag") - - local programState = ccb.ProgramState:new(vertexShader, fragmentShader) - + local program = ccb.Device:getInstance():newProgram(vertexShader, fragmentShader) + local programState = ccb.ProgramState:new(program) + program:release() + self._textureCube = cc.TextureCube:create("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg", "Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg", "Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg") diff --git a/tests/lua-tests/src/VideoPlayerTest/VideoPlayerTest.lua b/tests/lua-tests/src/VideoPlayerTest/VideoPlayerTest.lua index 28c5ef1e0a..79fa34287a 100644 --- a/tests/lua-tests/src/VideoPlayerTest/VideoPlayerTest.lua +++ b/tests/lua-tests/src/VideoPlayerTest/VideoPlayerTest.lua @@ -18,18 +18,18 @@ local function VideoPlayerTest() layer:addChild(videoStateLabel) local function onVideoEventCallback(sener, eventType) - if eventType == ccexp.VideoPlayerEvent.PLAYING then + if eventType == ccui.VideoPlayerEvent.PLAYING then videoStateLabel:setString("PLAYING") - elseif eventType == ccexp.VideoPlayerEvent.PAUSED then + elseif eventType == ccui.VideoPlayerEvent.PAUSED then videoStateLabel:setString("PAUSED") - elseif eventType == ccexp.VideoPlayerEvent.STOPPED then + elseif eventType == ccui.VideoPlayerEvent.STOPPED then videoStateLabel:setString("STOPPED") - elseif eventType == ccexp.VideoPlayerEvent.COMPLETED then + elseif eventType == ccui.VideoPlayerEvent.COMPLETED then videoStateLabel:setString("COMPLETED") end end local widgetSize = widget:getContentSize() - local videoPlayer = ccexp.VideoPlayer:create() + local videoPlayer = ccui.VideoPlayer:create() videoPlayer:setPosition(centerPos) videoPlayer:setAnchorPoint(cc.p(0.5, 0.5)) videoPlayer:setContentSize(cc.size(widgetSize.width * 0.4,widgetSize.height * 0.4)) diff --git a/tests/lua-tests/src/WebViewTest/WebViewTest.lua b/tests/lua-tests/src/WebViewTest/WebViewTest.lua index a33ca19259..e655cad5ff 100644 --- a/tests/lua-tests/src/WebViewTest/WebViewTest.lua +++ b/tests/lua-tests/src/WebViewTest/WebViewTest.lua @@ -18,7 +18,7 @@ function WebViewTest:init() Helper.subtitleLabel:setString(self:subtitle()) local winSize = cc.Director:getInstance():getVisibleSize() - self._webView = ccexp.WebView:create() + self._webView = ccui.WebView:create() self._webView:setPosition(winSize.width / 2, winSize.height / 2) self._webView:setContentSize(winSize.width / 2, winSize.height / 2) self._webView:loadURL("https://www.baidu.com") diff --git a/tests/lua-tests/src/helper.lua b/tests/lua-tests/src/helper.lua index 8ff5132b0a..583fc0fb8a 100644 --- a/tests/lua-tests/src/helper.lua +++ b/tests/lua-tests/src/helper.lua @@ -33,7 +33,8 @@ Helper = { createFunctioinTable = nil, currentLayer = nil, titleLabel = nil, - subtitleLabel = nil + subtitleLabel = nil, + restartTestItem = nil } function Helper.nextAction() @@ -93,6 +94,7 @@ function Helper.initWithLayer(layer) item1:registerScriptTapHandler(Helper.backAction) item2:registerScriptTapHandler(Helper.restartAction) item3:registerScriptTapHandler(Helper.nextAction) + Helper.restartTestItem = item2 local menu = cc.Menu:create() menu:addChild(item1) diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index ff23100542..971c82e988 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -194,6 +194,8 @@ function CreateTestMenu() CloseMenu:addChild(CloseItem) menuLayer:addChild(CloseMenu) + local targetPlatform = cc.Application:getInstance():getTargetPlatform() + -- add menu items for tests local MainMenu = cc.Menu:create() local index = 0 diff --git a/tests/performance-tests/proj.android/gradle.properties b/tests/performance-tests/proj.android/gradle.properties index 37661c012e..24ed69788b 100644 --- a/tests/performance-tests/proj.android/gradle.properties +++ b/tests/performance-tests/proj.android/gradle.properties @@ -42,4 +42,6 @@ PROP_BUILD_TYPE=cmake #RELEASE_STORE_FILE=file path of keystore #RELEASE_STORE_PASSWORD=password of keystore #RELEASE_KEY_ALIAS=alias of key -#RELEASE_KEY_PASSWORD=password of key \ No newline at end of file +#RELEASE_KEY_PASSWORD=password of key + +android.injected.testOnly=false diff --git a/tests/performance-tests/proj.ios/AppController.mm b/tests/performance-tests/proj.ios/AppController.mm index b1e54524e2..b8765f41fe 100644 --- a/tests/performance-tests/proj.ios/AppController.mm +++ b/tests/performance-tests/proj.ios/AppController.mm @@ -81,6 +81,12 @@ static AppDelegate s_sharedApplication; [[UIApplication sharedApplication] setStatusBarHidden:true]; + //Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior. + if ( [[UIDevice currentDevice].systemVersion floatValue] >= 13.0f) + { + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"]; + } + // IMPORTANT: Setting the GLView should be done after creating the RootViewController cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); cocos2d::Director::getInstance()->setOpenGLView(glview); diff --git a/tests/performance-tests/proj.ios/Info.plist b/tests/performance-tests/proj.ios/Info.plist index e28dd7c2c2..5d9101cf04 100644 --- a/tests/performance-tests/proj.ios/Info.plist +++ b/tests/performance-tests/proj.ios/Info.plist @@ -42,7 +42,7 @@ Icon-144.png CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -50,11 +50,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - + 1.0 CFBundleSignature ???? CFBundleVersion - 1.0 + 1 LSRequiresIPhoneOS UIAppFonts @@ -151,5 +151,7 @@ UIInterfaceOrientationLandscapeRight UIInterfaceOrientationLandscapeLeft + NSHumanReadableCopyright + Copyright © 2019. All rights reserved. diff --git a/tests/performance-tests/proj.mac/Info.plist b/tests/performance-tests/proj.mac/Info.plist index c08a435c3c..7251aefce9 100644 --- a/tests/performance-tests/proj.mac/Info.plist +++ b/tests/performance-tests/proj.mac/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile Icon CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + org.cocos2dx.${PRODUCT_NAME} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,10 +24,8 @@ 1 LSApplicationCategoryType public.app-category.games - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright - Copyright © 2013. All rights reserved. + Copyright © 2019. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 7df5348d16..56f86f7331 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 7df5348d16ef6c3e24d4ae6fc072e158ffc1738b +Subproject commit 56f86f7331cdac89fbd19f6b75963a4c12f53089 diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 99dea8ac05..3c27181756 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.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 = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ AsyncTaskPool RenderState Material Properties Technique Pass PolygonInfo AutoPolygon BoneNode SkeletonNode ComponentLua PipelineDescriptor Renderer +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ AsyncTaskPool RenderState Material Properties Technique Pass PolygonInfo AutoPolygon BoneNode SkeletonNode ComponentLua PipelineDescriptor Renderer FastTMXLayer FastTMXTiledMap # 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 @@ -91,6 +91,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS TiledGrid3DAction::[create actionWith.* tile originalTile getOriginalTile (g|s)etTile], TiledGrid3D::[tile originalTile getOriginalTile (g|s)etTile], TMXLayer::[getTiles getTileGIDAt setTiles], + FastTMXLayer::[(g|s)etTiles getTileGIDAt], TMXMapInfo::[startElement endElement textHandler], ParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node], LayerMultiplex::[create layerWith.* initWithLayers], diff --git a/tools/tolua/cocos2dx_audioengine.ini b/tools/tolua/cocos2dx_audioengine.ini index 3d75a34000..d097f6be2f 100644 --- a/tools/tolua/cocos2dx_audioengine.ini +++ b/tools/tolua/cocos2dx_audioengine.ini @@ -5,7 +5,7 @@ prefix = cocos2dx_audioengine # create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) # all classes will be embedded in that namespace -target_namespace = ccexp +target_namespace = cc macro_judgement = #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/tools/tolua/cocos2dx_backend.ini b/tools/tolua/cocos2dx_backend.ini index 7521bed03d..02f5f4b314 100644 --- a/tools/tolua/cocos2dx_backend.ini +++ b/tools/tolua/cocos2dx_backend.ini @@ -23,12 +23,12 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/renderer/backend/Types.h %(cocosdir)s/cocos/renderer/backend/ProgramState.h %(cocosdir)s/cocos/renderer/backend/Texture.h %(cocosdir)s/cocos/renderer/backend/VertexLayout.h +headers = %(cocosdir)s/cocos/renderer/backend/Types.h %(cocosdir)s/cocos/renderer/backend/ProgramState.h %(cocosdir)s/cocos/renderer/backend/Texture.h %(cocosdir)s/cocos/renderer/backend/VertexLayout.h %(cocosdir)s/cocos/renderer/backend/Device.h #headers = %(cocosdir)s/cocos/renderer/backend/ProgramState.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 = VertexLayout BufferUsage BufferType ShaderStage VertexFormat PixelFormat TextureUsage IndexFormat VertexStepMode PrimitiveType TextureType SamplerAddressMode SamplerFilter StencilOperation CompareFunction BlendOperation BlendFactor ColorWriteMask SamplerDescriptor CullMode Winding UniformInfo UniformLocation AttributeBindInfo TextureCubeFace ProgramState TextureBackend Program Texture2DBackend TextureCubemapBackend +classes = VertexLayout BufferUsage BufferType ShaderStage VertexFormat PixelFormat TextureUsage IndexFormat VertexStepMode PrimitiveType TextureType SamplerAddressMode SamplerFilter StencilOperation CompareFunction BlendOperation BlendFactor ColorWriteMask SamplerDescriptor CullMode Winding UniformInfo UniformLocation AttributeBindInfo TextureCubeFace ProgramState TextureBackend Program Texture2DBackend TextureCubemapBackend Device # 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,8 @@ classes = VertexLayout BufferUsage BufferType ShaderStage VertexFormat PixelForm skip = VertexLayout::[getAttributes], ProgramState::[getCallbackUniforms getVertexTextureInfos getVertexUniformInfos getFragmentTextureInfos getFragmentUniformInfos setTextureArray setCallbackUniform setUniform getVertexUniformBuffer getFragmentUniformBuffer getVertexLayout getUniformLocation], - Program::[getFragmentUniformInfos getVertexUniformInfos cloneUniformBuffer getActiveUniformInfo getAllActiveUniformInfo] - + Program::[getFragmentUniformInfos getVertexUniformInfos cloneUniformBuffer getActiveUniformInfo getAllActiveUniformInfo], + Device::[newCommandBuffer newBuffer newTexture createDepthStencilState newRenderPipeline setFrameBufferOnly getDeviceInfo] rename_functions = rename_classes = diff --git a/tools/tolua/cocos2dx_experimental.ini b/tools/tolua/cocos2dx_experimental.ini deleted file mode 100644 index d579896ba2..0000000000 --- a/tools/tolua/cocos2dx_experimental.ini +++ /dev/null @@ -1,61 +0,0 @@ -[cocos2dx_experimental] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = cocos2dx_experimental - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = ccexp - -android_headers = - -android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include - -clang_headers = -clang_flags = -nostdinc -x c++ -std=c++11 -fsigned-char -U__SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(cocosdir)s/cocos/2d/CCFastTMXLayer.h %(cocosdir)s/cocos/2d/CCFastTMXTiledMap.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 = TMXLayer TMXTiledMap - -# 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 -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = TMXLayer::[(g|s)etTiles getTileGIDAt] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -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 - diff --git a/tools/tolua/cocos2dx_ui.ini b/tools/tolua/cocos2dx_ui.ini index b877f4d54d..48103a81bd 100644 --- a/tools/tolua/cocos2dx_ui.ini +++ b/tools/tolua/cocos2dx_ui.ini @@ -44,7 +44,6 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*H Widget::[addTouchEventListener addClickEventListener addCCSEventListener], LayoutParameter::[(s|g)etMargin], RichText::[setTagDescription removeTagDescription setOpenUrlHandler] - rename_functions = rename_classes = diff --git a/tools/tolua/cocos2dx_experimental_video.ini b/tools/tolua/cocos2dx_video.ini similarity index 92% rename from tools/tolua/cocos2dx_experimental_video.ini rename to tools/tolua/cocos2dx_video.ini index 004c030813..bf876774bd 100644 --- a/tools/tolua/cocos2dx_experimental_video.ini +++ b/tools/tolua/cocos2dx_video.ini @@ -1,13 +1,11 @@ -[cocos2dx_experimental_video] +[cocos2dx_video] # the prefix to be added to the generated functions. You might or might not use this in your own # templates -prefix = cocos2dx_experimental_video +prefix = cocos2dx_video # create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) # all classes will be embedded in that namespace -target_namespace = ccexp - -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +target_namespace = ccui android_headers = diff --git a/tools/tolua/cocos2dx_experimental_webview.ini b/tools/tolua/cocos2dx_webview.ini similarity index 92% rename from tools/tolua/cocos2dx_experimental_webview.ini rename to tools/tolua/cocos2dx_webview.ini index 3d738cb66d..e92626b865 100644 --- a/tools/tolua/cocos2dx_experimental_webview.ini +++ b/tools/tolua/cocos2dx_webview.ini @@ -1,14 +1,11 @@ -[cocos2dx_experimental_webview] +[cocos2dx_webview] # the prefix to be added to the generated functions. You might or might not use this in your own # templates -prefix = cocos2dx_experimental_webview +prefix = cocos2dx_webview # create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) # all classes will be embedded in that namespace -target_namespace = ccexp - -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - +target_namespace = ccui android_headers = android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include diff --git a/tools/tolua/genbindings.py b/tools/tolua/genbindings.py index 0ab59acfcb..98c3da823d 100755 --- a/tools/tolua/genbindings.py +++ b/tools/tolua/genbindings.py @@ -206,13 +206,12 @@ def main(): 'cocos2dx_studio.ini' : ('cocos2dx_studio', 'lua_cocos2dx_studio_auto'), \ 'cocos2dx_spine.ini' : ('cocos2dx_spine', 'lua_cocos2dx_spine_auto'), \ 'cocos2dx_physics.ini' : ('cocos2dx_physics', 'lua_cocos2dx_physics_auto'), \ - 'cocos2dx_experimental_video.ini' : ('cocos2dx_experimental_video', 'lua_cocos2dx_experimental_video_auto'), \ - 'cocos2dx_experimental.ini' : ('cocos2dx_experimental', 'lua_cocos2dx_experimental_auto'), \ + 'cocos2dx_video.ini' : ('cocos2dx_video', 'lua_cocos2dx_video_auto'), \ 'cocos2dx_controller.ini' : ('cocos2dx_controller', 'lua_cocos2dx_controller_auto'), \ 'cocos2dx_3d.ini': ('cocos2dx_3d', 'lua_cocos2dx_3d_auto'), \ 'cocos2dx_audioengine.ini': ('cocos2dx_audioengine', 'lua_cocos2dx_audioengine_auto'), \ 'cocos2dx_csloader.ini' : ('cocos2dx_csloader', 'lua_cocos2dx_csloader_auto'), \ - 'cocos2dx_experimental_webview.ini' : ('cocos2dx_experimental_webview', 'lua_cocos2dx_experimental_webview_auto'), \ + 'cocos2dx_webview.ini' : ('cocos2dx_webview', 'lua_cocos2dx_webview_auto'), \ 'cocos2dx_physics3d.ini' : ('cocos2dx_physics3d', 'lua_cocos2dx_physics3d_auto'), \ 'cocos2dx_navmesh.ini' : ('cocos2dx_navmesh', 'lua_cocos2dx_navmesh_auto'), \ }