diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp index 952404bddb..448a68b47b 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp @@ -81,7 +81,8 @@ static std::function createFunctions[] = { CL(Issue1288), CL(Issue1288_2), CL(Issue1327), - CL(Issue1398) + CL(Issue1398), + CL(Issue2599) }; static int sceneIdx=-1; @@ -2094,6 +2095,38 @@ std::string Issue1398::title() const return "Issue 1398"; } +void Issue2599::onEnter() +{ + ActionsDemo::onEnter(); + this->centerSprites(0); + + _count = 0; + log("before: count = %d", _count); + + log("start count up 50 times using Repeat action"); + auto delay = 1.0f / 50; + auto repeatAction = Repeat::create( + Sequence::createWithTwoActions( + CallFunc::create([&](){ this->_count++; }), + DelayTime::create(delay)), + 50); + this->runAction( + Sequence::createWithTwoActions( + repeatAction, + CallFunc::create([&]() { log("after: count = %d", this->_count); }) + )); +} + +std::string Issue2599::subtitle() const +{ + return "See console: You should see '50'"; +} + +std::string Issue2599::title() const +{ + return "Issue 2599"; +} + /** ActionCatmullRom */ void ActionCatmullRom::onEnter() diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h index 7aa1de92ca..dafad5c774 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h @@ -564,6 +564,18 @@ private: int _testInteger; }; +class Issue2599 : public ActionsDemo +{ +public: + CREATE_FUNC(Issue2599); + + virtual void onEnter() override; + virtual std::string subtitle() const override; + virtual std::string title() const override; +private: + int _count; +}; + class ActionCatmullRom : public ActionsDemo { public: