Эх сурвалжийг харах

[cocos2dx] Initial cocos2dx v4 support. Need to fix formatting, ensure v3 and v4 work on all supported platforms, unify headers where possible and minimize code duplication.

badlogic 5 жил өмнө
parent
commit
bf14723dcc
85 өөрчлөгдсөн 4204 нэмэгдсэн , 360 устгасан
  1. 56 12
      spine-cocos2dx/CMakeLists.txt
  2. 4 0
      spine-cocos2dx/example-v4/.cocos-project.json
  3. 164 0
      spine-cocos2dx/example-v4/CMakeLists.txt
  4. 8 0
      spine-cocos2dx/example-v4/proj.android/.gitignore
  5. 2 0
      spine-cocos2dx/example-v4/proj.android/app/.gitignore
  6. 35 0
      spine-cocos2dx/example-v4/proj.android/app/AndroidManifest.xml
  7. 97 0
      spine-cocos2dx/example-v4/proj.android/app/build.gradle
  8. 42 0
      spine-cocos2dx/example-v4/proj.android/app/jni/hellocpp/main.cpp
  9. 37 0
      spine-cocos2dx/example-v4/proj.android/app/proguard-rules.pro
  10. BIN
      spine-cocos2dx/example-v4/proj.android/app/res/mipmap-hdpi/ic_launcher.png
  11. BIN
      spine-cocos2dx/example-v4/proj.android/app/res/mipmap-mdpi/ic_launcher.png
  12. BIN
      spine-cocos2dx/example-v4/proj.android/app/res/mipmap-xhdpi/ic_launcher.png
  13. BIN
      spine-cocos2dx/example-v4/proj.android/app/res/mipmap-xxhdpi/ic_launcher.png
  14. 3 0
      spine-cocos2dx/example-v4/proj.android/app/res/values/strings.xml
  15. 58 0
      spine-cocos2dx/example-v4/proj.android/app/src/org/cocos2dx/cpp/AppActivity.java
  16. 26 0
      spine-cocos2dx/example-v4/proj.android/build.gradle
  17. 42 0
      spine-cocos2dx/example-v4/proj.android/gradle.properties
  18. BIN
      spine-cocos2dx/example-v4/proj.android/gradle/wrapper/gradle-wrapper.jar
  19. 6 0
      spine-cocos2dx/example-v4/proj.android/gradle/wrapper/gradle-wrapper.properties
  20. 164 0
      spine-cocos2dx/example-v4/proj.android/gradlew
  21. 90 0
      spine-cocos2dx/example-v4/proj.android/gradlew.bat
  22. 4 0
      spine-cocos2dx/example-v4/proj.android/settings.gradle
  23. 38 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/AppController.h
  24. 153 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/AppController.mm
  25. 157 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Contents.json
  26. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-20.png
  27. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  28. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  29. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-29.png
  30. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  31. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  32. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-40.png
  33. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  34. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  35. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-50.png
  36. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  37. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-57.png
  38. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  39. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  40. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  41. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-72.png
  42. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  43. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-76.png
  44. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  45. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]
  46. 6 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/Contents.json
  47. 45 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Info.plist
  48. 45 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/LaunchScreen.storyboard
  49. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/ios/LaunchScreenBackground.png
  50. 12 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/Prefix.pch
  51. 35 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/RootViewController.h
  52. 122 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/RootViewController.mm
  53. 15 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/exportoptions.plist
  54. 7 0
      spine-cocos2dx/example-v4/proj.ios_mac/ios/main.m
  55. BIN
      spine-cocos2dx/example-v4/proj.ios_mac/mac/Icon.icns
  56. 36 0
      spine-cocos2dx/example-v4/proj.ios_mac/mac/Info.plist
  57. 11 0
      spine-cocos2dx/example-v4/proj.ios_mac/mac/Prefix.pch
  58. 35 0
      spine-cocos2dx/example-v4/proj.ios_mac/mac/main.cpp
  59. 39 0
      spine-cocos2dx/example-v4/proj.linux/main.cpp
  60. 8 0
      spine-cocos2dx/example-v4/proj.win32/build-cfg.json
  61. 86 0
      spine-cocos2dx/example-v4/proj.win32/game.rc
  62. 42 0
      spine-cocos2dx/example-v4/proj.win32/main.cpp
  63. 37 0
      spine-cocos2dx/example-v4/proj.win32/main.h
  64. BIN
      spine-cocos2dx/example-v4/proj.win32/res/game.ico
  65. 44 0
      spine-cocos2dx/example-v4/proj.win32/resource.h
  66. 3 1
      spine-cocos2dx/example/.gitignore
  67. 102 73
      spine-cocos2dx/example/CMakeLists.txt
  68. 0 1
      spine-cocos2dx/example/Classes/AppDelegate.cpp
  69. 1 1
      spine-cocos2dx/example/proj.ios_mac/ios/Info.plist
  70. 40 28
      spine-cocos2dx/example/proj.ios_mac/spine-cocos2d-x.xcodeproj/project.pbxproj
  71. 1 1
      spine-cocos2dx/src/spine/SkeletonAnimation.h
  72. 49 5
      spine-cocos2dx/src/spine/spine-cocos2dx.cpp
  73. 19 4
      spine-cocos2dx/src/spine/spine-cocos2dx.h
  74. 156 151
      spine-cocos2dx/src/spine/v3/SkeletonBatch.cpp
  75. 79 75
      spine-cocos2dx/src/spine/v3/SkeletonBatch.h
  76. 6 5
      spine-cocos2dx/src/spine/v3/SkeletonRenderer.cpp
  77. 5 1
      spine-cocos2dx/src/spine/v3/SkeletonRenderer.h
  78. 5 1
      spine-cocos2dx/src/spine/v3/SkeletonTwoColorBatch.cpp
  79. 5 1
      spine-cocos2dx/src/spine/v3/SkeletonTwoColorBatch.h
  80. 194 0
      spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp
  81. 84 0
      spine-cocos2dx/src/spine/v4/SkeletonBatch.h
  82. 910 0
      spine-cocos2dx/src/spine/v4/SkeletonRenderer.cpp
  83. 166 0
      spine-cocos2dx/src/spine/v4/SkeletonRenderer.h
  84. 403 0
      spine-cocos2dx/src/spine/v4/SkeletonTwoColorBatch.cpp
  85. 165 0
      spine-cocos2dx/src/spine/v4/SkeletonTwoColorBatch.h

+ 56 - 12
spine-cocos2dx/CMakeLists.txt

@@ -1,17 +1,61 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.6)
+
+project(spine-cocos2dx-example)
+
 set(EXAMPLE_DIR "${CMAKE_CURRENT_LIST_DIR}/example")
 set(EXAMPLE_DIR "${CMAKE_CURRENT_LIST_DIR}/example")
+option(USE_COCOS2DX_V4 "Use cocos2d-x version 4.0+" OFF)
+
+if(USE_COCOS2DX_V4)
+	set(COCOS_FOLDER_NAME "cocos2d-x-4.0")
+	set(COCOS_DOWNLOAD_URL "https://download.cocos.com/Cocos2D-X/${COCOS_FOLDER_NAME}.zip")
+	set(COCOS_SHORT_VERSION "v4")
+	set(EXAMPLE_DIR "${CMAKE_CURRENT_LIST_DIR}/example-v4")
+else()
+	set(COCOS_FOLDER_NAME "cocos2d-x-3.17.2")
+	set(COCOS_DOWNLOAD_URL "http://download.cocos.com/Cocos2D-X/${COCOS_FOLDER_NAME}.zip")
+	set(COCOS_SHORT_VERSION "v3")
+endif()
+
+if((NOT ${COCOS_CURRENT_VERSION} STREQUAL ${COCOS_SHORT_VERSION}) AND (NOT ${COCOS_CURRENT_VERSION} STREQUAL ""))
+	message(STATUS "Target Cocos2d-x version ${COCOS_SHORT_VERSION}, current ${COCOS_CURRENT_VERSION}")
+	message(STATUS "remove current folder ${EXAMPLE_DIR}/cocos2d")
+	file(REMOVE_RECURSE ${EXAMPLE_DIR}/cocos2d ${EXAMPLE_DIR}/cocos2dx.zip)
+endif()
+
 if (NOT EXISTS ${EXAMPLE_DIR}/cocos2d)
 if (NOT EXISTS ${EXAMPLE_DIR}/cocos2d)
-	message("Downloading cocos2dx, this may take some time!")
-	file(DOWNLOAD "https://digitalocean.cocos2d-x.org/Cocos2D-X/cocos2d-x-3.17.2.zip" "${EXAMPLE_DIR}/cocos2dx.zip")
+
+	if(NOT EXISTS ${EXAMPLE_DIR}/cocos2dx.zip)
+		message(STATUS "Downloading cocos2dx ${COCOS_SHORT_VERSION}, this may take some time!")
+		# download cocos2d-x package
+		file(DOWNLOAD ${COCOS_DOWNLOAD_URL} "${EXAMPLE_DIR}/cocos2dx.zip" SHOW_PROGRESS)
+	else()
+		message(STATUS "${EXAMPLE_DIR}/cocos2dx.zip found!")
+	endif()
+
+
+	# untar
+	message(STATUS "untar ${EXAMPLE_DIR}/cocos2dx.zip ...")
 	execute_process(
 	execute_process(
-		COMMAND ${CMAKE_COMMAND} -E tar x  ${EXAMPLE_DIR}/cocos2dx.zip
+		COMMAND ${CMAKE_COMMAND} -E tar x ${EXAMPLE_DIR}/cocos2dx.zip
 		WORKING_DIRECTORY ${EXAMPLE_DIR}
 		WORKING_DIRECTORY ${EXAMPLE_DIR}
-    )
-    execute_process(
-    	COMMAND ${CMAKE_COMMAND} -E rename
-        "${EXAMPLE_DIR}/cocos2d-x-3.17.2" "${EXAMPLE_DIR}/cocos2d"
-    )
-    execute_process(
-    	COMMAND ${CMAKE_COMMAND} -E remove_directory "${EXAMPLE_DIR}/cocos2d/cocos/editor-support/spine"
-    )
+	)
+	# rename folder
+	execute_process(
+		COMMAND ${CMAKE_COMMAND} -E rename
+		"${EXAMPLE_DIR}/${COCOS_FOLDER_NAME}" "${EXAMPLE_DIR}/cocos2d"
+	)
+
+	set(COCOS_CURRENT_VERSION ${COCOS_SHORT_VERSION} CACHE STRING "update current version" FORCE)
+
+	# remove spine source code in cocos2d-x's source tree
+	execute_process(
+		COMMAND ${CMAKE_COMMAND} -E remove_directory "${EXAMPLE_DIR}/cocos2d/cocos/editor-support/spine"
+		COMMAND ${CMAKE_COMMAND} -E make_directory "${EXAMPLE_DIR}/cocos2d/cocos/editor-support/spine"
+	)
+else()
+	message(STATUS "${EXAMPLE_DIR}/cocos2d is already exists, current version ${COCOS_SHORT_VERSION}.")
+endif()
+
+if(USE_COCOS2DX_V4)
+	add_subdirectory("${EXAMPLE_DIR}")
 endif()
 endif()

+ 4 - 0
spine-cocos2dx/example-v4/.cocos-project.json

@@ -0,0 +1,4 @@
+{
+    "engine_version": "cocos2d-x-4.0", 
+    "project_type": "cpp"
+}

+ 164 - 0
spine-cocos2dx/example-v4/CMakeLists.txt

@@ -0,0 +1,164 @@
+#/****************************************************************************
+# Copyright (c) 2013-2014 cocos2d-x.org
+# Copyright (c) 2015-2017 Chukong Technologies Inc.
+#
+# 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.
+# ****************************************************************************/
+
+cmake_minimum_required(VERSION 3.6)
+
+set(APP_NAME spine-cocos2dx-example)
+
+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 spine-cocos2dx-example into root project
+    set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
+    set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)
+
+    include(CocosBuildSet)
+    add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
+endif()
+
+
+# Add spine-cpp library
+file(GLOB SPINE_CPP_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/../../spine-cpp/spine-cpp/include/**/*.h")
+file(GLOB SPINE_CPP_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../../spine-cpp/spine-cpp/src/**/*.cpp")
+add_library(spine-cpp STATIC ${SPINE_CPP_SOURCE} ${SPINE_CPP_HEADER})
+target_include_directories(spine-cpp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../spine-cpp/spine-cpp/include/")
+
+# Add spine-cocos2dx library
+# file(GLOB SPINE_COCOS2DX_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/../src/**/*.h")
+# file(GLOB SPINE_COCOS2DX_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../src/**/*.cpp")
+# add_library(spine-cocos2dx STATIC ${SPINE_COCOS2DX_SOURCE} ${SPINE_COCOS2DX_HEADER})
+
+# record sources, headers, resources...
+set(GAME_RES_FOLDER
+    "${CMAKE_CURRENT_SOURCE_DIR}/../example/Resources"
+    )
+if(APPLE OR WINDOWS)
+    cocos_mark_multi_resources(common_res_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
+endif()
+
+# add cross-platforms source files and header files
+file(GLOB_RECURSE GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example/Classes/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/../src/**/*.cpp")
+file(GLOB_RECURSE GAME_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/../example/Classes/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/../src/**/*.h")
+set(GAME_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../example/Classes" "${CMAKE_CURRENT_SOURCE_DIR}/../src")
+
+if(ANDROID)
+    # change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
+    set(APP_NAME MyGame)
+    list(APPEND GAME_SOURCE
+         proj.android/app/jni/hellocpp/main.cpp
+         )
+elseif(LINUX)
+    list(APPEND GAME_SOURCE
+         proj.linux/main.cpp
+         )
+elseif(WINDOWS)
+    list(APPEND GAME_HEADER
+         proj.win32/main.h
+         proj.win32/resource.h
+         )
+    list(APPEND GAME_SOURCE
+         proj.win32/main.cpp
+         proj.win32/game.rc
+         ${common_res_files}
+         )
+elseif(APPLE)
+    if(IOS)
+        list(APPEND GAME_HEADER
+             proj.ios_mac/ios/AppController.h
+             proj.ios_mac/ios/RootViewController.h
+             )
+        set(APP_UI_RES
+            proj.ios_mac/ios/LaunchScreen.storyboard
+            proj.ios_mac/ios/LaunchScreenBackground.png
+            proj.ios_mac/ios/Images.xcassets
+            )
+        list(APPEND GAME_SOURCE
+             proj.ios_mac/ios/main.m
+             proj.ios_mac/ios/AppController.mm
+             proj.ios_mac/ios/RootViewController.mm
+             proj.ios_mac/ios/Prefix.pch
+             ${APP_UI_RES}
+             )
+    elseif(MACOSX)
+        set(APP_UI_RES
+            proj.ios_mac/mac/Icon.icns
+            proj.ios_mac/mac/Info.plist
+            )
+        list(APPEND GAME_SOURCE
+             proj.ios_mac/mac/main.cpp
+             proj.ios_mac/mac/Prefix.pch
+             ${APP_UI_RES}
+             )
+    endif()
+    list(APPEND GAME_SOURCE ${common_res_files})
+endif()
+
+# mark app complie info and libs info
+set(all_code_files
+    ${GAME_HEADER}
+    ${GAME_SOURCE}
+    )
+if(NOT ANDROID)
+    add_executable(${APP_NAME} ${all_code_files})
+	target_link_libraries(${APP_NAME} spine-cpp)
+else()
+    add_library(${APP_NAME} SHARED ${all_code_files})
+    add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
+    target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
+endif()
+
+target_link_libraries(${APP_NAME} cocos2d)
+target_include_directories(${APP_NAME}
+        PRIVATE ${GAME_INCLUDE}
+        PRIVATE ${COCOS2DX_ROOT_PATH}/cocos/audio/include/
+)
+
+# mark app resources
+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")
+    elseif(IOS)
+        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")
+    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()
+
+if(LINUX OR WINDOWS)
+    cocos_get_resource_path(APP_RES_DIR ${APP_NAME})
+    cocos_copy_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
+endif()

+ 8 - 0
spine-cocos2dx/example-v4/proj.android/.gitignore

@@ -0,0 +1,8 @@
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+/.externalNativeBuild

+ 2 - 0
spine-cocos2dx/example-v4/proj.android/app/.gitignore

@@ -0,0 +1,2 @@
+/build
+/.externalNativeBuild

+ 35 - 0
spine-cocos2dx/example-v4/proj.android/app/AndroidManifest.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.esotericsoftware.spine"
+    android:installLocation="auto">
+
+    <uses-permission android:name="android.permission.INTERNET"/>
+    
+    <uses-feature android:glEsVersion="0x00020000" />
+    
+    <application
+        android:label="@string/app_name"
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher">
+        
+        <!-- Tell Cocos2dxActivity the name of our .so -->
+        <meta-data android:name="android.app.lib_name"
+                   android:value="MyGame" />
+
+        <activity
+            android:name="org.cocos2dx.cpp.AppActivity"
+            android:screenOrientation="landscape"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:label="@string/app_name"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+            android:launchMode="singleTask"
+            android:taskAffinity=""  >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

+ 97 - 0
spine-cocos2dx/example-v4/proj.android/app/build.gradle

@@ -0,0 +1,97 @@
+import org.gradle.internal.os.OperatingSystem
+
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
+
+    defaultConfig {
+        applicationId "com.esotericsoftware.spine"
+        minSdkVersion PROP_MIN_SDK_VERSION
+        targetSdkVersion PROP_TARGET_SDK_VERSION
+        versionCode 1
+        versionName "1.0"
+
+        externalNativeBuild {
+            cmake {
+                targets 'MyGame'
+                arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
+                cppFlags "-frtti -fexceptions -fsigned-char"
+            }
+        }
+
+        ndk {
+            abiFilters = []
+            abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
+        }
+    }
+
+    sourceSets.main {
+        java.srcDir "src"
+        res.srcDir "res"
+        manifest.srcFile "AndroidManifest.xml"
+        assets.srcDir "../../Resources"
+    }
+
+    externalNativeBuild {
+        cmake {
+            path "../../CMakeLists.txt"
+        }
+    }
+
+    signingConfigs {
+
+       release {
+            if (project.hasProperty("RELEASE_STORE_FILE")) {
+                storeFile file(RELEASE_STORE_FILE)
+                storePassword RELEASE_STORE_PASSWORD
+                keyAlias RELEASE_KEY_ALIAS
+                keyPassword RELEASE_KEY_PASSWORD
+            }
+        }
+    }
+
+    buildTypes {
+        release {
+            debuggable false
+            jniDebuggable false
+            renderscriptDebuggable false
+            minifyEnabled true
+            shrinkResources true
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+            if (project.hasProperty("RELEASE_STORE_FILE")) {
+                signingConfig signingConfigs.release
+            }
+        }
+
+        debug {
+            debuggable true
+            jniDebuggable true
+            renderscriptDebuggable true
+        }
+    }
+}
+
+android.applicationVariants.all { variant ->
+    def project_root_folder = "${projectDir}/../.."
+    def dest_assets_folder = "${projectDir}/assets"
+
+    // delete previous files first
+    delete dest_assets_folder
+    def targetName = variant.name.capitalize()
+    def copyTaskName = "copy${targetName}ResourcesToAssets"
+    
+    tasks.register(copyTaskName) {
+        copy {
+            from "${buildDir}/../../../Resources"
+            into "${buildDir}/intermediates/assets/${variant.dirName}"
+            exclude "**/*.gz"
+        }
+    }
+    tasks.getByName("pre${targetName}Build").dependsOn copyTaskName
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    implementation project(':libcocos2dx')
+}

+ 42 - 0
spine-cocos2dx/example-v4/proj.android/app/jni/hellocpp/main.cpp

@@ -0,0 +1,42 @@
+/****************************************************************************
+ 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 <memory>
+
+#include <android/log.h>
+#include <jni.h>
+
+#include "AppDelegate.h"
+
+#define  LOG_TAG    "main"
+#define  LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
+
+namespace {
+std::unique_ptr<AppDelegate> appDelegate;
+}
+
+void cocos_android_app_init(JNIEnv* env) {
+    LOGD("cocos_android_app_init");
+    appDelegate.reset(new AppDelegate());
+}

+ 37 - 0
spine-cocos2dx/example-v4/proj.android/app/proguard-rules.pro

@@ -0,0 +1,37 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Proguard Cocos2d-x for release
+-keep public class org.cocos2dx.** { *; }
+-dontwarn org.cocos2dx.**
+-keep public class com.chukong.** { *; }
+-dontwarn com.chukong.**
+-keep public class com.huawei.android.** { *; }
+-dontwarn com.huawei.android.**
+
+# Proguard Apache HTTP for release
+-keep class org.apache.http.** { *; }
+-dontwarn org.apache.http.**
+
+# Proguard Android Webivew for release. uncomment if you are using a webview in cocos2d-x
+#-keep public class android.net.http.SslError
+#-keep public class android.webkit.WebViewClient
+
+#-dontwarn android.webkit.WebView
+#-dontwarn android.net.http.SslError
+#-dontwarn android.webkit.WebViewClient

BIN
spine-cocos2dx/example-v4/proj.android/app/res/mipmap-hdpi/ic_launcher.png


BIN
spine-cocos2dx/example-v4/proj.android/app/res/mipmap-mdpi/ic_launcher.png


BIN
spine-cocos2dx/example-v4/proj.android/app/res/mipmap-xhdpi/ic_launcher.png


BIN
spine-cocos2dx/example-v4/proj.android/app/res/mipmap-xxhdpi/ic_launcher.png


+ 3 - 0
spine-cocos2dx/example-v4/proj.android/app/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">spine-cocos2dx-example</string>
+</resources>

+ 58 - 0
spine-cocos2dx/example-v4/proj.android/app/src/org/cocos2dx/cpp/AppActivity.java

@@ -0,0 +1,58 @@
+/****************************************************************************
+Copyright (c) 2015-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.
+****************************************************************************/
+package org.cocos2dx.cpp;
+
+import android.os.Bundle;
+import org.cocos2dx.lib.Cocos2dxActivity;
+import android.os.Build;
+import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+
+public class AppActivity extends Cocos2dxActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.setEnableVirtualButton(false);
+        super.onCreate(savedInstanceState);
+        // Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
+        if (!isTaskRoot()) {
+            // Android launched another instance of the root activity into an existing task
+            //  so just quietly finish and go away, dropping the user back into the activity
+            //  at the top of the stack (ie: the last state of this task)
+            // Don't need to finish it again since it's finished in super.onCreate .
+            return;
+        }
+        // Make sure we're running on Pie or higher to change cutout mode
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+            // Enable rendering into the cutout area
+            WindowManager.LayoutParams lp = getWindow().getAttributes();
+            lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
+            getWindow().setAttributes(lp);
+        }
+        // DO OTHER INITIALIZATION BELOW
+        
+    }
+
+}

+ 26 - 0
spine-cocos2dx/example-v4/proj.android/build.gradle

@@ -0,0 +1,26 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        google()
+        jcenter()
+    }
+
+    dependencies {
+        classpath 'com.android.tools.build:gradle:3.1.0'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        google()
+        jcenter()
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 42 - 0
spine-cocos2dx/example-v4/proj.android/gradle.properties

@@ -0,0 +1,42 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
+# Android SDK version that will be used as the compile project
+PROP_COMPILE_SDK_VERSION=28
+
+# Android SDK version that will be used as the earliest version of android this application can run on
+PROP_MIN_SDK_VERSION=16
+
+# Android SDK version that will be used as the latest version of android this application has been tested on
+PROP_TARGET_SDK_VERSION=28
+
+
+# List of CPU Archtexture to build that application with
+# 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=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
+
+android.injected.testOnly=false

BIN
spine-cocos2dx/example-v4/proj.android/gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
spine-cocos2dx/example-v4/proj.android/gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Tue Mar 14 17:40:59 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

+ 164 - 0
spine-cocos2dx/example-v4/proj.android/gradlew

@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 90 - 0
spine-cocos2dx/example-v4/proj.android/gradlew.bat

@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 4 - 0
spine-cocos2dx/example-v4/proj.android/settings.gradle

@@ -0,0 +1,4 @@
+include ':libcocos2dx'
+project(':libcocos2dx').projectDir = new File(settingsDir, '../cocos2d/cocos/platform/android/libcocos2dx')
+include ':spine-cocos2dx-example'
+project(':spine-cocos2dx-example').projectDir = new File(settingsDir, 'app')

+ 38 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/AppController.h

@@ -0,0 +1,38 @@
+/****************************************************************************
+ Copyright (c) 2010-2013 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.
+ ****************************************************************************/
+
+#import <UIKit/UIKit.h>
+
+@class RootViewController;
+
+@interface AppController : NSObject <UIApplicationDelegate> {
+
+}
+
+@property(nonatomic, readonly) RootViewController* viewController;
+
+@end
+

+ 153 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/AppController.mm

@@ -0,0 +1,153 @@
+/****************************************************************************
+ Copyright (c) 2010-2013 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.
+ ****************************************************************************/
+
+#import "AppController.h"
+#import "cocos2d.h"
+#import "AppDelegate.h"
+#import "RootViewController.h"
+
+@implementation AppController
+
+@synthesize window;
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+// cocos2d application instance
+static AppDelegate s_sharedApplication;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+    
+    cocos2d::Application *app = cocos2d::Application::getInstance();
+    
+    // Initialize the GLView attributes
+    app->initGLContextAttrs();
+    cocos2d::GLViewImpl::convertAttrs();
+    
+    // Override point for customization after application launch.
+
+    // Add the view controller's view to the window and display.
+    window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
+
+    // Use RootViewController to manage CCEAGLView
+    _viewController = [[RootViewController alloc]init];
+    _viewController.wantsFullScreenLayout = YES;
+    
+
+    // Set RootViewController to window
+    if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
+    {
+        // warning: addSubView doesn't work on iOS6
+        [window addSubview: _viewController.view];
+    }
+    else
+    {
+        // use this method on ios6
+        [window setRootViewController:_viewController];
+    }
+
+    [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);
+    cocos2d::Director::getInstance()->setOpenGLView(glview);
+    
+    //run the cocos2d-x game scene
+    app->run();
+
+    return YES;
+}
+
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+    /*
+     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+     */
+    // We don't need to call this method any more. It will interrupt user defined game pause&resume logic
+    /* cocos2d::Director::getInstance()->pause(); */
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+    /*
+     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+     */
+    // We don't need to call this method any more. It will interrupt user defined game pause&resume logic
+    /* cocos2d::Director::getInstance()->resume(); */
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+    /*
+     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
+     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
+     */
+    cocos2d::Application::getInstance()->applicationDidEnterBackground();
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+    /*
+     Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
+     */
+    cocos2d::Application::getInstance()->applicationWillEnterForeground();
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+    /*
+     Called when the application is about to terminate.
+     See also applicationDidEnterBackground:.
+     */
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
+    /*
+     Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
+     */
+}
+
+
+#if __has_feature(objc_arc)
+#else
+- (void)dealloc {
+    [window release];
+    [_viewController release];
+    [super dealloc];
+}
+#endif
+
+
+@end

+ 157 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Contents.json

@@ -0,0 +1,157 @@
+{
+  "images" : [
+    {
+      "size" : "20x20",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "20x20",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "3x"
+    },
+    {
+      "size" : "29x29",
+      "idiom" : "iphone",
+      "filename" : "Icon-29.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "29x29",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "29x29",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "3x"
+    },
+    {
+      "size" : "40x40",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "40x40",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "3x"
+    },
+    {
+      "size" : "57x57",
+      "idiom" : "iphone",
+      "filename" : "Icon-57.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "57x57",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "60x60",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "60x60",
+      "idiom" : "iphone",
+      "filename" : "[email protected]",
+      "scale" : "3x"
+    },
+    {
+      "size" : "20x20",
+      "idiom" : "ipad",
+      "filename" : "Icon-20.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "20x20",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "29x29",
+      "idiom" : "ipad",
+      "filename" : "Icon-29.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "29x29",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "40x40",
+      "idiom" : "ipad",
+      "filename" : "Icon-40.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "40x40",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "50x50",
+      "idiom" : "ipad",
+      "filename" : "Icon-50.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "50x50",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "72x72",
+      "idiom" : "ipad",
+      "filename" : "Icon-72.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "72x72",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "76x76",
+      "idiom" : "ipad",
+      "filename" : "Icon-76.png",
+      "scale" : "1x"
+    },
+    {
+      "size" : "76x76",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "size" : "83.5x83.5",
+      "idiom" : "ipad",
+      "filename" : "[email protected]",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ios-marketing",
+      "size" : "1024x1024",
+      "scale" : "1x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-20.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-29.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-40.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-50.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-57.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-72.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/Icon-76.png


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/[email protected]


+ 6 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/Images.xcassets/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 45 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/Info.plist

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleDisplayName</key>
+    <string>${PRODUCT_NAME}</string>
+    <key>CFBundleExecutable</key>
+    <string>${EXECUTABLE_NAME}</string>
+    <key>CFBundleIconFile</key>
+    <string>Icon-57.png</string>
+    <key>CFBundleIdentifier</key>
+    <string>org.cocos2dx.${PRODUCT_NAME}</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundleName</key>
+    <string>${PRODUCT_NAME}</string>
+    <key>CFBundleShortVersionString</key>
+    <string>1.0</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleVersion</key>
+    <string>1</string>
+    <key>LSRequiresIPhoneOS</key>
+    <true/>
+    <key>UIAppFonts</key>
+    <array/>
+    <key>UILaunchStoryboardName</key>
+    <string>LaunchScreen</string>
+    <key>UIPrerenderedIcon</key>
+    <true/>
+    <key>UIStatusBarHidden</key>
+    <true/>
+    <key>UISupportedInterfaceOrientations</key>
+    <array>
+        <string>UIInterfaceOrientationLandscapeRight</string>
+        <string>UIInterfaceOrientationLandscapeLeft</string>
+    </array>
+    <key>NSHumanReadableCopyright</key>
+    <string>Copyright © 2019. All rights reserved.</string>
+</dict>
+</plist>

+ 45 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/LaunchScreen.storyboard

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
+    <device id="retina5_9" orientation="landscape">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment version="1792" identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--View Controller-->
+        <scene sceneID="EHf-IW-A2E">
+            <objects>
+                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="fm7-M6-edp"/>
+                        <viewControllerLayoutGuide type="bottom" id="uRH-d6-mvd"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
+                        <rect key="frame" x="0.0" y="0.0" width="812" height="375"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleAspectFill" insetsLayoutMarginsFromSafeArea="NO" image="LaunchScreenBackground.png" translatesAutoresizingMaskIntoConstraints="NO" id="YCC-wj-Gww" userLabel="Background">
+                                <rect key="frame" x="0.0" y="0.0" width="812" height="375"/>
+                            </imageView>
+                        </subviews>
+                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <constraints>
+                            <constraint firstAttribute="bottom" secondItem="YCC-wj-Gww" secondAttribute="bottom" id="Naz-ae-jWI"/>
+                            <constraint firstAttribute="trailing" secondItem="YCC-wj-Gww" secondAttribute="trailing" id="myj-85-hk9"/>
+                            <constraint firstItem="YCC-wj-Gww" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="qOq-Cg-doS"/>
+                            <constraint firstItem="YCC-wj-Gww" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xL7-Fo-4bl"/>
+                        </constraints>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="50.399999999999999" y="373.15270935960592"/>
+        </scene>
+    </scenes>
+    <resources>
+        <image name="LaunchScreenBackground.png" width="2208" height="1242"/>
+    </resources>
+</document>

BIN
spine-cocos2dx/example-v4/proj.ios_mac/ios/LaunchScreenBackground.png


+ 12 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/Prefix.pch

@@ -0,0 +1,12 @@
+//
+// Prefix header for all source files of the 'iphone' target in the 'iphone' project
+//
+
+#ifdef __OBJC__
+    #import <Foundation/Foundation.h>
+    #import <UIKit/UIKit.h>
+#endif
+
+#ifdef __cplusplus
+	#include "cocos2d.h"
+#endif

+ 35 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/RootViewController.h

@@ -0,0 +1,35 @@
+/****************************************************************************
+ Copyright (c) 2013      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.
+ ****************************************************************************/
+
+#import <UIKit/UIKit.h>
+
+
+@interface RootViewController : UIViewController {
+
+}
+- (BOOL) prefersStatusBarHidden;
+
+@end

+ 122 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/RootViewController.mm

@@ -0,0 +1,122 @@
+/****************************************************************************
+ Copyright (c) 2013      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.
+ ****************************************************************************/
+
+#import "RootViewController.h"
+#import "cocos2d.h"
+#import "platform/ios/CCEAGLView-ios.h"
+
+
+@implementation RootViewController
+
+/*
+ // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
+    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
+        // Custom initialization
+    }
+    return self;
+}
+*/
+
+// Implement loadView to create a view hierarchy programmatically, without using a nib.
+- (void)loadView {
+    // Initialize the CCEAGLView
+    CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [UIScreen mainScreen].bounds
+                                         pixelFormat: (__bridge NSString *)cocos2d::GLViewImpl::_pixelFormat
+                                         depthFormat: cocos2d::GLViewImpl::_depthFormat
+                                  preserveBackbuffer: NO
+                                          sharegroup: nil
+                                       multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO
+                                     numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ];
+    
+    // Enable or disable multiple touches
+    [eaglView setMultipleTouchEnabled:NO];
+    
+    // Set EAGLView as view of RootViewController
+    self.view = eaglView;
+}
+
+// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
+- (void)viewDidLoad {
+    [super viewDidLoad];
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+}
+
+- (void)viewDidDisappear:(BOOL)animated {
+    [super viewDidDisappear:animated];
+}
+
+
+// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
+#ifdef __IPHONE_6_0
+- (NSUInteger) supportedInterfaceOrientations{
+    return UIInterfaceOrientationMaskAllButUpsideDown;
+}
+#endif
+
+- (BOOL) shouldAutorotate {
+    return YES;
+}
+
+- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
+    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
+
+    auto glview = cocos2d::Director::getInstance()->getOpenGLView();
+
+    if (glview)
+    {
+        CCEAGLView *eaglview = (__bridge CCEAGLView *)glview->getEAGLView();
+
+        if (eaglview)
+        {
+            CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);
+            cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height);
+        }
+    }
+}
+
+//fix not hide status on ios7
+- (BOOL)prefersStatusBarHidden {
+    return YES;
+}
+
+// Controls the application's preferred home indicator auto-hiding when this view controller is shown.
+- (BOOL)prefersHomeIndicatorAutoHidden {
+    return YES;
+}
+
+- (void)didReceiveMemoryWarning {
+    // Releases the view if it doesn't have a superview.
+    [super didReceiveMemoryWarning];
+
+    // Release any cached data, images, etc that aren't in use.
+}
+
+
+@end

+ 15 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/exportoptions.plist

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>compileBitcode</key>
+	<false/>
+	<key>method</key>
+	<string>development</string>
+	<key>provisioningProfiles</key>
+	<dict>
+		<key>Bundle Identifier</key>
+		<string>Provision Prifile Name</string>
+	</dict>
+</dict>
+</plist>

+ 7 - 0
spine-cocos2dx/example-v4/proj.ios_mac/ios/main.m

@@ -0,0 +1,7 @@
+#import <UIKit/UIKit.h>
+
+int main(int argc, char *argv[]) {
+    @autoreleasepool {
+        return UIApplicationMain(argc, argv, nil, @"AppController");
+    }
+}

BIN
spine-cocos2dx/example-v4/proj.ios_mac/mac/Icon.icns


+ 36 - 0
spine-cocos2dx/example-v4/proj.ios_mac/mac/Info.plist

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>${EXECUTABLE_NAME}</string>
+	<key>CFBundleIconFile</key>
+	<string>Icon</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.esotericsoftware.spine</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+	<key>LSApplicationCategoryType</key>
+	<string>public.app-category.games</string>
+	<key>LSMinimumSystemVersion</key>
+	<string>${MACOSX_DEPLOYMENT_TARGET}</string>
+	<key>NSHumanReadableCopyright</key>
+	<string>Copyright © 2013. All rights reserved.</string>
+	<key>NSMainNibFile</key>
+	<string>MainMenu</string>
+	<key>NSPrincipalClass</key>
+	<string>NSApplication</string>
+</dict>
+</plist>

+ 11 - 0
spine-cocos2dx/example-v4/proj.ios_mac/mac/Prefix.pch

@@ -0,0 +1,11 @@
+//
+// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project
+//
+
+#ifdef __OBJC__
+	#import <Cocoa/Cocoa.h>
+#endif
+
+#ifdef __cplusplus
+	#include "cocos2d.h"
+#endif

+ 35 - 0
spine-cocos2dx/example-v4/proj.ios_mac/mac/main.cpp

@@ -0,0 +1,35 @@
+/****************************************************************************
+ Copyright (c) 2010 cocos2d-x.org
+ 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 "AppDelegate.h"
+#include "cocos2d.h"
+
+USING_NS_CC;
+
+int main(int argc, char *argv[])
+{
+    AppDelegate app;
+    return Application::getInstance()->run();
+}

+ 39 - 0
spine-cocos2dx/example-v4/proj.linux/main.cpp

@@ -0,0 +1,39 @@
+/****************************************************************************
+ 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 "../Classes/AppDelegate.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string>
+
+USING_NS_CC;
+
+int main(int argc, char **argv)
+{
+    // create the application instance
+    AppDelegate app;
+    return Application::getInstance()->run();
+}

+ 8 - 0
spine-cocos2dx/example-v4/proj.win32/build-cfg.json

@@ -0,0 +1,8 @@
+{
+    "copy_resources": [
+        {
+            "from": "../Resources",
+            "to": ""
+        }
+    ]
+}

+ 86 - 0
spine-cocos2dx/example-v4/proj.win32/game.rc

@@ -0,0 +1,86 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+GLFW_ICON           ICON                    "res\\game.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904B0"
+        BEGIN
+            VALUE "CompanyName", "\0"
+            VALUE "FileDescription", "game Module\0"
+            VALUE "FileVersion", "1, 0, 0, 1\0"
+            VALUE "InternalName", "game\0"
+            VALUE "LegalCopyright", "Copyright \0"
+            VALUE "OriginalFilename", "game.exe\0"
+            VALUE "ProductName", "game Module\0"
+            VALUE "ProductVersion", "1, 0, 0, 1\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x0409, 0x04B0
+    END
+END
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

+ 42 - 0
spine-cocos2dx/example-v4/proj.win32/main.cpp

@@ -0,0 +1,42 @@
+/****************************************************************************
+ 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 "main.h"
+#include "AppDelegate.h"
+#include "cocos2d.h"
+
+USING_NS_CC;
+
+int WINAPI _tWinMain(HINSTANCE hInstance,
+                       HINSTANCE hPrevInstance,
+                       LPTSTR    lpCmdLine,
+                       int       nCmdShow)
+{
+    UNREFERENCED_PARAMETER(hPrevInstance);
+    UNREFERENCED_PARAMETER(lpCmdLine);
+
+    // create the application instance
+    AppDelegate app;
+    return Application::getInstance()->run();
+}

+ 37 - 0
spine-cocos2dx/example-v4/proj.win32/main.h

@@ -0,0 +1,37 @@
+/****************************************************************************
+ 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 __MAIN_H__
+#define __MAIN_H__
+
+#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
+
+// Windows Header Files:
+#include <windows.h>
+#include <tchar.h>
+
+// C RunTime Header Files
+#include "platform/CCStdC.h"
+
+#endif    // __MAIN_H__

BIN
spine-cocos2dx/example-v4/proj.win32/res/game.ico


+ 44 - 0
spine-cocos2dx/example-v4/proj.win32/resource.h

@@ -0,0 +1,44 @@
+/****************************************************************************
+ 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.
+ ****************************************************************************/
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by game.RC
+//
+
+#define IDS_PROJNAME                100
+#define IDR_TESTJS    100
+
+#define ID_FILE_NEW_WINDOW            32771
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE    201
+#define _APS_NEXT_CONTROL_VALUE        1000
+#define _APS_NEXT_SYMED_VALUE        101
+#define _APS_NEXT_COMMAND_VALUE        32775
+#endif
+#endif

+ 3 - 1
spine-cocos2dx/example/.gitignore

@@ -1,5 +1,7 @@
 bin/
 bin/
+build/
+build-linux/
 proj.android/bin/
 proj.android/bin/
 proj.android/assets/
 proj.android/assets/
 proj.android/libs/
 proj.android/libs/
-proj.android/obj/
+proj.android/obj/

+ 102 - 73
spine-cocos2dx/example/CMakeLists.txt

@@ -22,9 +22,9 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 # THE SOFTWARE.
 # ****************************************************************************/
 # ****************************************************************************/
-cmake_policy(SET CMP0017 NEW)
+#cmake_policy(SET CMP0017 NEW)
 
 
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.8)
 
 
 set(APP_NAME MyGame)
 set(APP_NAME MyGame)
 project (${APP_NAME})
 project (${APP_NAME})
@@ -32,6 +32,8 @@ project (${APP_NAME})
 set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)
 set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)
 
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_ROOT}/cmake/Modules/")
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_ROOT}/cmake/Modules/")
+
+include(CocosConfigDefine)
 include(CocosBuildHelpers)
 include(CocosBuildHelpers)
 
 
 # libcocos2d
 # libcocos2d
@@ -39,53 +41,76 @@ set(BUILD_CPP_EMPTY_TEST OFF CACHE BOOL "turn off build cpp-empty-test")
 set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests")
 set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests")
 set(BUILD_LUA_LIBS OFF CACHE BOOL "turn off build lua related targets")
 set(BUILD_LUA_LIBS OFF CACHE BOOL "turn off build lua related targets")
 set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js related targets")
 set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js related targets")
+
+
+set(BUILD_EDITOR_SPINE ON CACHE BOOL "enable spine")
+
+include_directories(
+  ${CMAKE_CURRENT_LIST_DIR}/../../spine-cpp/spine-cpp/include
+  ${CMAKE_CURRENT_LIST_DIR}/../src
+)
+
 add_subdirectory(${COCOS2D_ROOT})
 add_subdirectory(${COCOS2D_ROOT})
 
 
-# Some macro definitions
-if(WINDOWS)
-  if(BUILD_SHARED_LIBS)
-    ADD_DEFINITIONS (-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL)
-  else()
-    ADD_DEFINITIONS (-DCC_STATIC)
-  endif()
+get_target_property(COCOS2D_X_VERSION cocos2d VERSION)
+set(COCOS2DX_ROOT_PATH ${COCOS2D_ROOT})
 
 
-  ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32)
-  set(PLATFORM_FOLDER win32)
-elseif(MACOSX OR APPLE)
-  ADD_DEFINITIONS (-DCC_TARGET_OS_MAC)
-  ADD_DEFINITIONS (-DUSE_FILE32API)
-  set(PLATFORM_FOLDER mac)
-elseif(LINUX)
-  ADD_DEFINITIONS(-DLINUX)
-  set(PLATFORM_FOLDER linux)
-elseif(ANDROID)
-  ADD_DEFINITIONS (-DUSE_FILE32API)
-  set(PLATFORM_FOLDER android)
-else()
-  message( FATAL_ERROR "Unsupported platform, CMake will exit" )
-endif()
+# Some macro definitions
+# if(WINDOWS)
+#   if(BUILD_SHARED_LIBS)
+#     ADD_DEFINITIONS (-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL)
+#   else()
+#     ADD_DEFINITIONS (-DCC_STATIC)
+#   endif()
+
+#   ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32)
+#   set(PLATFORM_FOLDER win32)
+# elseif(MACOSX OR APPLE)
+#   ADD_DEFINITIONS (-DCC_TARGET_OS_MAC)
+#   ADD_DEFINITIONS (-DUSE_FILE32API)
+#   set(PLATFORM_FOLDER mac)
+# elseif(LINUX)
+#   ADD_DEFINITIONS(-DLINUX)
+#   set(PLATFORM_FOLDER linux)
+# elseif(ANDROID)
+#   ADD_DEFINITIONS (-DUSE_FILE32API)
+#   set(PLATFORM_FOLDER android)
+# else()
+#   message( FATAL_ERROR "Unsupported platform, CMake will exit" )
+# endif()
 
 
 
 
 # Compiler options
 # Compiler options
-if(MSVC)
-  ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
-                  -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710
-                  -wd4514 -wd4056 -wd4996 -wd4099)
-else()
-  set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
-  set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
-  if(CLANG)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
-  endif()
-endif(MSVC)
+# if(MSVC)
+#   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+#                   -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710
+#                   -wd4514 -wd4056 -wd4996 -wd4099)
+# else()
+#   set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
+#   set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+#   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
+#   if(CLANG)
+#     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+#   endif()
+# endif(MSVC)
 
 
 
 
 set(PLATFORM_SPECIFIC_SRC)
 set(PLATFORM_SPECIFIC_SRC)
 set(PLATFORM_SPECIFIC_HEADERS)
 set(PLATFORM_SPECIFIC_HEADERS)
+set(cc_common_res)
+
+
+set(GAME_RES_FOLDER  ${CMAKE_CURRENT_SOURCE_DIR}/Resources)
+if(APPLE OR VS)
+  cocos_mark_multi_resources(cc_common_res RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
+endif()
 
 
 if(MACOSX OR APPLE)
 if(MACOSX OR APPLE)
+    set(APP_UI_RES
+    proj.ios_mac/mac/Icon.icns
+    proj.ios_mac/mac/Info.plist
+    )
     set(PLATFORM_SPECIFIC_SRC
     set(PLATFORM_SPECIFIC_SRC
       proj.ios_mac/mac/main.cpp
       proj.ios_mac/mac/main.cpp
     )
     )
@@ -107,30 +132,19 @@ elseif(ANDROID)
     )
     )
 endif()
 endif()
 
 
-include_directories(
-  /usr/local/include/GLFW
-  /usr/include/GLFW
-  ${COCOS2D_ROOT}/cocos
-  ${COCOS2D_ROOT}/cocos/platform
-  ${COCOS2D_ROOT}/cocos/audio/include/
-  Classes
-)
-if ( WIN32 )
-  include_directories(
-  ${COCOS2D_ROOT}/external/glfw3/include/win32
-  ${COCOS2D_ROOT}/external/win32-specific/gles/include/OGLES
-)
-endif( WIN32 )
+
+file(GLOB GAME_CLASSES_SOURCES "Classes/*.cpp")
+file(GLOB GAME_CLASSES_HEADERS "Classes/*.h")
 
 
 set(GAME_SRC
 set(GAME_SRC
-  Classes/AppDelegate.cpp
-  Classes/HelloWorldScene.cpp
+  ${GAME_CLASSES_SOURCES}
   ${PLATFORM_SPECIFIC_SRC}
   ${PLATFORM_SPECIFIC_SRC}
+  ${cc_common_res}
 )
 )
 
 
+
 set(GAME_HEADERS
 set(GAME_HEADERS
-  Classes/AppDelegate.h
-  Classes/HelloWorldScene.h
+  ${GAME_CLASSES_HEADERS}
   ${PLATFORM_SPECIFIC_HEADERS}
   ${PLATFORM_SPECIFIC_HEADERS}
 )
 )
 
 
@@ -143,27 +157,42 @@ else()
     add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS})
     add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS})
 endif()
 endif()
 
 
+target_include_directories(${APP_NAME} PRIVATE Classes)
 target_link_libraries(${APP_NAME} cocos2d)
 target_link_libraries(${APP_NAME} cocos2d)
 
 
-set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
-
-set_target_properties(${APP_NAME} PROPERTIES
-     RUNTIME_OUTPUT_DIRECTORY  "${APP_BIN_DIR}")
-
-if ( WIN32 )
-  #also copying dlls to binary directory for the executable to run
-  pre_build(${APP_NAME}
-    COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
-    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
-    COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt/glew32.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
-	COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt/zlib1.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
-	)
-elseif( ANDROID )
+setup_cocos_app_config(${APP_NAME})
 
 
+if(COMMAND cocos_get_resource_path)
+  cocos_get_resource_path(APP_RES_DIR ${APP_NAME})
 else()
 else()
-  pre_build(${APP_NAME}
-    COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
-    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
-    )
+  set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
+endif()
+
+if(APPLE)
+  set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${API_UI_RES}")
+  if(MACOSX)
+    set_target_properties(${APP_NAME} PROPERTIES
+                          MACOSX_BUNDLE_INFO_PLIST "${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} 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()
+elseif(WINDOWS)
+  cocos_copy_target_dll(${APP_NAME} COPY_TO ${APP_RES_DIR}/..)
+endif()
 
 
+if(LINUX OR WINDOWS)
+  if("${COCOS2D_X_VERSION}" VERSION_LESS "4.0")
+    if(COMMAND cocos_copy_res)
+      cocos_copy_res(COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
+    else()
+      cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
+    endif()
+  else()
+    cocos_copy_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
+  endif()
 endif()
 endif()

+ 0 - 1
spine-cocos2dx/example/Classes/AppDelegate.cpp

@@ -36,7 +36,6 @@
 #include <spine/spine-cocos2dx.h>
 #include <spine/spine-cocos2dx.h>
 #include <spine/Debug.h>
 #include <spine/Debug.h>
 #include "AppMacros.h"
 #include "AppMacros.h"
-#include <spine/SkeletonTwoColorBatch.h>
 
 
 USING_NS_CC;
 USING_NS_CC;
 using namespace std;
 using namespace std;

+ 1 - 1
spine-cocos2dx/example/proj.ios_mac/ios/Info.plist

@@ -55,7 +55,7 @@
 	<key>CFBundlePackageType</key>
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
 	<key>CFBundleShortVersionString</key>
-	<string></string>
+	<string>1</string>
 	<key>CFBundleSignature</key>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<string>????</string>
 	<key>CFBundleVersion</key>
 	<key>CFBundleVersion</key>

+ 40 - 28
spine-cocos2dx/example/proj.ios_mac/spine-cocos2d-x.xcodeproj/project.pbxproj

@@ -170,8 +170,6 @@
 		76798D1E22A95AEF00F77964 /* ConstraintData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76798D1C22A95AB300F77964 /* ConstraintData.cpp */; };
 		76798D1E22A95AEF00F77964 /* ConstraintData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76798D1C22A95AB300F77964 /* ConstraintData.cpp */; };
 		767D80E322B29F22000BD703 /* MixAndMatchExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 767D80E022B29F22000BD703 /* MixAndMatchExample.cpp */; };
 		767D80E322B29F22000BD703 /* MixAndMatchExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 767D80E022B29F22000BD703 /* MixAndMatchExample.cpp */; };
 		767D80E422B2A003000BD703 /* MixAndMatchExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 767D80E022B29F22000BD703 /* MixAndMatchExample.cpp */; };
 		767D80E422B2A003000BD703 /* MixAndMatchExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 767D80E022B29F22000BD703 /* MixAndMatchExample.cpp */; };
-		76A45BDE1E64396800745AA1 /* SkeletonTwoColorBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76A45BDC1E64396800745AA1 /* SkeletonTwoColorBatch.cpp */; };
-		76A45BDF1E64396800745AA1 /* SkeletonTwoColorBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76A45BDC1E64396800745AA1 /* SkeletonTwoColorBatch.cpp */; };
 		76AAA3C01D180F7C00C54FCB /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B31D180F7C00C54FCB /* AppDelegate.cpp */; };
 		76AAA3C01D180F7C00C54FCB /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B31D180F7C00C54FCB /* AppDelegate.cpp */; };
 		76AAA3C11D180F7C00C54FCB /* BatchingExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B61D180F7C00C54FCB /* BatchingExample.cpp */; };
 		76AAA3C11D180F7C00C54FCB /* BatchingExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B61D180F7C00C54FCB /* BatchingExample.cpp */; };
 		76AAA3C21D180F7C00C54FCB /* GoblinsExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B81D180F7C00C54FCB /* GoblinsExample.cpp */; };
 		76AAA3C21D180F7C00C54FCB /* GoblinsExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B81D180F7C00C54FCB /* GoblinsExample.cpp */; };
@@ -179,17 +177,11 @@
 		76AAA3C51D180F7C00C54FCB /* SpineboyExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3BE1D180F7C00C54FCB /* SpineboyExample.cpp */; };
 		76AAA3C51D180F7C00C54FCB /* SpineboyExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3BE1D180F7C00C54FCB /* SpineboyExample.cpp */; };
 		76AAA40C1D18106000C54FCB /* AttachmentVertices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4001D18106000C54FCB /* AttachmentVertices.cpp */; };
 		76AAA40C1D18106000C54FCB /* AttachmentVertices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4001D18106000C54FCB /* AttachmentVertices.cpp */; };
 		76AAA40E1D18106000C54FCB /* SkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */; };
 		76AAA40E1D18106000C54FCB /* SkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */; };
-		76AAA40F1D18106000C54FCB /* SkeletonBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4061D18106000C54FCB /* SkeletonBatch.cpp */; };
-		76AAA4101D18106000C54FCB /* SkeletonRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4081D18106000C54FCB /* SkeletonRenderer.cpp */; };
 		76AAA4111D18106000C54FCB /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */; };
 		76AAA4111D18106000C54FCB /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */; };
 		76AAA4121D18119F00C54FCB /* AttachmentVertices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4001D18106000C54FCB /* AttachmentVertices.cpp */; };
 		76AAA4121D18119F00C54FCB /* AttachmentVertices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4001D18106000C54FCB /* AttachmentVertices.cpp */; };
 		76AAA4131D18119F00C54FCB /* AttachmentVertices.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4011D18106000C54FCB /* AttachmentVertices.h */; };
 		76AAA4131D18119F00C54FCB /* AttachmentVertices.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4011D18106000C54FCB /* AttachmentVertices.h */; };
 		76AAA4161D18119F00C54FCB /* SkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */; };
 		76AAA4161D18119F00C54FCB /* SkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */; };
 		76AAA4171D18119F00C54FCB /* SkeletonAnimation.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4051D18106000C54FCB /* SkeletonAnimation.h */; };
 		76AAA4171D18119F00C54FCB /* SkeletonAnimation.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4051D18106000C54FCB /* SkeletonAnimation.h */; };
-		76AAA4181D18119F00C54FCB /* SkeletonBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4061D18106000C54FCB /* SkeletonBatch.cpp */; };
-		76AAA4191D18119F00C54FCB /* SkeletonBatch.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4071D18106000C54FCB /* SkeletonBatch.h */; };
-		76AAA41A1D18119F00C54FCB /* SkeletonRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4081D18106000C54FCB /* SkeletonRenderer.cpp */; };
-		76AAA41B1D18119F00C54FCB /* SkeletonRenderer.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA4091D18106000C54FCB /* SkeletonRenderer.h */; };
 		76AAA41C1D18119F00C54FCB /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */; };
 		76AAA41C1D18119F00C54FCB /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */; };
 		76AAA41D1D18119F00C54FCB /* spine-cocos2dx.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA40B1D18106000C54FCB /* spine-cocos2dx.h */; };
 		76AAA41D1D18119F00C54FCB /* spine-cocos2dx.h in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA40B1D18106000C54FCB /* spine-cocos2dx.h */; };
 		76AAA43B1D1811B000C54FCB /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B31D180F7C00C54FCB /* AppDelegate.cpp */; };
 		76AAA43B1D1811B000C54FCB /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76AAA3B31D180F7C00C54FCB /* AppDelegate.cpp */; };
@@ -209,6 +201,12 @@
 		76C893B1236715B8009D8DC8 /* IKExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76C893AE236715B8009D8DC8 /* IKExample.cpp */; };
 		76C893B1236715B8009D8DC8 /* IKExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76C893AE236715B8009D8DC8 /* IKExample.cpp */; };
 		76D1BFE02029E35200A0272D /* SkeletonRendererSeparatorExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D1BFDF2029E35200A0272D /* SkeletonRendererSeparatorExample.cpp */; };
 		76D1BFE02029E35200A0272D /* SkeletonRendererSeparatorExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D1BFDF2029E35200A0272D /* SkeletonRendererSeparatorExample.cpp */; };
 		76D1BFE12029E37700A0272D /* SkeletonRendererSeparatorExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D1BFDF2029E35200A0272D /* SkeletonRendererSeparatorExample.cpp */; };
 		76D1BFE12029E37700A0272D /* SkeletonRendererSeparatorExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D1BFDF2029E35200A0272D /* SkeletonRendererSeparatorExample.cpp */; };
+		76D28ACB239FAF0B00FB142D /* SkeletonTwoColorBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D28AC5239FAF0A00FB142D /* SkeletonTwoColorBatch.cpp */; };
+		76D28ACC239FAF0B00FB142D /* SkeletonRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D28AC9239FAF0B00FB142D /* SkeletonRenderer.cpp */; };
+		76D28ACD239FAF0B00FB142D /* SkeletonBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D28ACA239FAF0B00FB142D /* SkeletonBatch.cpp */; };
+		76D28ACE239FAF2C00FB142D /* SkeletonBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D28ACA239FAF0B00FB142D /* SkeletonBatch.cpp */; };
+		76D28ACF239FAF2C00FB142D /* SkeletonRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D28AC9239FAF0B00FB142D /* SkeletonRenderer.cpp */; };
+		76D28AD0239FAF2C00FB142D /* SkeletonTwoColorBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D28AC5239FAF0A00FB142D /* SkeletonTwoColorBatch.cpp */; };
 		76D520E61EB362DD00572471 /* CoinExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D520E41EB362DD00572471 /* CoinExample.cpp */; };
 		76D520E61EB362DD00572471 /* CoinExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D520E41EB362DD00572471 /* CoinExample.cpp */; };
 		76D520E71EB3634600572471 /* CoinExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D520E41EB362DD00572471 /* CoinExample.cpp */; };
 		76D520E71EB3634600572471 /* CoinExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D520E41EB362DD00572471 /* CoinExample.cpp */; };
 		76F5BD551D2BD7D3005917E5 /* TankExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BD531D2BD7D3005917E5 /* TankExample.cpp */; };
 		76F5BD551D2BD7D3005917E5 /* TankExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BD531D2BD7D3005917E5 /* TankExample.cpp */; };
@@ -370,8 +368,6 @@
 		76798D1C22A95AB300F77964 /* ConstraintData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConstraintData.cpp; path = "../../../spine-cpp/spine-cpp/src/spine/ConstraintData.cpp"; sourceTree = "<group>"; };
 		76798D1C22A95AB300F77964 /* ConstraintData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConstraintData.cpp; path = "../../../spine-cpp/spine-cpp/src/spine/ConstraintData.cpp"; sourceTree = "<group>"; };
 		767D80E022B29F22000BD703 /* MixAndMatchExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MixAndMatchExample.cpp; sourceTree = "<group>"; };
 		767D80E022B29F22000BD703 /* MixAndMatchExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MixAndMatchExample.cpp; sourceTree = "<group>"; };
 		767D80E222B29F22000BD703 /* MixAndMatchExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MixAndMatchExample.h; sourceTree = "<group>"; };
 		767D80E222B29F22000BD703 /* MixAndMatchExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MixAndMatchExample.h; sourceTree = "<group>"; };
-		76A45BDC1E64396800745AA1 /* SkeletonTwoColorBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonTwoColorBatch.cpp; path = ../../src/spine/SkeletonTwoColorBatch.cpp; sourceTree = "<group>"; };
-		76A45BDD1E64396800745AA1 /* SkeletonTwoColorBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonTwoColorBatch.h; path = ../../src/spine/SkeletonTwoColorBatch.h; sourceTree = "<group>"; };
 		76AAA3B31D180F7C00C54FCB /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
 		76AAA3B31D180F7C00C54FCB /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
 		76AAA3B41D180F7C00C54FCB /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		76AAA3B41D180F7C00C54FCB /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		76AAA3B51D180F7C00C54FCB /* AppMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppMacros.h; sourceTree = "<group>"; };
 		76AAA3B51D180F7C00C54FCB /* AppMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppMacros.h; sourceTree = "<group>"; };
@@ -387,10 +383,6 @@
 		76AAA4011D18106000C54FCB /* AttachmentVertices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AttachmentVertices.h; path = ../../src/spine/AttachmentVertices.h; sourceTree = "<group>"; };
 		76AAA4011D18106000C54FCB /* AttachmentVertices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AttachmentVertices.h; path = ../../src/spine/AttachmentVertices.h; sourceTree = "<group>"; };
 		76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonAnimation.cpp; path = ../../src/spine/SkeletonAnimation.cpp; sourceTree = "<group>"; };
 		76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonAnimation.cpp; path = ../../src/spine/SkeletonAnimation.cpp; sourceTree = "<group>"; };
 		76AAA4051D18106000C54FCB /* SkeletonAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonAnimation.h; path = ../../src/spine/SkeletonAnimation.h; sourceTree = "<group>"; };
 		76AAA4051D18106000C54FCB /* SkeletonAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonAnimation.h; path = ../../src/spine/SkeletonAnimation.h; sourceTree = "<group>"; };
-		76AAA4061D18106000C54FCB /* SkeletonBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonBatch.cpp; path = ../../src/spine/SkeletonBatch.cpp; sourceTree = "<group>"; };
-		76AAA4071D18106000C54FCB /* SkeletonBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonBatch.h; path = ../../src/spine/SkeletonBatch.h; sourceTree = "<group>"; };
-		76AAA4081D18106000C54FCB /* SkeletonRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonRenderer.cpp; path = ../../src/spine/SkeletonRenderer.cpp; sourceTree = "<group>"; };
-		76AAA4091D18106000C54FCB /* SkeletonRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonRenderer.h; path = ../../src/spine/SkeletonRenderer.h; sourceTree = "<group>"; };
 		76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "spine-cocos2dx.cpp"; path = "../../src/spine/spine-cocos2dx.cpp"; sourceTree = "<group>"; };
 		76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "spine-cocos2dx.cpp"; path = "../../src/spine/spine-cocos2dx.cpp"; sourceTree = "<group>"; };
 		76AAA40B1D18106000C54FCB /* spine-cocos2dx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "spine-cocos2dx.h"; path = "../../src/spine/spine-cocos2dx.h"; sourceTree = "<group>"; };
 		76AAA40B1D18106000C54FCB /* spine-cocos2dx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "spine-cocos2dx.h"; path = "../../src/spine/spine-cocos2dx.h"; sourceTree = "<group>"; };
 		76AAA4521D18132D00C54FCB /* common */ = {isa = PBXFileReference; lastKnownFileType = folder; path = common; sourceTree = "<group>"; };
 		76AAA4521D18132D00C54FCB /* common */ = {isa = PBXFileReference; lastKnownFileType = folder; path = common; sourceTree = "<group>"; };
