diff --git a/CHANGELOG.md b/CHANGELOG.md index 19370ecb1..5dba66c5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -164,6 +164,7 @@ ### Cocos2d-x * Updated to cocos2d-x 3.17.1 * Added mix-and-match example to demonstrate the new Skin API. +* Exmaple project requires Visual Studio 2019 on Windows ### SFML * Added mix-and-match example to demonstrate the new Skin API. diff --git a/spine-cocos2dx/README.md b/spine-cocos2dx/README.md index 73512debd..bc6293a26 100644 --- a/spine-cocos2dx/README.md +++ b/spine-cocos2dx/README.md @@ -33,15 +33,16 @@ The setup for cocos2d-x differs from most other Spine Runtimes because the cocos The Spine cocos2d-x example works on Windows, Mac OS X, iOS and Android. ### Windows -1. Install [Visual Studio 2015 Community](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) +1. Install [Visual Studio 2019 Community](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) 2. Install CMake via the [Windows installer package](https://cmake.org/download/). 3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above. 4. Run CMake GUI from the start menu 5. Click `Browse Source` and select the directory `spine-runtimes` 6. Click `Browse Build` and select the `spine-runtimes/spine-cocos2dx/build` directory. You can create the `build` folder directly in the file dialog via `New Folder`. -7. Click `Configure`. This will download the cocos2d-x dependency and wire it up with the example source code in `spine-runtimes/spine-cocos2dx/example`. The download is 400mb, so get yourself a cup of tea. +7. Click `Configure`. Check `SPINE_COCOS2D_X` +8. Click `Configure` again. This will download the cocos2d-x dependency and wire it up with the example source code in `spine-runtimes/spine-cocos2dx/example`. The download is 400mb, so get yourself a cup of tea. 7. Open the file `spine-cocos2dx\example\cocos2d\cocos\2d\cocos2dx.props` and remove the `libSpine.lib` entry from the `` tag. -8. Open the `spine-runtimes/spine-cocos2dx/example/proj.win32/spine-cocos2d-x.sln` file in Visual Studio 2015. Visual Studio may ask you to install the Windows XP/7 SDK, which you should install. +8. Open the `spine-runtimes/spine-cocos2dx/example/proj.win32/spine-cocos2d-x.sln` file in Visual Studio 2019. Visual Studio may ask you to install the Windows XP/7 SDK, which you should install. 9. Expand `References` of the libcocos2d sub project, and remove the entry for `libSpine`, which should be marked with an error. 9. Right click the `spine-cocos2d-x` project in the solution explorer and select `Set as Startup Project` from the context menu 10. Click `Local Windows Debugger` to run the example diff --git a/spine-cocos2dx/example/Classes/AppDelegate.cpp b/spine-cocos2dx/example/Classes/AppDelegate.cpp index 3775a9893..dcade70a0 100644 --- a/spine-cocos2dx/example/Classes/AppDelegate.cpp +++ b/spine-cocos2dx/example/Classes/AppDelegate.cpp @@ -112,7 +112,7 @@ bool AppDelegate::applicationDidFinishLaunching () { // create a scene. it's an autorelease object //auto scene = RaptorExample::scene(); - auto scene = MixAndMatchExample::scene(); + auto scene = BatchingExample::scene(); // run director->runWithScene(scene); diff --git a/spine-cpp/spine-cpp/include/spine/Debug.h b/spine-cpp/spine-cpp/include/spine/Debug.h index 13c3213ec..04768a31b 100644 --- a/spine-cpp/spine-cpp/include/spine/Debug.h +++ b/spine-cpp/spine-cpp/include/spine/Debug.h @@ -63,12 +63,14 @@ public: void clearAllocations() { _allocated.clear(); + _usedMemory = 0; } virtual void *_alloc(size_t size, const char *file, int line) { void *result = _extension->_alloc(size, file, line); _allocated[result] = Allocation(result, size, file, line); _allocations++; + _usedMemory += size; return result; } @@ -76,14 +78,17 @@ public: void *result = _extension->_calloc(size, file, line); _allocated[result] = Allocation(result, size, file, line); _allocations++; + _usedMemory += size; return result; } virtual void *_realloc(void *ptr, size_t size, const char *file, int line) { + if (_allocated.count(ptr)) _usedMemory -= _allocated[ptr].size; _allocated.erase(ptr); void *result = _extension->_realloc(ptr, size, file, line); _reallocations++; _allocated[result] = Allocation(result, size, file, line); + _usedMemory += size; return result; } @@ -91,6 +96,7 @@ public: if (_allocated.count(mem)) { _extension->_free(mem, file, line); _frees++; + _usedMemory -= _allocated[mem].size; _allocated.erase(mem); return; } @@ -102,6 +108,10 @@ public: virtual char *_readFile(const String &path, int *length) { return _extension->_readFile(path, length); } + + size_t getUsedMemory() { + return _usedMemory; + } private: SpineExtension* _extension; @@ -109,6 +119,7 @@ private: size_t _allocations; size_t _reallocations; size_t _frees; + size_t _usedMemory; }; } diff --git a/spine-cpp/spine-cpp/src/spine/Animation.cpp b/spine-cpp/spine-cpp/src/spine/Animation.cpp index d94579510..4ac7b2a71 100644 --- a/spine-cpp/spine-cpp/src/spine/Animation.cpp +++ b/spine-cpp/spine-cpp/src/spine/Animation.cpp @@ -38,6 +38,8 @@ #include +#include + using namespace spine; Animation::Animation(const String &name, Vector &timelines, float duration) : diff --git a/spine-cpp/spine-cpp/src/spine/SpineObject.cpp b/spine-cpp/spine-cpp/src/spine/SpineObject.cpp index fdcdc49bf..98e8dc6f8 100644 --- a/spine-cpp/spine-cpp/src/spine/SpineObject.cpp +++ b/spine-cpp/spine-cpp/src/spine/SpineObject.cpp @@ -36,11 +36,11 @@ using namespace spine; void *SpineObject::operator new(size_t sz) { - return SpineExtension::calloc(sz, __FILE__, __LINE__); + return SpineExtension::getInstance()->_calloc(sz, __FILE__, __LINE__); } void *SpineObject::operator new(size_t sz, const char *file, int line) { - return SpineExtension::calloc(sz, file, line); + return SpineExtension::getInstance()->_calloc(sz, file, line); } void *SpineObject::operator new(size_t sz, void *ptr) {