@@ -398,6 +390,12 @@
 		76C893AF236715B8009D8DC8 /* IKExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IKExample.h; sourceTree = "<group>"; };
 		76C893AF236715B8009D8DC8 /* IKExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IKExample.h; sourceTree = "<group>"; };
 		76D1BFDE2029E35100A0272D /* SkeletonRendererSeparatorExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkeletonRendererSeparatorExample.h; sourceTree = "<group>"; };
 		76D1BFDE2029E35100A0272D /* SkeletonRendererSeparatorExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkeletonRendererSeparatorExample.h; sourceTree = "<group>"; };
 		76D1BFDF2029E35200A0272D /* SkeletonRendererSeparatorExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonRendererSeparatorExample.cpp; sourceTree = "<group>"; };
 		76D1BFDF2029E35200A0272D /* SkeletonRendererSeparatorExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonRendererSeparatorExample.cpp; sourceTree = "<group>"; };
+		76D28AC5239FAF0A00FB142D /* SkeletonTwoColorBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonTwoColorBatch.cpp; path = ../../src/spine/v3/SkeletonTwoColorBatch.cpp; sourceTree = "<group>"; };
+		76D28AC6239FAF0B00FB142D /* SkeletonTwoColorBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonTwoColorBatch.h; path = ../../src/spine/v3/SkeletonTwoColorBatch.h; sourceTree = "<group>"; };
+		76D28AC7239FAF0B00FB142D /* SkeletonRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonRenderer.h; path = ../../src/spine/v3/SkeletonRenderer.h; sourceTree = "<group>"; };
+		76D28AC8239FAF0B00FB142D /* SkeletonBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkeletonBatch.h; path = ../../src/spine/v3/SkeletonBatch.h; sourceTree = "<group>"; };
+		76D28AC9239FAF0B00FB142D /* SkeletonRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonRenderer.cpp; path = ../../src/spine/v3/SkeletonRenderer.cpp; sourceTree = "<group>"; };
+		76D28ACA239FAF0B00FB142D /* SkeletonBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkeletonBatch.cpp; path = ../../src/spine/v3/SkeletonBatch.cpp; sourceTree = "<group>"; };
 		76D520E41EB362DD00572471 /* CoinExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoinExample.cpp; sourceTree = "<group>"; };
 		76D520E41EB362DD00572471 /* CoinExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoinExample.cpp; sourceTree = "<group>"; };
 		76D520E51EB362DD00572471 /* CoinExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoinExample.h; sourceTree = "<group>"; };
 		76D520E51EB362DD00572471 /* CoinExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoinExample.h; sourceTree = "<group>"; };
 		76F5BD531D2BD7D3005917E5 /* TankExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TankExample.cpp; sourceTree = "<group>"; };
 		76F5BD531D2BD7D3005917E5 /* TankExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TankExample.cpp; sourceTree = "<group>"; };
@@ -691,22 +689,38 @@
 		76AAA3FF1D18102C00C54FCB /* spine-cocos2dx */ = {
 		76AAA3FF1D18102C00C54FCB /* spine-cocos2dx */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				76A45BDC1E64396800745AA1 /* SkeletonTwoColorBatch.cpp */,
-				76A45BDD1E64396800745AA1 /* SkeletonTwoColorBatch.h */,
+				76D28AC4239FAEEA00FB142D /* v4 */,
+				76D28AC2239FAED800FB142D /* v3 */,
 				76AAA4001D18106000C54FCB /* AttachmentVertices.cpp */,
 				76AAA4001D18106000C54FCB /* AttachmentVertices.cpp */,
 				76AAA4011D18106000C54FCB /* AttachmentVertices.h */,
 				76AAA4011D18106000C54FCB /* AttachmentVertices.h */,
 				76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */,
 				76AAA4041D18106000C54FCB /* SkeletonAnimation.cpp */,
 				76AAA4051D18106000C54FCB /* SkeletonAnimation.h */,
 				76AAA4051D18106000C54FCB /* SkeletonAnimation.h */,
-				76AAA4061D18106000C54FCB /* SkeletonBatch.cpp */,
-				76AAA4071D18106000C54FCB /* SkeletonBatch.h */,
-				76AAA4081D18106000C54FCB /* SkeletonRenderer.cpp */,
-				76AAA4091D18106000C54FCB /* SkeletonRenderer.h */,
 				76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */,
 				76AAA40A1D18106000C54FCB /* spine-cocos2dx.cpp */,
 				76AAA40B1D18106000C54FCB /* spine-cocos2dx.h */,
 				76AAA40B1D18106000C54FCB /* spine-cocos2dx.h */,
 			);
 			);
 			name = "spine-cocos2dx";
 			name = "spine-cocos2dx";
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
+		76D28AC2239FAED800FB142D /* v3 */ = {
+			isa = PBXGroup;
+			children = (
+				76D28ACA239FAF0B00FB142D /* SkeletonBatch.cpp */,
+				76D28AC8239FAF0B00FB142D /* SkeletonBatch.h */,
+				76D28AC9239FAF0B00FB142D /* SkeletonRenderer.cpp */,
+				76D28AC7239FAF0B00FB142D /* SkeletonRenderer.h */,
+				76D28AC5239FAF0A00FB142D /* SkeletonTwoColorBatch.cpp */,
+				76D28AC6239FAF0B00FB142D /* SkeletonTwoColorBatch.h */,
+			);
+			name = v3;
+			sourceTree = "<group>";
+		};
+		76D28AC4239FAEEA00FB142D /* v4 */ = {
+			isa = PBXGroup;
+			children = (
+			);
+			name = v4;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 /* End PBXGroup section */
 
 
 /* Begin PBXNativeTarget section */
 /* Begin PBXNativeTarget section */
@@ -856,6 +870,7 @@
 				763104D820BC1B5E00927A1E /* AnimationState.cpp in Sources */,
 				763104D820BC1B5E00927A1E /* AnimationState.cpp in Sources */,
 				763104EE20BC1B5E00927A1E /* SkeletonClipping.cpp in Sources */,
 				763104EE20BC1B5E00927A1E /* SkeletonClipping.cpp in Sources */,
 				763104E420BC1B5E00927A1E /* ClippingAttachment.cpp in Sources */,
 				763104E420BC1B5E00927A1E /* ClippingAttachment.cpp in Sources */,
+				76D28ACD239FAF0B00FB142D /* SkeletonBatch.cpp in Sources */,
 				763104C620BC1B5E00927A1E /* CurveTimeline.cpp in Sources */,
 				763104C620BC1B5E00927A1E /* CurveTimeline.cpp in Sources */,
 				763104E120BC1B5E00927A1E /* AttachmentTimeline.cpp in Sources */,
 				763104E120BC1B5E00927A1E /* AttachmentTimeline.cpp in Sources */,
 				763104ED20BC1B5E00927A1E /* EventData.cpp in Sources */,
 				763104ED20BC1B5E00927A1E /* EventData.cpp in Sources */,
@@ -867,7 +882,6 @@
 				76AAA3C11D180F7C00C54FCB /* BatchingExample.cpp in Sources */,
 				76AAA3C11D180F7C00C54FCB /* BatchingExample.cpp in Sources */,
 				763104D520BC1B5E00927A1E /* SkeletonData.cpp in Sources */,
 				763104D520BC1B5E00927A1E /* SkeletonData.cpp in Sources */,
 				763104D620BC1B5E00927A1E /* Extension.cpp in Sources */,
 				763104D620BC1B5E00927A1E /* Extension.cpp in Sources */,
-				76AAA40F1D18106000C54FCB /* SkeletonBatch.cpp in Sources */,
 				763104C920BC1B5E00927A1E /* EventTimeline.cpp in Sources */,
 				763104C920BC1B5E00927A1E /* EventTimeline.cpp in Sources */,
 				763104EB20BC1B5E00927A1E /* VertexEffect.cpp in Sources */,
 				763104EB20BC1B5E00927A1E /* VertexEffect.cpp in Sources */,
 				76AAA3C31D180F7C00C54FCB /* RaptorExample.cpp in Sources */,
 				76AAA3C31D180F7C00C54FCB /* RaptorExample.cpp in Sources */,
@@ -876,6 +890,7 @@
 				763104E720BC1B5E00927A1E /* PathAttachment.cpp in Sources */,
 				763104E720BC1B5E00927A1E /* PathAttachment.cpp in Sources */,
 				763104F820BC1B5E00927A1E /* Json.cpp in Sources */,
 				763104F820BC1B5E00927A1E /* Json.cpp in Sources */,
 				763104F620BC1B5E00927A1E /* SlotData.cpp in Sources */,
 				763104F620BC1B5E00927A1E /* SlotData.cpp in Sources */,
+				76D28ACB239FAF0B00FB142D /* SkeletonTwoColorBatch.cpp in Sources */,
 				763104DF20BC1B5E00927A1E /* AttachmentLoader.cpp in Sources */,
 				763104DF20BC1B5E00927A1E /* AttachmentLoader.cpp in Sources */,
 				76AAA3C01D180F7C00C54FCB /* AppDelegate.cpp in Sources */,
 				76AAA3C01D180F7C00C54FCB /* AppDelegate.cpp in Sources */,
 				763104C420BC1B5E00927A1E /* PathConstraint.cpp in Sources */,
 				763104C420BC1B5E00927A1E /* PathConstraint.cpp in Sources */,
@@ -910,17 +925,16 @@
 				763104FB20BC1B5E00927A1E /* DeformTimeline.cpp in Sources */,
 				763104FB20BC1B5E00927A1E /* DeformTimeline.cpp in Sources */,
 				503AE10217EB989F00D1A890 /* RootViewController.mm in Sources */,
 				503AE10217EB989F00D1A890 /* RootViewController.mm in Sources */,
 				503AE10117EB989F00D1A890 /* main.m in Sources */,
 				503AE10117EB989F00D1A890 /* main.m in Sources */,
-				76A45BDE1E64396800745AA1 /* SkeletonTwoColorBatch.cpp in Sources */,
 				763104CC20BC1B5E00927A1E /* RTTI.cpp in Sources */,
 				763104CC20BC1B5E00927A1E /* RTTI.cpp in Sources */,
 				763104F020BC1B5E00927A1E /* Timeline.cpp in Sources */,
 				763104F020BC1B5E00927A1E /* Timeline.cpp in Sources */,
 				763104FE20BC1B5E00927A1E /* ShearTimeline.cpp in Sources */,
 				763104FE20BC1B5E00927A1E /* ShearTimeline.cpp in Sources */,
-				76AAA4101D18106000C54FCB /* SkeletonRenderer.cpp in Sources */,
 				763104F120BC1B5E00927A1E /* AtlasAttachmentLoader.cpp in Sources */,
 				763104F120BC1B5E00927A1E /* AtlasAttachmentLoader.cpp in Sources */,
 				763104EC20BC1B5E00927A1E /* AnimationStateData.cpp in Sources */,
 				763104EC20BC1B5E00927A1E /* AnimationStateData.cpp in Sources */,
 				763104CE20BC1B5E00927A1E /* PointAttachment.cpp in Sources */,
 				763104CE20BC1B5E00927A1E /* PointAttachment.cpp in Sources */,
 				763104EA20BC1B5E00927A1E /* IkConstraintData.cpp in Sources */,
 				763104EA20BC1B5E00927A1E /* IkConstraintData.cpp in Sources */,
 				763104F420BC1B5E00927A1E /* Attachment.cpp in Sources */,
 				763104F420BC1B5E00927A1E /* Attachment.cpp in Sources */,
 				763104E620BC1B5E00927A1E /* TransformConstraintData.cpp in Sources */,
 				763104E620BC1B5E00927A1E /* TransformConstraintData.cpp in Sources */,
+				76D28ACC239FAF0B00FB142D /* SkeletonRenderer.cpp in Sources */,
 				763104D720BC1B5E00927A1E /* SpineObject.cpp in Sources */,
 				763104D720BC1B5E00927A1E /* SpineObject.cpp in Sources */,
 				763104CA20BC1B5E00927A1E /* PathConstraintSpacingTimeline.cpp in Sources */,
 				763104CA20BC1B5E00927A1E /* PathConstraintSpacingTimeline.cpp in Sources */,
 				76D520E61EB362DD00572471 /* CoinExample.cpp in Sources */,
 				76D520E61EB362DD00572471 /* CoinExample.cpp in Sources */,
@@ -934,6 +948,9 @@
 			isa = PBXSourcesBuildPhase;
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
+				76D28ACE239FAF2C00FB142D /* SkeletonBatch.cpp in Sources */,
+				76D28ACF239FAF2C00FB142D /* SkeletonRenderer.cpp in Sources */,
+				76D28AD0239FAF2C00FB142D /* SkeletonTwoColorBatch.cpp in Sources */,
 				767D80E422B2A003000BD703 /* MixAndMatchExample.cpp in Sources */,
 				767D80E422B2A003000BD703 /* MixAndMatchExample.cpp in Sources */,
 				76798D1E22A95AEF00F77964 /* ConstraintData.cpp in Sources */,
 				76798D1E22A95AEF00F77964 /* ConstraintData.cpp in Sources */,
 				7631059E20BC1B9700927A1E /* Animation.cpp in Sources */,
 				7631059E20BC1B9700927A1E /* Animation.cpp in Sources */,
@@ -1014,13 +1031,8 @@
 				76AAA4471D1811B000C54FCB /* SpineboyExample.h in Sources */,
 				76AAA4471D1811B000C54FCB /* SpineboyExample.h in Sources */,
 				76AAA4121D18119F00C54FCB /* AttachmentVertices.cpp in Sources */,
 				76AAA4121D18119F00C54FCB /* AttachmentVertices.cpp in Sources */,
 				76AAA4131D18119F00C54FCB /* AttachmentVertices.h in Sources */,
 				76AAA4131D18119F00C54FCB /* AttachmentVertices.h in Sources */,
-				76A45BDF1E64396800745AA1 /* SkeletonTwoColorBatch.cpp in Sources */,
 				76AAA4161D18119F00C54FCB /* SkeletonAnimation.cpp in Sources */,
 				76AAA4161D18119F00C54FCB /* SkeletonAnimation.cpp in Sources */,
 				76AAA4171D18119F00C54FCB /* SkeletonAnimation.h in Sources */,
 				76AAA4171D18119F00C54FCB /* SkeletonAnimation.h in Sources */,
-				76AAA4181D18119F00C54FCB /* SkeletonBatch.cpp in Sources */,
-				76AAA4191D18119F00C54FCB /* SkeletonBatch.h in Sources */,
-				76AAA41A1D18119F00C54FCB /* SkeletonRenderer.cpp in Sources */,
-				76AAA41B1D18119F00C54FCB /* SkeletonRenderer.h in Sources */,
 				76AAA41C1D18119F00C54FCB /* spine-cocos2dx.cpp in Sources */,
 				76AAA41C1D18119F00C54FCB /* spine-cocos2dx.cpp in Sources */,
 				76AAA41D1D18119F00C54FCB /* spine-cocos2dx.h in Sources */,
 				76AAA41D1D18119F00C54FCB /* spine-cocos2dx.h in Sources */,
 				503AE10517EB98FF00D1A890 /* main.cpp in Sources */,
 				503AE10517EB98FF00D1A890 /* main.cpp in Sources */,

+ 1 - 1
spine-cocos2dx/src/spine/SkeletonAnimation.h

@@ -31,7 +31,7 @@
 #define SPINE_SKELETONANIMATION_H_
 #define SPINE_SKELETONANIMATION_H_
 
 
 #include <spine/spine.h>
 #include <spine/spine.h>
-#include <spine/SkeletonRenderer.h>
+#include <spine/spine-cocos2dx.h>
 #include "cocos2d.h"
 #include "cocos2d.h"
 
 
 namespace spine {
 namespace spine {

+ 49 - 5
spine-cocos2dx/src/spine/spine-cocos2dx.cpp

@@ -66,6 +66,8 @@ static void setAttachmentVertices(MeshAttachment* attachment) {
 Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas* atlas): AtlasAttachmentLoader(atlas) {
 Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas* atlas): AtlasAttachmentLoader(atlas) {
 }
 }
 
 
+Cocos2dAtlasAttachmentLoader::~Cocos2dAtlasAttachmentLoader() { }
+
 void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
 void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
 	if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
 	if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
 		setAttachmentVertices((RegionAttachment*)attachment);
 		setAttachmentVertices((RegionAttachment*)attachment);
@@ -74,6 +76,36 @@ void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
 	}
 	}
 }
 }
 
 
+#if COCOS2D_VERSION >= 0x0040000
+
+backend::SamplerAddressMode wrap (TextureWrap wrap) {
+	return wrap ==  TextureWrap_ClampToEdge ? backend::SamplerAddressMode::CLAMP_TO_EDGE : backend::SamplerAddressMode::REPEAT;
+}
+
+backend::SamplerFilter filter (TextureFilter filter) {
+	switch (filter) {
+	case TextureFilter_Unknown:
+		break;
+	case TextureFilter_Nearest:
+		return backend::SamplerFilter::NEAREST;
+	case TextureFilter_Linear:
+		return backend::SamplerFilter::LINEAR;
+	case TextureFilter_MipMap:
+		return backend::SamplerFilter::LINEAR;
+	case TextureFilter_MipMapNearestNearest:
+		return backend::SamplerFilter::NEAREST;
+	case TextureFilter_MipMapLinearNearest:
+        return backend::SamplerFilter::NEAREST;
+	case TextureFilter_MipMapNearestLinear:
+        return backend::SamplerFilter::LINEAR;
+	case TextureFilter_MipMapLinearLinear:
+        return backend::SamplerFilter::LINEAR;
+	}
+	return backend::SamplerFilter::LINEAR;
+}
+
+#else
+
 GLuint wrap (TextureWrap wrap) {
 GLuint wrap (TextureWrap wrap) {
 	return wrap ==  TextureWrap_ClampToEdge ? GL_CLAMP_TO_EDGE : GL_REPEAT;
 	return wrap ==  TextureWrap_ClampToEdge ? GL_CLAMP_TO_EDGE : GL_REPEAT;
 }
 }
@@ -100,14 +132,23 @@ GLuint filter (TextureFilter filter) {
 	return GL_LINEAR;
 	return GL_LINEAR;
 }
 }
 
 
+#endif
+
+Cocos2dTextureLoader::Cocos2dTextureLoader() : TextureLoader() { }
+Cocos2dTextureLoader::~Cocos2dTextureLoader() { }
+
 void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
 void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
 	Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path.buffer());
 	Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path.buffer());
 	CCASSERT(texture != nullptr, "Invalid image");
 	CCASSERT(texture != nullptr, "Invalid image");
-	if (texture)
-	{
+	if (texture) {
 		texture->retain();
 		texture->retain();
-		Texture2D::TexParams textureParams = { filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap) };
+#if COCOS2D_VERSION >= 0x0040000
+		Texture2D::TexParams textureParams(filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap));
+#else
+		Texture2D::TexParams textureParams = {filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap)};
+#endif
 		texture->setTexParameters(textureParams);
 		texture->setTexParameters(textureParams);
+
 		page.setRendererObject(texture);
 		page.setRendererObject(texture);
 		page.width = texture->getPixelsWide();
 		page.width = texture->getPixelsWide();
 		page.height = texture->getPixelsHigh();
 		page.height = texture->getPixelsHigh();
@@ -115,13 +156,16 @@ void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
 }
 }
 
 
 void Cocos2dTextureLoader::unload(void* texture) {
 void Cocos2dTextureLoader::unload(void* texture) {
-	if (texture)
-	{
+	if (texture) {
 		((Texture2D*)texture)->release();
 		((Texture2D*)texture)->release();
 	}
 	}
 }
 }
 
 
 
 
+Cocos2dExtension::Cocos2dExtension() : DefaultSpineExtension() { }
+
+Cocos2dExtension::~Cocos2dExtension() { }
+
 char *Cocos2dExtension::_readFile(const spine::String &path, int *length) {
 char *Cocos2dExtension::_readFile(const spine::String &path, int *length) {
 	Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path.buffer()));
 	Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path.buffer()));
 	if (data.isNull()) return nullptr;
 	if (data.isNull()) return nullptr;

+ 19 - 4
spine-cocos2dx/src/spine/spine-cocos2dx.h

@@ -33,20 +33,32 @@
 #include <spine/spine.h>
 #include <spine/spine.h>
 #include "cocos2d.h"
 #include "cocos2d.h"
 
 
-#include <spine/SkeletonRenderer.h>
+#if COCOS2D_VERSION < 0x00040000
+#include <spine/v3/SkeletonRenderer.h>
+#include <spine/v3/SkeletonBatch.h>
+#include <spine/v3/SkeletonTwoColorBatch.h>
+#else
+#include <spine/v4/SkeletonRenderer.h>
+#include <spine/v4/SkeletonBatch.h>
+#include <spine/v4/SkeletonTwoColorBatch.h>
+#endif
+
 #include <spine/SkeletonAnimation.h>
 #include <spine/SkeletonAnimation.h>
-#include <spine/SkeletonBatch.h>
 
 
 namespace spine {
 namespace spine {
 	class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
 	class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
 	public:
 	public:
 		Cocos2dAtlasAttachmentLoader(Atlas* atlas);
 		Cocos2dAtlasAttachmentLoader(Atlas* atlas);
+		virtual ~Cocos2dAtlasAttachmentLoader();
 		virtual void configureAttachment(Attachment* attachment);
 		virtual void configureAttachment(Attachment* attachment);
 	};
 	};
 
 
 	class Cocos2dTextureLoader: public TextureLoader {
 	class Cocos2dTextureLoader: public TextureLoader {
 	public:
 	public:
-
+		Cocos2dTextureLoader();
+		
+		virtual ~Cocos2dTextureLoader();
+		
 		virtual void load(AtlasPage& page, const String& path);
 		virtual void load(AtlasPage& page, const String& path);
 
 
 		virtual void unload(void* texture);
 		virtual void unload(void* texture);
@@ -54,7 +66,10 @@ namespace spine {
 
 
 	class Cocos2dExtension: public DefaultSpineExtension {
 	class Cocos2dExtension: public DefaultSpineExtension {
 	public:
 	public:
-
+		Cocos2dExtension();
+		
+		virtual ~Cocos2dExtension();
+		
 	protected:
 	protected:
 		virtual char *_readFile(const String &path, int *length);
 		virtual char *_readFile(const String &path, int *length);
 	};
 	};

+ 156 - 151
spine-cocos2dx/src/spine/SkeletonBatch.cpp → spine-cocos2dx/src/spine/v3/SkeletonBatch.cpp

@@ -1,151 +1,156 @@
-/******************************************************************************
- * Spine Runtimes License Agreement
- * Last updated May 1, 2019. Replaces all prior versions.
- *
- * Copyright (c) 2013-2019, Esoteric Software LLC
- *
- * Integration of the Spine Runtimes into software or otherwise creating
- * derivative works of the Spine Runtimes is permitted under the terms and
- * conditions of Section 2 of the Spine Editor License Agreement:
- * http://esotericsoftware.com/spine-editor-license
- *
- * Otherwise, it is permitted to integrate the Spine Runtimes into software
- * or otherwise create derivative works of the Spine Runtimes (collectively,
- * "Products"), provided that each user of the Products must obtain their own
- * Spine Editor license and redistribution of the Products in any form must
- * include this license and copyright notice.
- *
- * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
- * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************************************************/
-
-#include <spine/SkeletonBatch.h>
-#include <spine/Extension.h>
-#include <algorithm>
-
-USING_NS_CC;
-#define EVENT_AFTER_DRAW_RESET_POSITION "director_after_draw"
-using std::max;
-#define INITIAL_SIZE (10000)
-
-namespace spine {
-
-static SkeletonBatch* instance = nullptr;
-
-SkeletonBatch* SkeletonBatch::getInstance () {
-	if (!instance) instance = new SkeletonBatch();
-	return instance;
-}
-
-void SkeletonBatch::destroyInstance () {
-	if (instance) {
-		delete instance;
-		instance = nullptr;
-	}
-}
-
-SkeletonBatch::SkeletonBatch () {
-	for (unsigned int i = 0; i < INITIAL_SIZE; i++) {
-		_commandsPool.push_back(new TrianglesCommand());
-	}
-
-	reset ();
-
-	// callback after drawing is finished so we can clear out the batch state
-	// for the next frame
-	Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom* eventCustom){
-		this->update(0);
-	});;
-}
-
-SkeletonBatch::~SkeletonBatch () {
-	Director::getInstance()->getEventDispatcher()->removeCustomEventListeners(EVENT_AFTER_DRAW_RESET_POSITION);
-
-	for (unsigned int i = 0; i < _commandsPool.size(); i++) {
-		delete _commandsPool[i];
-		_commandsPool[i] = nullptr;
-	}
-}
-
-void SkeletonBatch::update (float delta) {
-	reset();
-}
-
-cocos2d::V3F_C4B_T2F* SkeletonBatch::allocateVertices(uint32_t numVertices) {
-	if (_vertices.size() - _numVertices < numVertices) {
-		cocos2d::V3F_C4B_T2F* oldData = _vertices.data();
-		_vertices.resize((_vertices.size() + numVertices) * 2 + 1);
-		cocos2d::V3F_C4B_T2F* newData = _vertices.data();
-		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
-			TrianglesCommand* command = _commandsPool[i];
-			cocos2d::TrianglesCommand::Triangles& triangles = (cocos2d::TrianglesCommand::Triangles&)command->getTriangles();
-			triangles.verts = newData + (triangles.verts - oldData);
-		}
-	}
-
-	cocos2d::V3F_C4B_T2F* vertices = _vertices.data() + _numVertices;
-	_numVertices += numVertices;
-	return vertices;
-}
-
-void SkeletonBatch::deallocateVertices(uint32_t numVertices) {
-	_numVertices -= numVertices;
-}
-
-
-unsigned short* SkeletonBatch::allocateIndices(uint32_t numIndices) {
-	if (_indices.getCapacity() - _indices.size() < numIndices) {
-		unsigned short* oldData = _indices.buffer();
-		int oldSize = _indices.size();
-		_indices.ensureCapacity(_indices.size() + numIndices);
-		unsigned short* newData = _indices.buffer();
-		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
-			TrianglesCommand* command = _commandsPool[i];
-			cocos2d::TrianglesCommand::Triangles& triangles = (cocos2d::TrianglesCommand::Triangles&)command->getTriangles();
-			if (triangles.indices >= oldData && triangles.indices < oldData + oldSize) {
-				triangles.indices = newData + (triangles.indices - oldData);
-			}
-		}
-	}
-
-	unsigned short* indices = _indices.buffer() + _indices.size();
-	_indices.setSize(_indices.size() + numIndices, 0);
-	return indices;
-}
-
-void SkeletonBatch::deallocateIndices(uint32_t numIndices) {
-	_indices.setSize(_indices.size() - numIndices, 0);
-}
-
-
-cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::GLProgramState* glProgramState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags) {
-	TrianglesCommand* command = nextFreeCommand();
-	command->init(globalOrder, texture, glProgramState, blendType, triangles, mv, flags);
-	renderer->addCommand(command);
-	return command;
-}
-
-void SkeletonBatch::reset() {
-	_nextFreeCommand = 0;
-	_numVertices = 0;
-	_indices.setSize(0, 0);
-}
-
-cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() {
-	if (_commandsPool.size() <= _nextFreeCommand) {
-		unsigned int newSize = _commandsPool.size() * 2 + 1;
-		for (int i = _commandsPool.size(); i < newSize; i++) {
-			_commandsPool.push_back(new TrianglesCommand());
-		}
-	}
-	return _commandsPool[_nextFreeCommand++];
-}
-}
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#include <spine/spine-cocos2dx.h>
+#if COCOS2D_VERSION < 0x00040000
+
+#include <spine/Extension.h>
+#include <algorithm>
+
+USING_NS_CC;
+#define EVENT_AFTER_DRAW_RESET_POSITION "director_after_draw"
+using std::max;
+#define INITIAL_SIZE (10000)
+
+namespace spine {
+
+static SkeletonBatch* instance = nullptr;
+
+SkeletonBatch* SkeletonBatch::getInstance () {
+	if (!instance) instance = new SkeletonBatch();
+	return instance;
+}
+
+void SkeletonBatch::destroyInstance () {
+	if (instance) {
+		delete instance;
+		instance = nullptr;
+	}
+}
+
+SkeletonBatch::SkeletonBatch () {
+	for (unsigned int i = 0; i < INITIAL_SIZE; i++) {
+		_commandsPool.push_back(new TrianglesCommand());
+	}
+
+	reset ();
+
+	// callback after drawing is finished so we can clear out the batch state
+	// for the next frame
+	Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom* eventCustom){
+		this->update(0);
+	});;
+}
+
+SkeletonBatch::~SkeletonBatch () {
+	Director::getInstance()->getEventDispatcher()->removeCustomEventListeners(EVENT_AFTER_DRAW_RESET_POSITION);
+
+	for (unsigned int i = 0; i < _commandsPool.size(); i++) {
+		delete _commandsPool[i];
+		_commandsPool[i] = nullptr;
+	}
+}
+
+void SkeletonBatch::update (float delta) {
+	reset();
+}
+
+cocos2d::V3F_C4B_T2F* SkeletonBatch::allocateVertices(uint32_t numVertices) {
+	if (_vertices.size() - _numVertices < numVertices) {
+		cocos2d::V3F_C4B_T2F* oldData = _vertices.data();
+		_vertices.resize((_vertices.size() + numVertices) * 2 + 1);
+		cocos2d::V3F_C4B_T2F* newData = _vertices.data();
+		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
+			TrianglesCommand* command = _commandsPool[i];
+			cocos2d::TrianglesCommand::Triangles& triangles = (cocos2d::TrianglesCommand::Triangles&)command->getTriangles();
+			triangles.verts = newData + (triangles.verts - oldData);
+		}
+	}
+
+	cocos2d::V3F_C4B_T2F* vertices = _vertices.data() + _numVertices;
+	_numVertices += numVertices;
+	return vertices;
+}
+
+void SkeletonBatch::deallocateVertices(uint32_t numVertices) {
+	_numVertices -= numVertices;
+}
+
+
+unsigned short* SkeletonBatch::allocateIndices(uint32_t numIndices) {
+	if (_indices.getCapacity() - _indices.size() < numIndices) {
+		unsigned short* oldData = _indices.buffer();
+		int oldSize = _indices.size();
+		_indices.ensureCapacity(_indices.size() + numIndices);
+		unsigned short* newData = _indices.buffer();
+		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
+			TrianglesCommand* command = _commandsPool[i];
+			cocos2d::TrianglesCommand::Triangles& triangles = (cocos2d::TrianglesCommand::Triangles&)command->getTriangles();
+			if (triangles.indices >= oldData && triangles.indices < oldData + oldSize) {
+				triangles.indices = newData + (triangles.indices - oldData);
+			}
+		}
+	}
+
+	unsigned short* indices = _indices.buffer() + _indices.size();
+	_indices.setSize(_indices.size() + numIndices, 0);
+	return indices;
+}
+
+void SkeletonBatch::deallocateIndices(uint32_t numIndices) {
+	_indices.setSize(_indices.size() - numIndices, 0);
+}
+
+
+cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::GLProgramState* glProgramState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags) {
+	TrianglesCommand* command = nextFreeCommand();
+	command->init(globalOrder, texture, glProgramState, blendType, triangles, mv, flags);
+	renderer->addCommand(command);
+	return command;
+}
+
+void SkeletonBatch::reset() {
+	_nextFreeCommand = 0;
+	_numVertices = 0;
+	_indices.setSize(0, 0);
+}
+
+cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() {
+	if (_commandsPool.size() <= _nextFreeCommand) {
+		unsigned int newSize = _commandsPool.size() * 2 + 1;
+		for (int i = _commandsPool.size(); i < newSize; i++) {
+			_commandsPool.push_back(new TrianglesCommand());
+		}
+	}
+	return _commandsPool[_nextFreeCommand++];
+}
+}
+
+#endif
+

+ 79 - 75
spine-cocos2dx/src/spine/SkeletonBatch.h → spine-cocos2dx/src/spine/v3/SkeletonBatch.h

@@ -1,75 +1,79 @@
-/******************************************************************************
- * Spine Runtimes License Agreement
- * Last updated May 1, 2019. Replaces all prior versions.
- *
- * Copyright (c) 2013-2019, Esoteric Software LLC
- *
- * Integration of the Spine Runtimes into software or otherwise creating
- * derivative works of the Spine Runtimes is permitted under the terms and
- * conditions of Section 2 of the Spine Editor License Agreement:
- * http://esotericsoftware.com/spine-editor-license
- *
- * Otherwise, it is permitted to integrate the Spine Runtimes into software
- * or otherwise create derivative works of the Spine Runtimes (collectively,
- * "Products"), provided that each user of the Products must obtain their own
- * Spine Editor license and redistribution of the Products in any form must
- * include this license and copyright notice.
- *
- * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
- * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************************************************/
-
-#ifndef SPINE_SKELETONBATCH_H_
-#define SPINE_SKELETONBATCH_H_
-
-#include <spine/spine.h>
-#include "cocos2d.h"
-#include <vector>
-
-namespace spine {
-
-	class SkeletonBatch {
-	public:
-		static SkeletonBatch* getInstance ();
-
-		static void destroyInstance ();
-
-		void update (float delta);
-
-		cocos2d::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
-		void deallocateVertices(uint32_t numVertices);
-		unsigned short* allocateIndices(uint32_t numIndices);
-		void deallocateIndices(uint32_t numVertices);
-		cocos2d::TrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::GLProgramState* glProgramState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
-
-	protected:
-		SkeletonBatch ();
-		virtual ~SkeletonBatch ();
-
-		void reset ();
-
-		cocos2d::TrianglesCommand* nextFreeCommand ();
-
-		// pool of commands
-		std::vector<cocos2d::TrianglesCommand*> _commandsPool;
-		uint32_t _nextFreeCommand;
-
-		// pool of vertices
-		std::vector<cocos2d::V3F_C4B_T2F> _vertices;
-		uint32_t _numVertices;
-
-		// pool of indices
-		Vector<unsigned short> _indices;
-	};
-
-}
-
-#endif // SPINE_SKELETONBATCH_H_
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#ifndef SPINE_SKELETONBATCH_H_
+#define SPINE_SKELETONBATCH_H_
+
+#include "cocos2d.h"
+#if COCOS2D_VERSION < 0x00040000
+
+#include <spine/spine.h>
+#include <vector>
+
+namespace spine {
+
+	class SkeletonBatch {
+	public:
+		static SkeletonBatch* getInstance ();
+
+		static void destroyInstance ();
+
+		void update (float delta);
+
+		cocos2d::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
+		void deallocateVertices(uint32_t numVertices);
+		unsigned short* allocateIndices(uint32_t numIndices);
+		void deallocateIndices(uint32_t numVertices);
+		cocos2d::TrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::GLProgramState* glProgramState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
+
+	protected:
+		SkeletonBatch ();
+		virtual ~SkeletonBatch ();
+
+		void reset ();
+
+		cocos2d::TrianglesCommand* nextFreeCommand ();
+
+		// pool of commands
+		std::vector<cocos2d::TrianglesCommand*> _commandsPool;
+		uint32_t _nextFreeCommand;
+
+		// pool of vertices
+		std::vector<cocos2d::V3F_C4B_T2F> _vertices;
+		uint32_t _numVertices;
+
+		// pool of indices
+		Vector<unsigned short> _indices;
+	};
+
+}
+
+#endif
+
+#endif // SPINE_SKELETONBATCH_H_

+ 6 - 5
spine-cocos2dx/src/spine/SkeletonRenderer.cpp → spine-cocos2dx/src/spine/v3/SkeletonRenderer.cpp

@@ -28,10 +28,9 @@
  *****************************************************************************/
  *****************************************************************************/
 
 
 #include <spine/spine-cocos2dx.h>
 #include <spine/spine-cocos2dx.h>
-#include <spine/SkeletonRenderer.h>
+#if COCOS2D_VERSION < 0x00040000
+
 #include <spine/Extension.h>
 #include <spine/Extension.h>
-#include <spine/SkeletonBatch.h>
-#include <spine/SkeletonTwoColorBatch.h>
 #include <spine/AttachmentVertices.h>
 #include <spine/AttachmentVertices.h>
 #include <algorithm>
 #include <algorithm>
 
 
@@ -163,8 +162,8 @@ namespace spine {
 	SkeletonRenderer::~SkeletonRenderer () {
 	SkeletonRenderer::~SkeletonRenderer () {
 		if (_ownsSkeletonData) delete _skeleton->getData();
 		if (_ownsSkeletonData) delete _skeleton->getData();
 		if (_ownsSkeleton) delete _skeleton;
 		if (_ownsSkeleton) delete _skeleton;
-		if (_ownsAtlas) delete _atlas;
-		delete _attachmentLoader;
+		if (_ownsAtlas && _atlas) delete _atlas;
+		if (_attachmentLoader) delete _attachmentLoader;
 		delete _clipper;
 		delete _clipper;
 	}
 	}
 
 
@@ -1029,3 +1028,5 @@ namespace spine {
 	}
 	}
 
 
 }
 }
+
+#endif

+ 5 - 1
spine-cocos2dx/src/spine/SkeletonRenderer.h → spine-cocos2dx/src/spine/v3/SkeletonRenderer.h

@@ -30,8 +30,10 @@
 #ifndef SPINE_SKELETONRENDERER_H_
 #ifndef SPINE_SKELETONRENDERER_H_
 #define SPINE_SKELETONRENDERER_H_
 #define SPINE_SKELETONRENDERER_H_
 
 
-#include <spine/spine.h>
 #include "cocos2d.h"
 #include "cocos2d.h"
+#if COCOS2D_VERSION < 0x00040000
+
+#include <spine/spine.h>
 
 
 namespace spine {
 namespace spine {
 
 
@@ -161,4 +163,6 @@ namespace spine {
 
 
 }
 }
 
 
+#endif
+
 #endif /* SPINE_SKELETONRENDERER_H_ */
 #endif /* SPINE_SKELETONRENDERER_H_ */

+ 5 - 1
spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp → spine-cocos2dx/src/spine/v3/SkeletonTwoColorBatch.cpp

@@ -27,7 +27,9 @@
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
  *****************************************************************************/
 
 
-#include <spine/SkeletonTwoColorBatch.h>
+#include <spine/spine-cocos2dx.h>
+#if COCOS2D_VERSION < 0x00040000
+
 #include <spine/Extension.h>
 #include <spine/Extension.h>
 #include <algorithm>
 #include <algorithm>
 
 
@@ -345,3 +347,5 @@ TwoColorTrianglesCommand* SkeletonTwoColorBatch::nextFreeCommand() {
 	return command;
 	return command;
 }
 }
 }
 }
+
+#endif

+ 5 - 1
spine-cocos2dx/src/spine/SkeletonTwoColorBatch.h → spine-cocos2dx/src/spine/v3/SkeletonTwoColorBatch.h

@@ -30,8 +30,10 @@
 #ifndef SPINE_SKELETONTWOCOLORBATCH_H_
 #ifndef SPINE_SKELETONTWOCOLORBATCH_H_
 #define SPINE_SKELETONTWOCOLORBATCH_H_
 #define SPINE_SKELETONTWOCOLORBATCH_H_
 
 
-#include <spine/spine.h>
 #include "cocos2d.h"
 #include "cocos2d.h"
+#if COCOS2D_VERSION < 0x00040000
+
+#include <spine/spine.h>
 #include <vector>
 #include <vector>
 
 
 namespace spine {
 namespace spine {
@@ -165,4 +167,6 @@ namespace spine {
 	};
 	};
 }
 }
 
 
+#endif
+
 #endif // SPINE_SKELETONTWOCOLORBATCH_H_
 #endif // SPINE_SKELETONTWOCOLORBATCH_H_

+ 194 - 0
spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp

@@ -0,0 +1,194 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#include <spine/spine-cocos2dx.h>
+#if COCOS2D_VERSION >= 0x00040000
+
+#include <spine/Extension.h>
+#include <algorithm>
+
+USING_NS_CC;
+#define EVENT_AFTER_DRAW_RESET_POSITION "director_after_draw"
+using std::max;
+#define INITIAL_SIZE (10000)
+
+#include "renderer/ccShaders.h"
+#include "renderer/backend/Device.h"
+
+namespace spine {
+
+static SkeletonBatch* instance = nullptr;
+
+SkeletonBatch* SkeletonBatch::getInstance () {
+	if (!instance) instance = new SkeletonBatch();
+	return instance;
+}
+
+void SkeletonBatch::destroyInstance () {
+	if (instance) {
+		delete instance;
+		instance = nullptr;
+	}
+}
+
+SkeletonBatch::SkeletonBatch () {
+
+    auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, positionTextureColor_frag);
+    _programState = std::make_shared<backend::ProgramState>(program);
+    program->autorelease();
+
+    auto vertexLayout = _programState->getVertexLayout();
+
+    vertexLayout->setAttribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(V3F_C4B_T2F, vertices), false);
+    vertexLayout->setAttribute("a_color", 2, backend::VertexFormat::UBYTE4, offsetof(V3F_C4B_T2F, colors), true);
+    vertexLayout->setAttribute("a_texCoord", 1, backend::VertexFormat::FLOAT2, offsetof(V3F_C4B_T2F, texCoords), false);
+    vertexLayout->setLayout(sizeof(_vertices[0]));
+
+
+    _locMVP = _programState->getUniformLocation("u_MVPMatrix");
+    _locTexture = _programState->getUniformLocation("u_texture");
+
+    for (unsigned int i = 0; i < INITIAL_SIZE; i++) {
+        _commandsPool.push_back(createNewTrianglesCommand());
+    }
+    reset();
+    // callback after drawing is finished so we can clear out the batch state
+    // for the next frame
+    Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom* eventCustom) {
+        this->update(0);
+        });;
+}
+
+SkeletonBatch::~SkeletonBatch () {
+	Director::getInstance()->getEventDispatcher()->removeCustomEventListeners(EVENT_AFTER_DRAW_RESET_POSITION);
+
+	for (unsigned int i = 0; i < _commandsPool.size(); i++) {
+        CC_SAFE_RELEASE(_commandsPool[i]->getPipelineDescriptor().programState);
+		delete _commandsPool[i];
+		_commandsPool[i] = nullptr;
+	}
+}
+
+void SkeletonBatch::update (float delta) {
+	reset();
+}
+
+cocos2d::V3F_C4B_T2F* SkeletonBatch::allocateVertices(uint32_t numVertices) {
+	if (_vertices.size() - _numVertices < numVertices) {
+		cocos2d::V3F_C4B_T2F* oldData = _vertices.data();
+		_vertices.resize((_vertices.size() + numVertices) * 2 + 1);
+		cocos2d::V3F_C4B_T2F* newData = _vertices.data();
+		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
+			TrianglesCommand* command = _commandsPool[i];
+			cocos2d::TrianglesCommand::Triangles& triangles = (cocos2d::TrianglesCommand::Triangles&)command->getTriangles();
+			triangles.verts = newData + (triangles.verts - oldData);
+		}
+	}
+
+	cocos2d::V3F_C4B_T2F* vertices = _vertices.data() + _numVertices;
+	_numVertices += numVertices;
+	return vertices;
+}
+
+void SkeletonBatch::deallocateVertices(uint32_t numVertices) {
+	_numVertices -= numVertices;
+}
+
+
+unsigned short* SkeletonBatch::allocateIndices(uint32_t numIndices) {
+	if (_indices.getCapacity() - _indices.size() < numIndices) {
+		unsigned short* oldData = _indices.buffer();
+		int oldSize = _indices.size();
+		_indices.ensureCapacity(_indices.size() + numIndices);
+		unsigned short* newData = _indices.buffer();
+		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
+			TrianglesCommand* command = _commandsPool[i];
+			cocos2d::TrianglesCommand::Triangles& triangles = (cocos2d::TrianglesCommand::Triangles&)command->getTriangles();
+			if (triangles.indices >= oldData && triangles.indices < oldData + oldSize) {
+				triangles.indices = newData + (triangles.indices - oldData);
+			}
+		}
+	}
+
+	unsigned short* indices = _indices.buffer() + _indices.size();
+	_indices.setSize(_indices.size() + numIndices, 0);
+	return indices;
+}
+
+void SkeletonBatch::deallocateIndices(uint32_t numIndices) {
+	_indices.setSize(_indices.size() - numIndices, 0);
+}
+
+
+cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags) {
+	TrianglesCommand* command = nextFreeCommand();
+    const cocos2d::Mat4& projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
+    auto &pipelineDescriptor = command->getPipelineDescriptor();
+
+    auto programState = command->getPipelineDescriptor().programState;
+    CCASSERT(programState, "programState should not be null");
+
+    programState->setUniform(_locMVP, projectionMat.m, sizeof(projectionMat.m));
+    programState->setTexture(_locTexture, 0, texture->getBackendTexture());
+
+    command->init(globalOrder, texture, blendType, triangles, mv, flags);
+    renderer->addCommand(command);
+	return command;
+}
+
+void SkeletonBatch::reset() {
+	_nextFreeCommand = 0;
+	_numVertices = 0;
+	_indices.setSize(0, 0);
+}
+
+cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() {
+    if (_commandsPool.size() <= _nextFreeCommand) {
+        unsigned int newSize = _commandsPool.size() * 2 + 1;
+        for (int i = _commandsPool.size(); i < newSize; i++) {
+            _commandsPool.push_back(createNewTrianglesCommand());
+        }
+    }
+    auto* command = _commandsPool[_nextFreeCommand++];
+    auto& pipelineDescriptor = command->getPipelineDescriptor();
+    if (pipelineDescriptor.programState == nullptr)
+    {
+        CCASSERT(_programState, "programState should not be null");
+        pipelineDescriptor.programState = _programState->clone();
+    }
+    return command;
+}
+
+cocos2d::TrianglesCommand *SkeletonBatch::createNewTrianglesCommand() {
+    auto* command = new TrianglesCommand();
+    return command;
+}
+}
+
+#endif

+ 84 - 0
spine-cocos2dx/src/spine/v4/SkeletonBatch.h

@@ -0,0 +1,84 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#ifndef SPINE_SKELETONBATCH_H_
+#define SPINE_SKELETONBATCH_H_
+
+#include "cocos2d.h"
+#if COCOS2D_VERSION >= 0x00040000
+
+#include <spine/spine.h>
+#include <vector>
+
+namespace spine {
+    
+    class SkeletonBatch {
+    public:
+        static SkeletonBatch* getInstance ();
+        
+        static void destroyInstance ();
+        
+        void update (float delta);
+		
+		cocos2d::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
+		void deallocateVertices(uint32_t numVertices);
+		unsigned short* allocateIndices(uint32_t numIndices);
+		void deallocateIndices(uint32_t numVertices);
+		cocos2d::TrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
+        
+    protected:
+        SkeletonBatch ();
+        virtual ~SkeletonBatch ();
+		
+		void reset ();
+		
+		cocos2d::TrianglesCommand* nextFreeCommand ();
+
+        cocos2d::TrianglesCommand* createNewTrianglesCommand();
+        std::shared_ptr<cocos2d::backend::ProgramState>     _programState = nullptr;
+        cocos2d::backend::UniformLocation                   _locMVP;
+        cocos2d::backend::UniformLocation                   _locTexture;
+		
+		// pool of commands
+		std::vector<cocos2d::TrianglesCommand*>             _commandsPool;
+		uint32_t                                            _nextFreeCommand;
+		
+		// pool of vertices
+		std::vector<cocos2d::V3F_C4B_T2F>                   _vertices;
+		uint32_t                                            _numVertices;
+		
+		// pool of indices
+		Vector<unsigned short>                              _indices;
+    };
+	
+}
+
+#endif
+
+#endif // SPINE_SKELETONBATCH_H_

+ 910 - 0
spine-cocos2dx/src/spine/v4/SkeletonRenderer.cpp

@@ -0,0 +1,910 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#include <spine/spine-cocos2dx.h>
+#if COCOS2D_VERSION >= 0x00040000
+
+#include <spine/Extension.h>
+#include <spine/AttachmentVertices.h>
+#include <algorithm>
+
+#include "renderer/backend/Types.h"
+
+#define INITIAL_WORLD_VERTICES_LENGTH 1000
+// Used for transforming attachments for bounding boxes & debug rendering
+static float* worldVertices = nullptr;
+static size_t worldVerticesLength = 0;
+
+void ensureWorldVerticesCapacity(size_t capacity) {
+	if (worldVerticesLength < capacity) {
+		float* newWorldVertices = new float[capacity];
+		memcpy(newWorldVertices, worldVertices, capacity * sizeof(float));
+		delete[] worldVertices;
+		worldVertices = newWorldVertices;
+		worldVerticesLength = capacity;
+	}
+}
+
+USING_NS_CC;
+using std::min;
+using std::max;
+
+namespace spine {
+
+	static Cocos2dTextureLoader textureLoader;
+
+	void SkeletonRenderer::destroyScratchBuffers() {
+		if (worldVertices) {
+			delete[] worldVertices;
+			worldVertices = nullptr;
+			worldVerticesLength = 0;
+		}
+	}
+
+	SkeletonRenderer* SkeletonRenderer::createWithSkeleton(Skeleton* skeleton, bool ownsSkeleton, bool ownsSkeletonData) {
+		SkeletonRenderer* node = new SkeletonRenderer(skeleton, ownsSkeleton, ownsSkeletonData);
+		node->autorelease();
+		return node;
+	}
+
+	SkeletonRenderer* SkeletonRenderer::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
+		SkeletonRenderer* node = new SkeletonRenderer(skeletonData, ownsSkeletonData);
+		node->autorelease();
+		return node;
+	}
+
+	SkeletonRenderer* SkeletonRenderer::createWithFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
+		SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlas, scale);
+		node->autorelease();
+		return node;
+	}
+
+	SkeletonRenderer* SkeletonRenderer::createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) {
+		SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlasFile, scale);
+		node->autorelease();
+		return node;
+	}
+
+	void SkeletonRenderer::initialize () {
+		if (!worldVertices) {
+			worldVertices = new float[INITIAL_WORLD_VERTICES_LENGTH];
+			worldVerticesLength = INITIAL_WORLD_VERTICES_LENGTH;
+		}
+
+		_clipper = new (__FILE__, __LINE__) SkeletonClipping();
+
+		_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
+		setOpacityModifyRGB(true);
+
+		setupGLProgramState(false);
+
+		_skeleton->setToSetupPose();
+		_skeleton->updateWorldTransform();
+	}
+
+	void SkeletonRenderer::setupGLProgramState (bool twoColorTintEnabled) {
+
+        _twoColorTintEnabled = twoColorTintEnabled;
+		if (twoColorTintEnabled) {
+			return;
+		}
+
+		Texture2D *texture = nullptr;
+		for (int i = 0, n = _skeleton->getSlots().size(); i < n; i++) {
+			Slot* slot = _skeleton->getDrawOrder()[i];
+			if (!slot->getAttachment()) continue;
+			if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
+				RegionAttachment* attachment = (RegionAttachment*)slot->getAttachment();
+				texture = static_cast<AttachmentVertices*>(attachment->getRendererObject())->_texture;
+			} else if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
+				MeshAttachment* attachment = (MeshAttachment*)slot->getAttachment();
+				texture = static_cast<AttachmentVertices*>(attachment->getRendererObject())->_texture;
+			} else {
+				continue;
+			}
+
+			if (texture != nullptr) {
+				break;
+			}
+		}
+		//setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
+	}
+
+	void SkeletonRenderer::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) {
+		_skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
+		_ownsSkeletonData = ownsSkeletonData;
+	}
+
+	SkeletonRenderer::SkeletonRenderer ()
+	: _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _debugMeshes(false), _timeScale(1), _effect(nullptr), _startSlotIndex(-1), _endSlotIndex(-1) {
+	}
+
+	SkeletonRenderer::SkeletonRenderer(Skeleton* skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas)
+	: _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _debugMeshes(false), _timeScale(1), _effect(nullptr), _startSlotIndex(-1), _endSlotIndex(-1) {
+		initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData, ownsAtlas);
+	}
+
+	SkeletonRenderer::SkeletonRenderer (SkeletonData *skeletonData, bool ownsSkeletonData)
+	: _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _debugMeshes(false), _timeScale(1), _effect(nullptr), _startSlotIndex(-1), _endSlotIndex(-1) {
+		initWithData(skeletonData, ownsSkeletonData);
+	}
+
+	SkeletonRenderer::SkeletonRenderer (const std::string& skeletonDataFile, Atlas* atlas, float scale)
+	: _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _debugMeshes(false), _timeScale(1), _effect(nullptr), _startSlotIndex(-1), _endSlotIndex(-1) {
+		initWithJsonFile(skeletonDataFile, atlas, scale);
+	}
+
+	SkeletonRenderer::SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
+	: _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _debugMeshes(false), _timeScale(1), _effect(nullptr), _startSlotIndex(-1), _endSlotIndex(-1) {
+		initWithJsonFile(skeletonDataFile, atlasFile, scale);
+	}
+
+	SkeletonRenderer::~SkeletonRenderer () {
+		if (_ownsSkeletonData) delete _skeleton->getData();
+		if (_ownsSkeleton) delete _skeleton;
+		if (_ownsAtlas && _atlas) delete _atlas;
+		if (_attachmentLoader) delete _attachmentLoader;
+		delete _clipper;
+	}
+
+	void SkeletonRenderer::initWithSkeleton(Skeleton* skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas) {
+		_skeleton = skeleton;
+		_ownsSkeleton = ownsSkeleton;
+		_ownsSkeletonData = ownsSkeletonData;
+		_ownsAtlas = ownsAtlas;
+
+		initialize();
+	}
+
+	void SkeletonRenderer::initWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
+		_ownsSkeleton = true;
+		setSkeletonData(skeletonData, ownsSkeletonData);
+		initialize();
+	}
+
+	void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
+		_atlas = atlas;
+		_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
+
+		SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
+		json->setScale(scale);
+		SkeletonData* skeletonData = json->readSkeletonDataFile(skeletonDataFile.c_str());
+		CCASSERT(skeletonData, !json->getError().isEmpty() ? json->getError().buffer() : "Error reading skeleton data.");
+		delete json;
+
+		_ownsSkeleton = true;
+		setSkeletonData(skeletonData, true);
+
+		initialize();
+	}
+
+	void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) {
+		_atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader);
+		CCASSERT(_atlas, "Error reading atlas file.");
+
+		_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
+
+		SkeletonJson* json = new (__FILE__, __LINE__) SkeletonJson(_attachmentLoader);
+		json->setScale(scale);
+		SkeletonData* skeletonData = json->readSkeletonDataFile(skeletonDataFile.c_str());
+		CCASSERT(skeletonData, !json->getError().isEmpty() ? json->getError().buffer() : "Error reading skeleton data.");
+		delete json;
+
+		_ownsSkeleton = true;
+		_ownsAtlas = true;
+		setSkeletonData(skeletonData, true);
+
+		initialize();
+	}
+
+	void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale) {
+		_atlas = atlas;
+		_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
+
+		SkeletonBinary* binary = new (__FILE__, __LINE__) SkeletonBinary(_attachmentLoader);
+		binary->setScale(scale);
+		SkeletonData* skeletonData = binary->readSkeletonDataFile(skeletonDataFile.c_str());
+		CCASSERT(skeletonData, !binary->getError().isEmpty() ? binary->getError().buffer() : "Error reading skeleton data.");
+		delete binary;
+		_ownsSkeleton = true;
+		setSkeletonData(skeletonData, true);
+
+		initialize();
+	}
+
+	void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) {
+		_atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader);
+		CCASSERT(_atlas, "Error reading atlas file.");
+
+		_attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas);
+
+		SkeletonBinary* binary = new (__FILE__, __LINE__) SkeletonBinary(_attachmentLoader);
+		binary->setScale(scale);
+		SkeletonData* skeletonData = binary->readSkeletonDataFile(skeletonDataFile.c_str());
+		CCASSERT(skeletonData, !binary->getError().isEmpty() ? binary->getError().buffer() : "Error reading skeleton data.");
+		delete binary;
+		_ownsSkeleton = true;
+		_ownsAtlas = true;
+		setSkeletonData(skeletonData, true);
+
+		initialize();
+	}
+
+	void SkeletonRenderer::update (float deltaTime) {
+		Node::update(deltaTime);
+		if (_ownsSkeleton) _skeleton->update(deltaTime * _timeScale);
+	}
+
+	void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t transformFlags) {
+		SkeletonBatch* batch = SkeletonBatch::getInstance();
+		SkeletonTwoColorBatch* twoColorBatch = SkeletonTwoColorBatch::getInstance();
+		bool isTwoColorTint = this->isTwoColorTint();
+
+		// Early exit if the skeleton is invisible
+		if (getDisplayedOpacity() == 0 || _skeleton->getColor().a == 0){
+			return;
+		}
+
+		if (_effect) _effect->begin(*_skeleton);
+
+		Color4F nodeColor;
+		nodeColor.r = getDisplayedColor().r / (float)255;
+		nodeColor.g = getDisplayedColor().g / (float)255;
+		nodeColor.b = getDisplayedColor().b / (float)255;
+		nodeColor.a = getDisplayedOpacity() / (float)255;
+
+		Color4F color;
+		Color4F darkColor;
+		float darkPremultipliedAlpha = _premultipliedAlpha ? 255 : 0;
+		AttachmentVertices* attachmentVertices = nullptr;
+		TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr;
+		bool inRange = _startSlotIndex != -1 || _endSlotIndex != -1 ? false : true;
+		for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
+			Slot* slot = _skeleton->getDrawOrder()[i];
+
+			if (_startSlotIndex >= 0 && _startSlotIndex == slot->getData().getIndex()) {
+				inRange = true;
+			}
+
+			if (!inRange) {
+				_clipper->clipEnd(*slot);
+				continue;
+			}
+
+			if (_endSlotIndex >= 0 && _endSlotIndex == slot->getData().getIndex()) {
+				inRange = false;
+			}
+
+			if (!slot->getAttachment()) {
+				_clipper->clipEnd(*slot);
+				continue;
+			}
+
+			// Early exit if slot is invisible
+			if (slot->getColor().a == 0) {
+				_clipper->clipEnd(*slot);
+				continue;
+			}
+
+			cocos2d::TrianglesCommand::Triangles triangles;
+			TwoColorTriangles trianglesTwoColor;
+
+			if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
+				RegionAttachment* attachment = (RegionAttachment*)slot->getAttachment();
+				attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
+
+				// Early exit if attachment is invisible
+				if (attachment->getColor().a == 0) {
+					_clipper->clipEnd(*slot);
+					continue;
+				}
+
+				if (!isTwoColorTint) {
+					triangles.indices = attachmentVertices->_triangles->indices;
+					triangles.indexCount = attachmentVertices->_triangles->indexCount;
+					triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
+					triangles.vertCount = attachmentVertices->_triangles->vertCount;
+					memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
+					attachment->computeWorldVertices(slot->getBone(), (float*)triangles.verts, 0, 6);
+				} else {
+					trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
+					trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
+					trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
+					trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
+					for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
+						trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
+					}
+					attachment->computeWorldVertices(slot->getBone(), (float*)trianglesTwoColor.verts, 0, 7);
+				}
+
+				color.r = attachment->getColor().r;
+				color.g = attachment->getColor().g;
+				color.b = attachment->getColor().b;
+				color.a = attachment->getColor().a;
+			}
+			else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
+				MeshAttachment* attachment = (MeshAttachment*)slot->getAttachment();
+				attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
+
+				// Early exit if attachment is invisible
+				if (attachment->getColor().a == 0) {
+					_clipper->clipEnd(*slot);
+					continue;
+				}
+
+				if (!isTwoColorTint) {
+					triangles.indices = attachmentVertices->_triangles->indices;
+					triangles.indexCount = attachmentVertices->_triangles->indexCount;
+					triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
+					triangles.vertCount = attachmentVertices->_triangles->vertCount;
+					memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
+					attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float*)triangles.verts, 0, 6);
+				} else {
+					trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
+					trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
+					trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
+					trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
+					for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
+						trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
+					}
+					attachment->computeWorldVertices(*slot, 0,  attachment->getWorldVerticesLength(), (float*)trianglesTwoColor.verts, 0, 7);
+				}
+
+				color.r = attachment->getColor().r;
+				color.g = attachment->getColor().g;
+				color.b = attachment->getColor().b;
+				color.a = attachment->getColor().a;
+			}
+			else if (slot->getAttachment()->getRTTI().isExactly(ClippingAttachment::rtti)) {
+				ClippingAttachment* clip = (ClippingAttachment*)slot->getAttachment();
+				_clipper->clipStart(*slot, clip);
+				continue;
+			} else {
+				_clipper->clipEnd(*slot);
+				continue;
+			}
+
+			float alpha = nodeColor.a * _skeleton->getColor().a * slot->getColor().a * color.a * 255;
+			// skip rendering if the color of this attachment is 0
+			if (alpha == 0){
+				_clipper->clipEnd(*slot);
+				continue;
+			}
+			float multiplier = _premultipliedAlpha ? alpha : 255;
+			float red = nodeColor.r * _skeleton->getColor().r * color.r * multiplier;
+			float green = nodeColor.g * _skeleton->getColor().g * color.g * multiplier;
+			float blue = nodeColor.b * _skeleton->getColor().b * color.b * multiplier;
+
+			color.r = red * slot->getColor().r;
+			color.g = green * slot->getColor().g;
+			color.b = blue * slot->getColor().b;
+			color.a = alpha;
+
+			if (slot->hasDarkColor()) {
+				darkColor.r = red * slot->getDarkColor().r;
+				darkColor.g = green * slot->getDarkColor().g;
+				darkColor.b = blue * slot->getDarkColor().b;
+			} else {
+				darkColor.r = 0;
+				darkColor.g = 0;
+				darkColor.b = 0;
+			}
+			darkColor.a = darkPremultipliedAlpha;
+
+			BlendFunc blendFunc;
+			switch (slot->getData().getBlendMode()) {
+				case BlendMode_Additive:
+					blendFunc.src = _premultipliedAlpha ? backend::BlendFactor::ONE : backend::BlendFactor::SRC_ALPHA;
+					blendFunc.dst = backend::BlendFactor::ONE;
+					break;
+				case BlendMode_Multiply:
+					blendFunc.src = backend::BlendFactor::DST_COLOR;
+					blendFunc.dst = backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
+					break;
+				case BlendMode_Screen:
+					blendFunc.src = backend::BlendFactor::ONE;
+					blendFunc.dst = backend::BlendFactor::ONE_MINUS_SRC_COLOR;
+					break;
+				default:
+					blendFunc.src = _premultipliedAlpha ? backend::BlendFactor::ONE : backend::BlendFactor::SRC_ALPHA;
+					blendFunc.dst = backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
+			}
+
+			if (!isTwoColorTint) {
+				if (_clipper->isClipping()) {
+					_clipper->clipTriangles((float*)&triangles.verts[0].vertices, triangles.indices, triangles.indexCount, (float*)&triangles.verts[0].texCoords, sizeof(cocos2d::V3F_C4B_T2F) / 4);
+					batch->deallocateVertices(triangles.vertCount);
+
+					if (_clipper->getClippedTriangles().size() == 0){
+						_clipper->clipEnd(*slot);
+						continue;
+					}
+
+					triangles.vertCount = _clipper->getClippedVertices().size() >> 1;
+					triangles.verts = batch->allocateVertices(triangles.vertCount);
+					triangles.indexCount = _clipper->getClippedTriangles().size();
+					triangles.indices = batch->allocateIndices(triangles.indexCount);
+					memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
+
+					cocos2d::TrianglesCommand* batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, blendFunc, triangles, transform, transformFlags);
+
+					float* verts = _clipper->getClippedVertices().buffer();
+					float* uvs = _clipper->getClippedUVs().buffer();
+					if (_effect) {
+						Color light;
+						Color dark;
+						light.r = color.r / 255.0f;
+						light.g = color.g / 255.0f;
+						light.b = color.b / 255.0f;
+						light.a = color.a / 255.0f;
+						dark.r = dark.g = dark.b = dark.a = 0;
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv+=2) {
+							V3F_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							Color lightCopy = light;
+							Color darkCopy = dark;
+							vertex->vertices.x = verts[vv];
+							vertex->vertices.y = verts[vv + 1];
+							vertex->texCoords.u = uvs[vv];
+							vertex->texCoords.v = uvs[vv + 1];
+							_effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
+							vertex->colors.r = (uint8_t)(lightCopy.r * 255);
+							vertex->colors.g = (uint8_t)(lightCopy.g * 255);
+							vertex->colors.b = (uint8_t)(lightCopy.b * 255);
+							vertex->colors.a = (uint8_t)(lightCopy.a * 255);
+						}
+					} else {
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv+=2) {
+							V3F_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							vertex->vertices.x = verts[vv];
+							vertex->vertices.y = verts[vv + 1];
+							vertex->texCoords.u = uvs[vv];
+							vertex->texCoords.v = uvs[vv + 1];
+							vertex->colors.r = (uint8_t)color.r;
+							vertex->colors.g = (uint8_t)color.g;
+							vertex->colors.b = (uint8_t)color.b;
+							vertex->colors.a = (uint8_t)color.a;
+						}
+					}
+				} else {
+					cocos2d::TrianglesCommand* batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, blendFunc, triangles, transform, transformFlags);
+
+					if (_effect) {
+						Color light;
+						Color dark;
+						light.r = color.r / 255.0f;
+						light.g = color.g / 255.0f;
+						light.b = color.b / 255.0f;
+						light.a = color.a / 255.0f;
+						dark.r = dark.g = dark.b = dark.a = 0;
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
+							V3F_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							Color lightCopy = light;
+							Color darkCopy = dark;
+							_effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy,  darkCopy);
+							vertex->colors.r = (uint8_t)(lightCopy.r * 255);
+							vertex->colors.g = (uint8_t)(lightCopy.g * 255);
+							vertex->colors.b = (uint8_t)(lightCopy.b * 255);
+							vertex->colors.a = (uint8_t)(lightCopy.a * 255);
+						}
+					} else {
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
+							V3F_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							vertex->colors.r = (uint8_t)color.r;
+							vertex->colors.g = (uint8_t)color.g;
+							vertex->colors.b = (uint8_t)color.b;
+							vertex->colors.a = (uint8_t)color.a;
+						}
+					}
+				}
+			} else {
+				if (_clipper->isClipping()) {
+					_clipper->clipTriangles((float*)&trianglesTwoColor.verts[0].position, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float*)&trianglesTwoColor.verts[0].texCoords, sizeof(V3F_C4B_C4B_T2F) / 4);
+					twoColorBatch->deallocateVertices(trianglesTwoColor.vertCount);
+
+					if (_clipper->getClippedTriangles().size() == 0){
+						_clipper->clipEnd(*slot);
+						continue;
+					}
+
+					trianglesTwoColor.vertCount = _clipper->getClippedVertices().size() >> 1;
+					trianglesTwoColor.verts = twoColorBatch->allocateVertices(trianglesTwoColor.vertCount);
+					trianglesTwoColor.indexCount = _clipper->getClippedTriangles().size();
+					trianglesTwoColor.indices = twoColorBatch->allocateIndices(trianglesTwoColor.indexCount);
+					memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
+
+					TwoColorTrianglesCommand* batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, blendFunc, trianglesTwoColor, transform, transformFlags);
+
+					float* verts = _clipper->getClippedVertices().buffer();
+					float* uvs = _clipper->getClippedUVs().buffer();
+
+					if (_effect) {
+						Color light;
+						Color dark;
+						light.r = color.r / 255.0f;
+						light.g = color.g / 255.0f;
+						light.b = color.b / 255.0f;
+						light.a = color.a / 255.0f;
+						dark.r = darkColor.r / 255.0f;
+						dark.g = darkColor.g / 255.0f;
+						dark.b = darkColor.b / 255.0f;
+						dark.a = darkColor.a / 255.0f;
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2) {
+							V3F_C4B_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							Color lightCopy = light;
+							Color darkCopy = dark;
+							vertex->position.x = verts[vv];
+							vertex->position.y = verts[vv + 1];
+							vertex->texCoords.u = uvs[vv];
+							vertex->texCoords.v = uvs[vv + 1];
+							_effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
+							vertex->color.r = (uint8_t)(lightCopy.r * 255);
+							vertex->color.g = (uint8_t)(lightCopy.g * 255);
+							vertex->color.b = (uint8_t)(lightCopy.b * 255);
+							vertex->color.a = (uint8_t)(lightCopy.a * 255);
+							vertex->color2.r = (uint8_t)(darkCopy.r * 255);
+							vertex->color2.g = (uint8_t)(darkCopy.g * 255);
+							vertex->color2.b = (uint8_t)(darkCopy.b * 255);
+							vertex->color2.a = (uint8_t)darkColor.a;
+						}
+					} else {
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2) {
+							V3F_C4B_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							vertex->position.x = verts[vv];
+							vertex->position.y = verts[vv + 1];
+							vertex->texCoords.u = uvs[vv];
+							vertex->texCoords.v = uvs[vv + 1];
+							vertex->color.r = (uint8_t)color.r;
+							vertex->color.g = (uint8_t)color.g;
+							vertex->color.b = (uint8_t)color.b;
+							vertex->color.a = (uint8_t)color.a;
+							vertex->color2.r = (uint8_t)darkColor.r;
+							vertex->color2.g = (uint8_t)darkColor.g;
+							vertex->color2.b = (uint8_t)darkColor.b;
+							vertex->color2.a = (uint8_t)darkColor.a;
+						}
+					}
+				} else {
+					TwoColorTrianglesCommand* batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, blendFunc, trianglesTwoColor, transform, transformFlags);
+
+					if (_effect) {
+						Color light;
+						Color dark;
+						light.r = color.r / 255.0f;
+						light.g = color.g / 255.0f;
+						light.b = color.b / 255.0f;
+						light.a = color.a / 255.0f;
+						dark.r = darkColor.r / 255.0f;
+						dark.g = darkColor.g / 255.0f;
+						dark.b = darkColor.b / 255.0f;
+						dark.a = darkColor.a / 255.0f;
+
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
+							V3F_C4B_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							Color lightCopy = light;
+							Color darkCopy = dark;
+							_effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
+							vertex->color.r = (uint8_t)(lightCopy.r * 255);
+							vertex->color.g = (uint8_t)(lightCopy.g * 255);
+							vertex->color.b = (uint8_t)(lightCopy.b * 255);
+							vertex->color.a = (uint8_t)(lightCopy.a * 255);
+							vertex->color2.r = (uint8_t)(darkCopy.r * 255);
+							vertex->color2.g = (uint8_t)(darkCopy.g * 255);
+							vertex->color2.b = (uint8_t)(darkCopy.b * 255);
+							vertex->color2.a = (uint8_t)darkColor.a;
+						}
+					} else {
+						for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
+							V3F_C4B_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
+							vertex->color.r = (uint8_t)color.r;
+							vertex->color.g = (uint8_t)color.g;
+							vertex->color.b = (uint8_t)color.b;
+							vertex->color.a = (uint8_t)color.a;
+							vertex->color2.r = (uint8_t)darkColor.r;
+							vertex->color2.g = (uint8_t)darkColor.g;
+							vertex->color2.b = (uint8_t)darkColor.b;
+							vertex->color2.a = (uint8_t)darkColor.a;
+						}
+					}
+				}
+			}
+			_clipper->clipEnd(*slot);
+		}
+		_clipper->clipEnd();
+
+		if (lastTwoColorTrianglesCommand) {
+			Node* parent = this->getParent();
+
+			// We need to decide if we can postpone flushing the current
+			// batch. We can postpone if the next sibling node is a
+			// two color tinted skeleton with the same global-z.
+			// The parent->getChildrenCount() > 100 check is a hack
+			// as checking for a sibling is an O(n) operation, and if
+			// all children of this nodes parent are skeletons, we
+			// are in O(n2) territory.
+			if (!parent || parent->getChildrenCount() > 100 || getChildrenCount() != 0) {
+				lastTwoColorTrianglesCommand->setForceFlush(true);
+			} else {
+				cocos2d::Vector<Node*>& children = parent->getChildren();
+				Node* sibling = nullptr;
+				for (ssize_t i = 0; i < children.size(); i++) {
+					if (children.at(i) == this) {
+						if (i < children.size() - 1) {
+							sibling = children.at(i+1);
+							break;
+						}
+					}
+				}
+				if (!sibling) {
+					lastTwoColorTrianglesCommand->setForceFlush(true);
+				} else {
+					SkeletonRenderer* siblingSkeleton = dynamic_cast<SkeletonRenderer*>(sibling);
+					if (!siblingSkeleton || // flush is next sibling isn't a SkeletonRenderer
+						!siblingSkeleton->isTwoColorTint() || // flush if next sibling isn't two color tinted
+						!siblingSkeleton->isVisible() || // flush if next sibling is two color tinted but not visible
+						(siblingSkeleton->getGlobalZOrder() != this->getGlobalZOrder())) { // flush if next sibling is two color tinted but z-order differs
+						lastTwoColorTrianglesCommand->setForceFlush(true);
+					}
+				}
+			}
+		}
+
+		if (_effect) _effect->end();
+
+		if (_debugSlots || _debugBones || _debugMeshes) {
+			drawDebug(renderer, transform, transformFlags);
+		}
+	}
+
+	void SkeletonRenderer::drawDebug (Renderer* renderer, const Mat4 &transform, uint32_t transformFlags) {
+
+		Director* director = Director::getInstance();
+		director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
+		director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);
+
+		DrawNode* drawNode = DrawNode::create();
+
+		if (_debugSlots) {
+			// Slots.
+			// DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
+            drawNode->setLineWidth(1.0f);
+			Vec2 points[4];
+			V3F_C4B_T2F_Quad quad;
+			for (int i = 0, n = _skeleton->getSlots().size(); i < n; i++) {
+				Slot* slot = _skeleton->getDrawOrder()[i];
+				if (!slot->getAttachment() || !slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) continue;
+				RegionAttachment* attachment = (RegionAttachment*)slot->getAttachment();
+				attachment->computeWorldVertices(slot->getBone(), worldVertices, 0, 2);
+				points[0] = Vec2(worldVertices[0], worldVertices[1]);
+				points[1] = Vec2(worldVertices[2], worldVertices[3]);
+				points[2] = Vec2(worldVertices[4], worldVertices[5]);
+				points[3] = Vec2(worldVertices[6], worldVertices[7]);
+				drawNode->drawPoly(points, 4, true, Color4F::BLUE);
+			}
+		}
+		if (_debugBones) {
+			// Bone lengths.
+            drawNode->setLineWidth(2.0f);
+			for (int i = 0, n = _skeleton->getBones().size(); i < n; i++) {
+				Bone *bone = _skeleton->getBones()[i];
+				float x = bone->getData().getLength() * bone->getA() + bone->getWorldX();
+				float y = bone->getData().getLength() * bone->getC() + bone->getWorldY();
+				drawNode->drawLine(Vec2(bone->getWorldX(), bone->getWorldY()), Vec2(x, y), Color4F::RED);
+			}
+			// Bone origins.
+			auto color = Color4F::BLUE; // Root bone is blue.
+			for (int i = 0, n = _skeleton->getBones().size(); i < n; i++) {
+				Bone *bone = _skeleton->getBones()[i];
+				drawNode->drawPoint(Vec2(bone->getWorldX(), bone->getWorldY()), 4, color);
+				if (i == 0) color = Color4F::GREEN;
+			}
+		}
+
+		if (_debugMeshes) {
+			// Meshes.
+            drawNode->setLineWidth(1.0f);
+			for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
+				Slot* slot = _skeleton->getDrawOrder()[i];
+				if (!slot->getAttachment() || !slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) continue;
+				MeshAttachment* attachment = (MeshAttachment*)slot->getAttachment();
+				ensureWorldVerticesCapacity(attachment->getWorldVerticesLength());
+				attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), worldVertices, 0, 2);
+				for (int ii = 0; ii < attachment->getTriangles().size();) {
+					Vec2 v1(worldVertices + (attachment->getTriangles()[ii++] * 2));
+					Vec2 v2(worldVertices + (attachment->getTriangles()[ii++] * 2));
+					Vec2 v3(worldVertices + (attachment->getTriangles()[ii++] * 2));
+					drawNode->drawLine(v1, v2, Color4F::YELLOW);
+					drawNode->drawLine(v2, v3, Color4F::YELLOW);
+					drawNode->drawLine(v3, v1, Color4F::YELLOW);
+				}
+			}
+
+		}
+
+		drawNode->draw(renderer, transform, transformFlags);
+		director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
+	}
+
+	Rect SkeletonRenderer::getBoundingBox () const {
+		float minX = FLT_MAX, minY = FLT_MAX, maxX = -FLT_MAX, maxY = -FLT_MAX;
+		float scaleX = getScaleX(), scaleY = getScaleY();
+		for (int i = 0; i < _skeleton->getSlots().size(); ++i) {
+			Slot* slot = _skeleton->getSlots()[i];
+			if (!slot->getAttachment()) continue;
+			int verticesCount;
+			if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
+				RegionAttachment* attachment = (RegionAttachment*)slot->getAttachment();
+				attachment->computeWorldVertices(slot->getBone(), worldVertices, 0, 2);
+				verticesCount = 8;
+			} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
+				MeshAttachment* mesh = (MeshAttachment*)slot->getAttachment();
+				ensureWorldVerticesCapacity(mesh->getWorldVerticesLength());
+				mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), worldVertices, 0, 2);
+				verticesCount = mesh->getWorldVerticesLength();
+			} else
+				continue;
+			for (int ii = 0; ii < verticesCount; ii += 2) {
+				float x = worldVertices[ii] * scaleX, y = worldVertices[ii + 1] * scaleY;
+				minX = min(minX, x);
+				minY = min(minY, y);
+				maxX = max(maxX, x);
+				maxY = max(maxY, y);
+			}
+		}
+		Vec2 position = getPosition();
+		if (minX == FLT_MAX) minX = minY = maxX = maxY = 0;
+		return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
+	}
+
+	// --- Convenience methods for Skeleton_* functions.
+
+	void SkeletonRenderer::updateWorldTransform () {
+		_skeleton->updateWorldTransform();
+	}
+
+	void SkeletonRenderer::setToSetupPose () {
+		_skeleton->setToSetupPose();
+	}
+	void SkeletonRenderer::setBonesToSetupPose () {
+		_skeleton->setBonesToSetupPose();
+	}
+	void SkeletonRenderer::setSlotsToSetupPose () {
+		_skeleton->setSlotsToSetupPose();
+	}
+
+	Bone* SkeletonRenderer::findBone (const std::string& boneName) const {
+		return _skeleton->findBone(boneName.c_str());
+	}
+
+	Slot* SkeletonRenderer::findSlot (const std::string& slotName) const {
+		return _skeleton->findSlot(slotName.c_str());
+	}
+
+	void SkeletonRenderer::setSkin (const std::string& skinName) {
+		_skeleton->setSkin(skinName.empty() ? 0 : skinName.c_str());
+	}
+	void SkeletonRenderer::setSkin (const char* skinName) {
+		_skeleton->setSkin(skinName);
+	}
+
+	Attachment* SkeletonRenderer::getAttachment (const std::string& slotName, const std::string& attachmentName) const {
+		return _skeleton->getAttachment(slotName.c_str(), attachmentName.c_str());
+	}
+	bool SkeletonRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName) {
+		return _skeleton->getAttachment(slotName.c_str(), attachmentName.empty() ? 0 : attachmentName.c_str()) ? true : false;
+	}
+	bool SkeletonRenderer::setAttachment (const std::string& slotName, const char* attachmentName) {
+		return _skeleton->getAttachment(slotName.c_str(), attachmentName) ? true : false;
+	}
+
+	void SkeletonRenderer::setTwoColorTint(bool enabled) {
+		setupGLProgramState(enabled);
+	}
+
+	bool SkeletonRenderer::isTwoColorTint() {
+        return _twoColorTintEnabled;
+	}
+
+	void SkeletonRenderer::setVertexEffect(VertexEffect *effect) {
+		this->_effect = effect;
+	}
+
+	void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
+		this->_startSlotIndex = startSlotIndex;
+		this->_endSlotIndex = endSlotIndex;
+	}
+
+	Skeleton* SkeletonRenderer::getSkeleton () {
+		return _skeleton;
+	}
+
+	void SkeletonRenderer::setTimeScale (float scale) {
+		_timeScale = scale;
+	}
+	float SkeletonRenderer::getTimeScale () const {
+		return _timeScale;
+	}
+
+	void SkeletonRenderer::setDebugSlotsEnabled (bool enabled) {
+		_debugSlots = enabled;
+	}
+	bool SkeletonRenderer::getDebugSlotsEnabled () const {
+		return _debugSlots;
+	}
+
+	void SkeletonRenderer::setDebugBonesEnabled (bool enabled) {
+		_debugBones = enabled;
+	}
+	bool SkeletonRenderer::getDebugBonesEnabled () const {
+		return _debugBones;
+	}
+
+	void SkeletonRenderer::setDebugMeshesEnabled (bool enabled) {
+		_debugMeshes = enabled;
+	}
+	bool SkeletonRenderer::getDebugMeshesEnabled () const {
+		return _debugMeshes;
+	}
+
+	void SkeletonRenderer::onEnter () {
+#if CC_ENABLE_SCRIPT_BINDING
+		if (_scriptType == kScriptTypeJavascript && ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter)) return;
+#endif
+		Node::onEnter();
+		scheduleUpdate();
+	}
+
+	void SkeletonRenderer::onExit () {
+#if CC_ENABLE_SCRIPT_BINDING
+		if (_scriptType == kScriptTypeJavascript && ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnExit)) return;
+#endif
+		Node::onExit();
+		unscheduleUpdate();
+	}
+
+	// --- CCBlendProtocol
+
+	const BlendFunc& SkeletonRenderer::getBlendFunc () const {
+		return _blendFunc;
+	}
+
+	void SkeletonRenderer::setBlendFunc (const BlendFunc &blendFunc) {
+		_blendFunc = blendFunc;
+	}
+
+	void SkeletonRenderer::setOpacityModifyRGB (bool value) {
+		_premultipliedAlpha = value;
+	}
+
+	bool SkeletonRenderer::isOpacityModifyRGB () const {
+		return _premultipliedAlpha;
+	}
+
+}
+
+#endif

+ 166 - 0
spine-cocos2dx/src/spine/v4/SkeletonRenderer.h

@@ -0,0 +1,166 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#ifndef SPINE_SKELETONRENDERER_H_
+#define SPINE_SKELETONRENDERER_H_
+
+#include "cocos2d.h"
+#if COCOS2D_VERSION >= 0x00040000
+
+#include <spine/spine.h>
+
+namespace spine {
+	
+	class AttachmentVertices;
+	
+	/* Draws a skeleton. */
+	class SkeletonRenderer: public cocos2d::Node, public cocos2d::BlendProtocol {
+	public:
+		CREATE_FUNC(SkeletonRenderer);
+		static SkeletonRenderer* createWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
+		static SkeletonRenderer* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
+		static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
+		static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
+		
+		virtual void update (float deltaTime) override;
+		virtual void draw (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags) override;
+		virtual void drawDebug (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags);
+		virtual cocos2d::Rect getBoundingBox () const override;
+		virtual void onEnter () override;
+		virtual void onExit () override;
+		
+		Skeleton* getSkeleton();
+		
+		void setTimeScale(float scale);
+		float getTimeScale() const;
+		
+		/*  */
+		void setDebugSlotsEnabled(bool enabled);
+		bool getDebugSlotsEnabled() const;
+		
+		void setDebugBonesEnabled(bool enabled);
+		bool getDebugBonesEnabled() const;
+		
+		void setDebugMeshesEnabled(bool enabled);
+		bool getDebugMeshesEnabled() const;
+		
+		// --- Convenience methods for common Skeleton_* functions.
+		void updateWorldTransform ();
+		
+		void setToSetupPose ();
+		void setBonesToSetupPose ();
+		void setSlotsToSetupPose ();
+		
+		/* Returns 0 if the bone was not found. */
+		Bone* findBone (const std::string& boneName) const;
+		/* Returns 0 if the slot was not found. */
+		Slot* findSlot (const std::string& slotName) const;
+		
+		/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
+		 * attached if the corresponding attachment from the old skin was attached.
+		 * @param skin May be empty string ("") for no skin.*/
+		void setSkin (const std::string& skinName);
+		/** @param skin May be 0 for no skin.*/
+		void setSkin (const char* skinName);
+		
+		/* Returns 0 if the slot or attachment was not found. */
+		Attachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const;
+		/* Returns false if the slot or attachment was not found.
+		 * @param attachmentName May be empty string ("") for no attachment. */
+		bool setAttachment (const std::string& slotName, const std::string& attachmentName);
+		/* @param attachmentName May be 0 for no attachment. */
+		bool setAttachment (const std::string& slotName, const char* attachmentName);
+		
+		/* Enables/disables two color tinting for this instance. May break batching */
+		void setTwoColorTint(bool enabled);
+		/* Whether two color tinting is enabled */
+		bool isTwoColorTint();
+		
+		/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
+		void setVertexEffect(VertexEffect* effect);
+		
+		/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
+		void setSlotsRange(int startSlotIndex, int endSlotIndex);
+		
+		// --- BlendProtocol
+		virtual void setBlendFunc (const cocos2d::BlendFunc& blendFunc)override;
+		virtual const cocos2d::BlendFunc& getBlendFunc () const override;
+		virtual void setOpacityModifyRGB (bool value) override;
+		virtual bool isOpacityModifyRGB () const override;
+		
+		// Frees global memory used for temporay vertex transformations.
+		static void destroyScratchBuffers();
+		
+	CC_CONSTRUCTOR_ACCESS:
+		SkeletonRenderer ();
+		SkeletonRenderer(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
+		SkeletonRenderer (SkeletonData* skeletonData, bool ownsSkeletonData = false);
+		SkeletonRenderer (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
+		SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
+		
+		virtual ~SkeletonRenderer ();
+		
+		void initWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
+		void initWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
+		void initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
+		void initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
+		void initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
+		void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
+		
+		virtual void initialize ();
+		
+	protected:
+		void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData);
+		void setupGLProgramState(bool twoColorTintEnabled);
+		
+		bool _ownsSkeletonData;
+		bool _ownsSkeleton;
+		bool _ownsAtlas;
+		Atlas* _atlas;
+		AttachmentLoader* _attachmentLoader;
+
+		cocos2d::BlendFunc _blendFunc;
+		bool _premultipliedAlpha;
+		Skeleton* _skeleton;
+		float _timeScale;
+		bool _debugSlots;
+		bool _debugBones;
+		bool _debugMeshes;
+		SkeletonClipping* _clipper;
+		VertexEffect* _effect;
+        bool _twoColorTintEnabled = false;
+		int _startSlotIndex;
+		int _endSlotIndex;
+	};
+	
+}
+
+#endif
+
+#endif /* SPINE_SKELETONRENDERER_H_ */

+ 403 - 0
spine-cocos2dx/src/spine/v4/SkeletonTwoColorBatch.cpp

@@ -0,0 +1,403 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#include <spine/spine-cocos2dx.h>
+#if COCOS2D_VERSION >= 0x00040000
+
+#include <spine/Extension.h>
+#include <algorithm>
+#include <stddef.h> // offsetof
+#include "base/ccTypes.h"
+#include "base/ccUtils.h"
+
+#include "xxhash.h"
+#include "renderer/ccShaders.h"
+#include "renderer/backend/Device.h"
+
+USING_NS_CC;
+#define EVENT_AFTER_DRAW_RESET_POSITION "director_after_draw"
+using std::max;
+#define INITIAL_SIZE (10000)
+#define MAX_VERTICES 64000
+#define MAX_INDICES 64000
+
+#define STRINGIFY(A)  #A
+
+namespace {
+
+    const char* TWO_COLOR_TINT_VERTEX_SHADER = STRINGIFY(
+    uniform mat4 u_PMatrix;
+    attribute vec4 a_position;
+    attribute vec4 a_color;
+    attribute vec4 a_color2;
+    attribute vec2 a_texCoords;
+
+    \n#ifdef GL_ES\n
+        varying lowp vec4 v_light;
+    varying lowp vec4 v_dark;
+    varying mediump vec2 v_texCoord;
+    \n#else\n
+        varying vec4 v_light;
+    varying vec4 v_dark;
+    varying vec2 v_texCoord;
+
+    \n#endif\n
+
+        void main() {
+        v_light = a_color;
+        v_dark = a_color2;
+        v_texCoord = a_texCoords;
+        gl_Position = u_PMatrix * a_position;
+    }
+    );
+
+    const char* TWO_COLOR_TINT_FRAGMENT_SHADER = STRINGIFY(
+        \n#ifdef GL_ES\n
+        precision lowp float;
+    \n#endif\n
+        uniform sampler2D u_texture;
+    varying vec4 v_light;
+    varying vec4 v_dark;
+    varying vec2 v_texCoord;
+
+    void main() {
+        vec4 texColor = texture2D(u_texture, v_texCoord);
+        float alpha = texColor.a * v_light.a;
+        gl_FragColor.a = alpha;
+        gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
+    }
+    );
+
+
+    std::shared_ptr<backend::ProgramState>  __twoColorProgramState = nullptr;
+    backend::UniformLocation                __locPMatrix;
+    backend::UniformLocation                __locTexture;
+
+    void initTwoColorProgramState()
+    {
+        if (__twoColorProgramState)
+        {
+            return;
+        }
+        auto program = backend::Device::getInstance()->newProgram(TWO_COLOR_TINT_VERTEX_SHADER, TWO_COLOR_TINT_FRAGMENT_SHADER);
+        auto* programState = new backend::ProgramState(program);
+        program->autorelease();
+
+        __locPMatrix = programState->getUniformLocation("u_PMatrix");
+        __locTexture = programState->getUniformLocation("u_texture");
+
+        auto layout = programState->getVertexLayout();
+
+        layout->setAttribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(spine::V3F_C4B_C4B_T2F, position), false);
+        layout->setAttribute("a_color", 1, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color), true);
+        layout->setAttribute("a_color2", 2, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color2), true);
+        layout->setAttribute("a_texCoords", 3, backend::VertexFormat::FLOAT2, offsetof(spine::V3F_C4B_C4B_T2F, texCoords), false);
+        layout->setLayout(sizeof(spine::V3F_C4B_C4B_T2F));
+
+        __twoColorProgramState = std::shared_ptr<backend::ProgramState>(programState);
+    }
+
+}
+
+namespace spine {
+
+TwoColorTrianglesCommand::TwoColorTrianglesCommand() :_materialID(0), _texture(nullptr), _blendType(BlendFunc::DISABLE) {
+	_type = RenderCommand::Type::CUSTOM_COMMAND;
+}
+
+void TwoColorTrianglesCommand::init(float globalOrder, cocos2d::Texture2D *texture, BlendFunc blendType, const TwoColorTriangles& triangles, const Mat4& mv, uint32_t flags) {
+
+    updateCommandPipelineDescriptor();
+    const cocos2d::Mat4& projectionMat = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
+
+    auto finalMatrix = projectionMat * mv;
+
+    _programState->setUniform(_locPMatrix, finalMatrix.m, sizeof(finalMatrix.m));
+    _programState->setTexture(_locTexture, 0, texture->getBackendTexture());
+
+
+    RenderCommand::init(globalOrder, mv, flags);
+
+    _triangles = triangles;
+    if (_triangles.indexCount % 3 != 0) {
+        int count = _triangles.indexCount;
+        _triangles.indexCount = count / 3 * 3;
+        CCLOGERROR("Resize indexCount from %d to %d, size must be multiple times of 3", count, _triangles.indexCount);
+    }
+
+    _mv = mv;
+
+    if (_blendType.src != blendType.src || _blendType.dst != blendType.dst ||
+        _texture != texture->getBackendTexture() || _pipelineDescriptor.programState != _programState)
+    {
+		_texture = texture->getBackendTexture();
+		_blendType = blendType;
+
+        _prog = _programState->getProgram();
+
+        auto& blendDescriptor = _pipelineDescriptor.blendDescriptor;
+        blendDescriptor.blendEnabled = true;
+        blendDescriptor.sourceRGBBlendFactor = blendDescriptor.sourceAlphaBlendFactor = blendType.src;
+        blendDescriptor.destinationRGBBlendFactor = blendDescriptor.destinationAlphaBlendFactor = blendType.dst;
+
+		generateMaterialID();
+	}
+}
+
+
+
+void TwoColorTrianglesCommand::updateCommandPipelineDescriptor()
+{
+    if (!__twoColorProgramState)
+    {
+        initTwoColorProgramState();
+    }
+
+    CC_SAFE_RELEASE_NULL(_programState);
+    _programState = __twoColorProgramState->clone();
+    _locPMatrix = __locPMatrix;
+    _locTexture = __locTexture;
+    _pipelineDescriptor.programState = _programState;
+}
+
+TwoColorTrianglesCommand::~TwoColorTrianglesCommand()
+{
+    CC_SAFE_RELEASE_NULL(_programState);
+}
+
+void TwoColorTrianglesCommand::generateMaterialID() {
+	// do not batch if using custom uniforms (since we cannot batch) it
+
+
+    struct
+    {
+        void* texture;
+        void* prog;
+        backend::BlendFactor src;
+        backend::BlendFactor dst;
+    }hashMe;
+
+    // NOTE: Initialize hashMe struct to make the value of padding bytes be filled with zero.
+    // It's important since XXH32 below will also consider the padding bytes which probably
+    // are set to random values by different compilers.
+    memset(&hashMe, 0, sizeof(hashMe));
+
+    hashMe.texture = _texture;
+    hashMe.src = _blendType.src;
+    hashMe.dst = _blendType.dst;
+    hashMe.prog = _prog;
+    _materialID = XXH32((const void*)&hashMe, sizeof(hashMe), 0);
+}
+
+
+void TwoColorTrianglesCommand::draw(Renderer *r) {
+	SkeletonTwoColorBatch::getInstance()->batch(r, this);
+}
+
+void TwoColorTrianglesCommand::updateVertexAndIndexBuffer(Renderer *r, V3F_C4B_C4B_T2F *vertices, int verticesSize, uint16_t *indices, int indicesSize)
+{
+    if(verticesSize != _vertexCapacity)
+        createVertexBuffer(sizeof(V3F_C4B_C4B_T2F), verticesSize, CustomCommand::BufferUsage::DYNAMIC);
+    if(indicesSize != _indexCapacity)
+        createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, indicesSize, CustomCommand::BufferUsage::DYNAMIC);
+
+    updateVertexBuffer(vertices, sizeof(V3F_C4B_C4B_T2F) * verticesSize);
+    updateIndexBuffer(indices, sizeof(uint16_t) * indicesSize);
+}
+
+
+static SkeletonTwoColorBatch* instance = nullptr;
+
+SkeletonTwoColorBatch* SkeletonTwoColorBatch::getInstance () {
+	if (!instance) instance = new SkeletonTwoColorBatch();
+	return instance;
+}
+
+void SkeletonTwoColorBatch::destroyInstance () {
+	if (instance) {
+		delete instance;
+		instance = nullptr;
+	}
+}
+
+SkeletonTwoColorBatch::SkeletonTwoColorBatch () : _vertexBuffer(0), _indexBuffer(0) {
+    _commandsPool.reserve(INITIAL_SIZE);
+	for (unsigned int i = 0; i < INITIAL_SIZE; i++) {
+		_commandsPool.push_back(new TwoColorTrianglesCommand());
+	}
+
+	reset ();
+
+	// callback after drawing is finished so we can clear out the batch state
+	// for the next frame
+	Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom* eventCustom){
+		this->update(0);
+	});
+
+}
+
+SkeletonTwoColorBatch::~SkeletonTwoColorBatch () {
+	Director::getInstance()->getEventDispatcher()->removeCustomEventListeners(EVENT_AFTER_DRAW_RESET_POSITION);
+
+	for (unsigned int i = 0; i < _commandsPool.size(); i++) {
+		delete _commandsPool[i];
+		_commandsPool[i] = nullptr;
+	}
+
+	delete[] _vertexBuffer;
+	delete[] _indexBuffer;
+}
+
+void SkeletonTwoColorBatch::update (float delta) {
+	reset();
+}
+
+V3F_C4B_C4B_T2F* SkeletonTwoColorBatch::allocateVertices(uint32_t numVertices) {
+	if (_vertices.size() - _numVertices < numVertices) {
+		V3F_C4B_C4B_T2F* oldData = _vertices.data();
+		_vertices.resize((_vertices.size() + numVertices) * 2 + 1);
+		V3F_C4B_C4B_T2F* newData = _vertices.data();
+		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
+			TwoColorTrianglesCommand* command = _commandsPool[i];
+			TwoColorTriangles& triangles = (TwoColorTriangles&)command->getTriangles();
+			triangles.verts = newData + (triangles.verts - oldData);
+		}
+	}
+
+	V3F_C4B_C4B_T2F* vertices = _vertices.data() + _numVertices;
+	_numVertices += numVertices;
+	return vertices;
+}
+
+
+void SkeletonTwoColorBatch::deallocateVertices(uint32_t numVertices) {
+	_numVertices -= numVertices;
+}
+
+
+unsigned short* SkeletonTwoColorBatch::allocateIndices(uint32_t numIndices) {
+	if (_indices.getCapacity() - _indices.size() < numIndices) {
+		unsigned short* oldData = _indices.buffer();
+		int oldSize =_indices.size();
+		_indices.ensureCapacity(_indices.size() + numIndices);
+		unsigned short* newData = _indices.buffer();
+		for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
+			TwoColorTrianglesCommand* command = _commandsPool[i];
+			TwoColorTriangles& triangles = (TwoColorTriangles&)command->getTriangles();
+			if (triangles.indices >= oldData && triangles.indices < oldData + oldSize) {
+				triangles.indices = newData + (triangles.indices - oldData);
+			}
+		}
+	}
+
+	unsigned short* indices = _indices.buffer() + _indices.size();
+	_indices.setSize(_indices.size() + numIndices, 0);
+	return indices;
+}
+
+void SkeletonTwoColorBatch::deallocateIndices(uint32_t numIndices) {
+	_indices.setSize(_indices.size() - numIndices, 0);
+}
+
+TwoColorTrianglesCommand* SkeletonTwoColorBatch::addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::BlendFunc blendType, const TwoColorTriangles& triangles, const cocos2d::Mat4& mv, uint32_t flags) {
+	TwoColorTrianglesCommand* command = nextFreeCommand();
+	command->init(globalOrder, texture, blendType, triangles, mv, flags);
+    command->updateVertexAndIndexBuffer(renderer, triangles.verts, triangles.vertCount, triangles.indices, triangles.indexCount);
+	renderer->addCommand(command);
+	return command;
+}
+
+void SkeletonTwoColorBatch::batch (cocos2d::Renderer *renderer, TwoColorTrianglesCommand* command) {
+	if (_numVerticesBuffer + command->getTriangles().vertCount >= MAX_VERTICES || _numIndicesBuffer + command->getTriangles().indexCount >= MAX_INDICES) {
+		flush(renderer, _lastCommand);
+	}
+
+	uint32_t materialID = command->getMaterialID();
+	if (_lastCommand && _lastCommand->getMaterialID() != materialID) {
+		flush(renderer, _lastCommand);
+	}
+
+	memcpy(_vertexBuffer + _numVerticesBuffer, command->getTriangles().verts, sizeof(V3F_C4B_C4B_T2F) * command->getTriangles().vertCount);
+	const Mat4& modelView = command->getModelView();
+	for (int i = _numVerticesBuffer; i < _numVerticesBuffer + command->getTriangles().vertCount; i++) {
+		modelView.transformPoint(&_vertexBuffer[i].position);
+	}
+
+	unsigned short vertexOffset = (unsigned short)_numVerticesBuffer;
+	unsigned short* indices = command->getTriangles().indices;
+	for (int i = 0, j = _numIndicesBuffer; i < command->getTriangles().indexCount; i++, j++) {
+		_indexBuffer[j] = indices[i] + vertexOffset;
+	}
+
+	_numVerticesBuffer += command->getTriangles().vertCount;
+	_numIndicesBuffer += command->getTriangles().indexCount;
+
+	if (command->isForceFlush()) {
+		flush(renderer, command);
+	}
+	_lastCommand = command;
+}
+
+void SkeletonTwoColorBatch::flush (cocos2d::Renderer *renderer, TwoColorTrianglesCommand* materialCommand) {
+	if (!materialCommand)
+		return;
+
+    materialCommand->updateVertexAndIndexBuffer(renderer, _vertexBuffer, _numVerticesBuffer, _indexBuffer, _numIndicesBuffer);
+
+    renderer->addCommand(materialCommand);
+
+    _numVerticesBuffer = 0;
+	_numIndicesBuffer = 0;
+	_numBatches++;
+}
+
+void SkeletonTwoColorBatch::reset() {
+	_nextFreeCommand = 0;
+	_numVertices = 0;
+	_indices.setSize(0, 0);
+	_numVerticesBuffer = 0;
+	_numIndicesBuffer = 0;
+	_lastCommand = nullptr;
+	_numBatches = 0;
+}
+
+TwoColorTrianglesCommand* SkeletonTwoColorBatch::nextFreeCommand() {
+	if (_commandsPool.size() <= _nextFreeCommand) {
+		unsigned int newSize = _commandsPool.size() * 2 + 1;
+		for (int i = _commandsPool.size();  i < newSize; i++) {
+			_commandsPool.push_back(new TwoColorTrianglesCommand());
+		}
+	}
+	TwoColorTrianglesCommand* command = _commandsPool[_nextFreeCommand++];
+	command->setForceFlush(false);
+	return command;
+}
+}
+
+#endif

+ 165 - 0
spine-cocos2dx/src/spine/v4/SkeletonTwoColorBatch.h

@@ -0,0 +1,165 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated May 1, 2019. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2019, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
+ * INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#ifndef SPINE_SKELETONTWOCOLORBATCH_H_
+#define SPINE_SKELETONTWOCOLORBATCH_H_
+
+#include "cocos2d.h"
+#if COCOS2D_VERSION >= 0x00040000
+
+#include <spine/spine.h>
+#include <vector>
+
+namespace spine {
+	struct V3F_C4B_C4B_T2F {
+		cocos2d::Vec3 position;
+		cocos2d::Color4B color;
+		cocos2d::Color4B color2;
+		cocos2d::Tex2F texCoords;
+	};
+	
+	struct TwoColorTriangles {
+		V3F_C4B_C4B_T2F* verts;
+		unsigned short* indices;
+		int vertCount;
+		int indexCount;
+	};
+	
+	class TwoColorTrianglesCommand : public cocos2d::CustomCommand {
+	public:
+		TwoColorTrianglesCommand();
+		
+		~TwoColorTrianglesCommand();
+
+        void init(float globalOrder, cocos2d::Texture2D* texture, cocos2d::BlendFunc blendType, const TwoColorTriangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
+
+        void updateCommandPipelineDescriptor();
+
+        inline cocos2d::backend::TextureBackend* getTexture() const { return _texture; }
+
+        void draw(cocos2d::Renderer *renderer);
+
+        void updateVertexAndIndexBuffer(cocos2d::Renderer *renderer, V3F_C4B_C4B_T2F *vertices, int verticesSize, uint16_t *indices, int indicesSize);
+		
+		inline uint32_t getMaterialID() const { return _materialID; }
+		
+		inline const TwoColorTriangles& getTriangles() const { return _triangles; }
+		
+		inline ssize_t getVertexCount() const { return _triangles.vertCount; }
+		
+		inline ssize_t getIndexCount() const { return _triangles.indexCount; }
+		
+		inline const V3F_C4B_C4B_T2F* getVertices() const { return _triangles.verts; }
+		
+		inline const unsigned short* getIndices() const { return _triangles.indices; }
+		
+		inline cocos2d::BlendFunc getBlendType() const { return _blendType; }
+		
+		inline const cocos2d::Mat4& getModelView() const { return _mv; }
+		
+		void setForceFlush (bool forceFlush) { _forceFlush = forceFlush; }
+		
+		bool isForceFlush () { return _forceFlush; };
+		
+	protected:
+		void generateMaterialID();
+		uint32_t _materialID;
+
+
+        void *_prog = nullptr;
+        cocos2d::backend::TextureBackend    *_texture       = nullptr;
+        cocos2d::backend::ProgramState      *_programState  = nullptr;
+        cocos2d::backend::UniformLocation   _locPMatrix;
+        cocos2d::backend::UniformLocation   _locTexture;
+
+		cocos2d::BlendFunc  _blendType;
+		TwoColorTriangles   _triangles;
+		cocos2d::Mat4       _mv;
+		bool                _forceFlush;
+	};
+
+    class SkeletonTwoColorBatch {
+    public:
+        static SkeletonTwoColorBatch* getInstance ();
+
+        static void destroyInstance ();
+
+        void update (float delta);
+
+		V3F_C4B_C4B_T2F* allocateVertices(uint32_t numVertices);
+		void deallocateVertices(uint32_t numVertices);
+		
+		unsigned short* allocateIndices(uint32_t numIndices);
+		void deallocateIndices(uint32_t numIndices);
+
+        TwoColorTrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::BlendFunc blendType, const TwoColorTriangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
+
+        void batch(cocos2d::Renderer* renderer, TwoColorTrianglesCommand* command);
+
+        void flush(cocos2d::Renderer* renderer, TwoColorTrianglesCommand* materialCommand);
+
+		uint32_t getNumBatches () { return _numBatches; };
+		
+    protected:
+        SkeletonTwoColorBatch ();
+        virtual ~SkeletonTwoColorBatch ();
+
+		void reset ();
+
+		TwoColorTrianglesCommand* nextFreeCommand ();
+
+		// pool of commands
+		std::vector<TwoColorTrianglesCommand*> _commandsPool;
+		uint32_t _nextFreeCommand;
+
+		// pool of vertices
+		std::vector<V3F_C4B_C4B_T2F> _vertices;
+		uint32_t _numVertices;
+		
+		// pool of indices
+		Vector<unsigned short> _indices;
+		
+		
+		// VBO handles & attribute locations
+		V3F_C4B_C4B_T2F* _vertexBuffer;
+		uint32_t _numVerticesBuffer;
+        uint32_t _numIndicesBuffer;
+        unsigned short* _indexBuffer;
+
+		// last batched command, needed for flushing to set material
+		TwoColorTrianglesCommand* _lastCommand = nullptr;
+
+		// number of batches in the last frame
+		uint32_t _numBatches;
+	};
+}
+
+#endif
+
+#endif // SPINE_SKELETONTWOCOLORBATCH_H_