axmol/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp

1151 lines
29 KiB
C++
Raw Normal View History

2010-09-09 16:15:21 +08:00
#include "SchedulerTest.h"
#include "../testResource.h"
USING_NS_CC;
2015-04-09 12:23:47 +08:00
USING_NS_CC_EXT;
2010-09-09 16:15:21 +08:00
enum {
kTagAnimationDance = 1,
2010-09-09 16:15:21 +08:00
};
SchedulerTests::SchedulerTests()
{
ADD_TEST_CASE(SchedulerTimeScale);
ADD_TEST_CASE(TwoSchedulers);
ADD_TEST_CASE(SchedulerAutoremove);
ADD_TEST_CASE(SchedulerPauseResume);
ADD_TEST_CASE(SchedulerPauseResumeAll);
ADD_TEST_CASE(SchedulerPauseResumeAllUser);
ADD_TEST_CASE(SchedulerUnscheduleAll);
ADD_TEST_CASE(SchedulerUnscheduleAllHard);
ADD_TEST_CASE(SchedulerUnscheduleAllUserLevel);
ADD_TEST_CASE(SchedulerSchedulesAndRemove);
ADD_TEST_CASE(SchedulerUpdate);
ADD_TEST_CASE(SchedulerUpdateAndCustom);
ADD_TEST_CASE(SchedulerUpdateFromCustom);
ADD_TEST_CASE(RescheduleSelector);
ADD_TEST_CASE(SchedulerDelayAndRepeat);
ADD_TEST_CASE(SchedulerIssue2268);
ADD_TEST_CASE(ScheduleCallbackTest);
ADD_TEST_CASE(ScheduleUpdatePriority);
ADD_TEST_CASE(SchedulerIssue10232);
};
2011-07-08 15:57:46 +08:00
2010-09-09 16:15:21 +08:00
//------------------------------------------------------------------
//
// SchedulerAutoremove
//
//------------------------------------------------------------------
void SchedulerAutoremove::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(CC_SCHEDULE_SELECTOR(SchedulerAutoremove::autoremove), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerAutoremove::tick), 0.5f);
2010-09-09 16:15:21 +08:00
accum = 0;
}
2012-06-08 13:55:28 +08:00
void SchedulerAutoremove::autoremove(float dt)
2010-09-09 16:15:21 +08:00
{
accum += dt;
CCLOG("Time: %f", accum);
2010-09-09 16:15:21 +08:00
if( accum > 3 )
{
unschedule(CC_SCHEDULE_SELECTOR(SchedulerAutoremove::autoremove));
CCLOG("scheduler removed");
2010-09-09 16:15:21 +08:00
}
}
2012-06-08 13:55:28 +08:00
void SchedulerAutoremove::tick(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("This scheduler should not be removed");
2010-09-09 16:15:21 +08:00
}
std::string SchedulerAutoremove::title() const
2010-09-09 16:15:21 +08:00
{
return "Self-remove an scheduler";
}
std::string SchedulerAutoremove::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "1 scheduler will be autoremoved in 3 seconds. See console";
}
//------------------------------------------------------------------
//
// SchedulerPauseResume
//
//------------------------------------------------------------------
void SchedulerPauseResume::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResume::tick1), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResume::tick2), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResume::pause), 3.0f);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerPauseResume::tick1(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick1");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerPauseResume::tick2(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick2");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerPauseResume::pause(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("paused, tick1 and tick2 should called six times");
Director::getInstance()->getScheduler()->pauseTarget(this);
2010-09-09 16:15:21 +08:00
}
std::string SchedulerPauseResume::title() const
2010-09-09 16:15:21 +08:00
{
return "Pause / Resume";
}
std::string SchedulerPauseResume::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "Scheduler should be paused after 3 seconds. See console";
}
2012-06-12 18:12:45 +08:00
//------------------------------------------------------------------
//
// SchedulerPauseResumeAll
//
//------------------------------------------------------------------
SchedulerPauseResumeAll::SchedulerPauseResumeAll()
{
}
SchedulerPauseResumeAll::~SchedulerPauseResumeAll()
{
2013-12-07 14:28:37 +08:00
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAll::onEnter()
{
2012-11-15 18:34:23 +08:00
SchedulerTestLayer::onEnter();
auto sprite = Sprite::create("Images/grossinis_sister1.png");
2012-11-15 18:34:23 +08:00
sprite->setPosition(VisibleRect::center());
this->addChild(sprite);
sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360)));
sprite->setTag(123);
2012-11-20 16:24:27 +08:00
scheduleUpdate();
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAll::tick1), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAll::tick2), 1.0f);
scheduleOnce(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAll::pause), 3.0f);
2012-11-20 16:24:27 +08:00
}
void SchedulerPauseResumeAll::update(float delta)
{
// do nothing
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAll::onExit()
{
2013-12-07 14:28:37 +08:00
if (!_pausedTargets.empty())
2012-11-15 18:34:23 +08:00
{
Director::getInstance()->getScheduler()->resumeTargets(_pausedTargets);
2012-06-12 18:12:45 +08:00
}
SchedulerTestLayer::onExit();
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAll::tick1(float dt)
{
log("tick1");
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAll::tick2(float dt)
{
log("tick2");
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAll::pause(float dt)
{
log("Pausing, tick1 should be called six times and tick2 three times");
auto scheduler = Director::getInstance()->getScheduler();
_pausedTargets = scheduler->pauseAllTargets();
// should have only 2 items: ActionManager, self
CCASSERT(_pausedTargets.size() == 2, "Error: pausedTargets should have only 2 items");
// because target 'this' has been paused above, so use another node(tag:123) as target
getChildByTag(123)->scheduleOnce([this](float dt)
{
this->resume(dt);
}, 2.0f, "test resume");
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAll::resume(float dt)
{
log("Resuming");
auto director = Director::getInstance();
director->getScheduler()->resumeTargets(_pausedTargets);
2013-12-07 14:28:37 +08:00
_pausedTargets.clear();
2012-06-12 18:12:45 +08:00
}
std::string SchedulerPauseResumeAll::title() const
2012-06-12 18:12:45 +08:00
{
return "Pause / Resume All";
2012-06-12 18:12:45 +08:00
}
std::string SchedulerPauseResumeAll::subtitle() const
2012-06-12 18:12:45 +08:00
{
return "Everything will pause after 3s, then resume at 5s. See console";
}
2012-11-15 18:34:23 +08:00
2012-06-12 18:12:45 +08:00
//------------------------------------------------------------------
//
// SchedulerPauseResumeAllUser
//
//------------------------------------------------------------------
SchedulerPauseResumeAllUser::SchedulerPauseResumeAllUser()
{
}
SchedulerPauseResumeAllUser::~SchedulerPauseResumeAllUser()
{
2013-12-07 14:28:37 +08:00
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAllUser::onEnter()
{
SchedulerTestLayer::onEnter();
auto s = Director::getInstance()->getWinSize();
2012-11-15 18:34:23 +08:00
auto sprite = Sprite::create("Images/grossinis_sister1.png");
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sprite->setPosition(Vec2(s.width/2, s.height/2));
sprite->setTag(123);
2012-11-15 18:34:23 +08:00
this->addChild(sprite);
sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360)));
2012-06-12 18:12:45 +08:00
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAllUser::tick1), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAllUser::tick2), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerPauseResumeAllUser::pause), 3.0f, false, 0);
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAllUser::onExit()
{
2013-12-07 14:28:37 +08:00
if (!_pausedTargets.empty())
2012-11-15 18:34:23 +08:00
{
Director::getInstance()->getScheduler()->resumeTargets(_pausedTargets);
2012-06-12 18:12:45 +08:00
}
SchedulerTestLayer::onExit();
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAllUser::tick1(float dt)
{
log("tick1");
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAllUser::tick2(float dt)
{
log("tick2");
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAllUser::pause(float dt)
{
log("Pausing, tick1 and tick2 should be called three times");
auto director = Director::getInstance();
_pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
// because target 'this' has been paused above, so use another node(tag:123) as target
getChildByTag(123)->scheduleOnce([this](float dt)
{
this->resume(dt);
}, 2.0f, "test resume");
2012-06-12 18:12:45 +08:00
}
void SchedulerPauseResumeAllUser::resume(float dt)
{
log("Resuming");
getScheduler()->resumeTargets(_pausedTargets);
2013-12-07 14:28:37 +08:00
_pausedTargets.clear();
2012-06-12 18:12:45 +08:00
}
std::string SchedulerPauseResumeAllUser::title() const
2012-06-12 18:12:45 +08:00
{
return "Pause / Resume All User scheduler";
2012-06-12 18:12:45 +08:00
}
std::string SchedulerPauseResumeAllUser::subtitle() const
2012-06-12 18:12:45 +08:00
{
return "ticks will pause after 3s, then resume at 5s. See console";
2012-06-12 18:12:45 +08:00
}
2010-09-09 16:15:21 +08:00
//------------------------------------------------------------------
//
// SchedulerUnscheduleAll
//
//------------------------------------------------------------------
void SchedulerUnscheduleAll::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAll::tick1), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAll::tick2), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAll::tick3), 1.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAll::tick4), 1.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAll::unscheduleAll), 4);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAll::tick1(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick1");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAll::tick2(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick2");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAll::tick3(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick3");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAll::tick4(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick4");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAll::unscheduleAll(float dt)
2010-09-09 16:15:21 +08:00
{
unscheduleAllCallbacks();
2010-09-09 16:15:21 +08:00
}
std::string SchedulerUnscheduleAll::title() const
2010-09-09 16:15:21 +08:00
{
return "Unschedule All selectors";
}
std::string SchedulerUnscheduleAll::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "All scheduled selectors will be unscheduled in 4 seconds. See console";
}
//------------------------------------------------------------------
//
// SchedulerUnscheduleAllHard
//
//------------------------------------------------------------------
void SchedulerUnscheduleAllHard::onEnter()
{
SchedulerTestLayer::onEnter();
auto s = Director::getInstance()->getWinSize();
2012-11-15 18:34:23 +08:00
auto sprite = Sprite::create("Images/grossinis_sister1.png");
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sprite->setPosition(Vec2(s.width/2, s.height/2));
2012-11-15 18:34:23 +08:00
this->addChild(sprite);
sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360)));
2012-11-15 18:34:23 +08:00
_actionManagerActive = true;
2012-06-12 18:12:45 +08:00
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllHard::tick1), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllHard::tick2), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllHard::tick3), 1.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllHard::tick4), 1.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllHard::unscheduleAll), 4);
2010-09-09 16:15:21 +08:00
}
2012-06-12 18:12:45 +08:00
void SchedulerUnscheduleAllHard::onExit()
{
if(!_actionManagerActive) {
2012-11-15 18:34:23 +08:00
// Restore the director's action manager.
auto director = Director::getInstance();
director->getScheduler()->scheduleUpdate(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false);
2012-06-12 18:12:45 +08:00
}
SchedulerTestLayer::onExit();
2012-06-12 18:12:45 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAllHard::tick1(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick1");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAllHard::tick2(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick2");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAllHard::tick3(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick3");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAllHard::tick4(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick4");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUnscheduleAllHard::unscheduleAll(float dt)
2010-09-09 16:15:21 +08:00
{
Director::getInstance()->getScheduler()->unscheduleAll();
_actionManagerActive = false;
2010-09-09 16:15:21 +08:00
}
std::string SchedulerUnscheduleAllHard::title() const
2010-09-09 16:15:21 +08:00
{
2012-06-12 18:12:45 +08:00
return "Unschedule All selectors (HARD)";
2010-09-09 16:15:21 +08:00
}
std::string SchedulerUnscheduleAllHard::subtitle() const
2010-09-09 16:15:21 +08:00
{
2012-06-12 18:12:45 +08:00
return "Unschedules all user selectors after 4s. Action will stop. See console";
}
//------------------------------------------------------------------
//
// SchedulerUnscheduleAllUserLevel
//
//------------------------------------------------------------------
void SchedulerUnscheduleAllUserLevel::onEnter()
{
SchedulerTestLayer::onEnter();
auto s = Director::getInstance()->getWinSize();
2012-11-15 18:34:23 +08:00
auto sprite = Sprite::create("Images/grossinis_sister1.png");
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sprite->setPosition(Vec2(s.width/2, s.height/2));
2012-11-15 18:34:23 +08:00
this->addChild(sprite);
sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360)));
2012-06-12 18:12:45 +08:00
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::tick1), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::tick2), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::tick3), 1.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::tick4), 1.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerUnscheduleAllUserLevel::unscheduleAll), 4);
2012-06-12 18:12:45 +08:00
}
void SchedulerUnscheduleAllUserLevel::tick1(float dt)
{
CCLOG("tick1");
}
void SchedulerUnscheduleAllUserLevel::tick2(float dt)
{
CCLOG("tick2");
}
void SchedulerUnscheduleAllUserLevel::tick3(float dt)
{
CCLOG("tick3");
}
void SchedulerUnscheduleAllUserLevel::tick4(float dt)
{
CCLOG("tick4");
}
void SchedulerUnscheduleAllUserLevel::unscheduleAll(float dt)
{
Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
2012-06-12 18:12:45 +08:00
}
std::string SchedulerUnscheduleAllUserLevel::title() const
2012-06-12 18:12:45 +08:00
{
return "Unschedule All user selectors";
}
std::string SchedulerUnscheduleAllUserLevel::subtitle() const
2012-06-12 18:12:45 +08:00
{
return "Unschedules all user selectors after 4s. Action should not stop. See console";
2010-09-09 16:15:21 +08:00
}
//------------------------------------------------------------------
//
// SchedulerSchedulesAndRemove
//
//------------------------------------------------------------------
void SchedulerSchedulesAndRemove::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::tick1), 0.5f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::tick2), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::scheduleAndUnschedule), 4.0f);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerSchedulesAndRemove::tick1(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick1");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerSchedulesAndRemove::tick2(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick2");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerSchedulesAndRemove::tick3(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick3");
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerSchedulesAndRemove::tick4(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("tick4");
2010-09-09 16:15:21 +08:00
}
std::string SchedulerSchedulesAndRemove::title() const
2010-09-09 16:15:21 +08:00
{
return "Schedule from Schedule";
}
std::string SchedulerSchedulesAndRemove::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "Will unschedule and schedule selectors in 4s. See console";
}
2012-06-08 13:55:28 +08:00
void SchedulerSchedulesAndRemove::scheduleAndUnschedule(float dt)
2010-09-09 16:15:21 +08:00
{
unschedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::tick1));
unschedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::tick2));
unschedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::scheduleAndUnschedule));
2010-09-09 16:15:21 +08:00
schedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::tick3), 1.0f);
schedule(CC_SCHEDULE_SELECTOR(SchedulerSchedulesAndRemove::tick4), 1.0f);
2010-09-09 16:15:21 +08:00
}
//------------------------------------------------------------------
//
// TestNode
//
//------------------------------------------------------------------
2013-12-18 16:03:07 +08:00
void TestNode::initWithString(const std::string& str, int priority)
2010-09-09 16:15:21 +08:00
{
2013-12-18 16:03:07 +08:00
_string = str;
2010-09-09 16:15:21 +08:00
scheduleUpdateWithPriority(priority);
}
TestNode::~TestNode()
{
}
void TestNode::update(float dt)
{
CC_UNUSED_PARAM(dt);
2013-12-18 16:03:07 +08:00
log("%s", _string.c_str());
}
2010-09-09 16:15:21 +08:00
//------------------------------------------------------------------
//
// SchedulerUpdate
//
//------------------------------------------------------------------
void SchedulerUpdate::onEnter()
{
SchedulerTestLayer::onEnter();
auto d = new (std::nothrow) TestNode();
2013-12-18 16:03:07 +08:00
d->initWithString("---", 50);
2010-09-09 16:15:21 +08:00
addChild(d);
d->release();
auto b = new (std::nothrow) TestNode();
2013-12-18 16:03:07 +08:00
b->initWithString("3rd", 0);
2010-09-09 16:15:21 +08:00
addChild(b);
b->release();
auto a = new (std::nothrow) TestNode();
2013-12-18 16:03:07 +08:00
a->initWithString("1st", -10);
2010-09-09 16:15:21 +08:00
addChild(a);
a->release();
auto c = new (std::nothrow) TestNode();
2013-12-18 16:03:07 +08:00
c->initWithString("4th", 10);
2010-09-09 16:15:21 +08:00
addChild(c);
c->release();
auto e = new (std::nothrow) TestNode();
2013-12-18 16:03:07 +08:00
e->initWithString("5th", 20);
2010-09-09 16:15:21 +08:00
addChild(e);
e->release();
auto f = new (std::nothrow) TestNode();
2013-12-18 16:03:07 +08:00
f->initWithString("2nd", -5);
2010-09-09 16:15:21 +08:00
addChild(f);
f->release();
schedule(CC_SCHEDULE_SELECTOR(SchedulerUpdate::removeUpdates), 4.0f);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdate::removeUpdates(float dt)
2010-09-09 16:15:21 +08:00
{
auto& children = getChildren();
2010-09-09 16:15:21 +08:00
for (auto& c : children)
{
auto obj = static_cast<Ref*>(c);
auto node = static_cast<Node*>(obj);
if (! node)
2010-09-09 16:15:21 +08:00
{
break;
}
node->unscheduleAllCallbacks();
2010-09-09 16:15:21 +08:00
}
}
std::string SchedulerUpdate::title() const
2010-09-09 16:15:21 +08:00
{
return "Schedule update with priority";
}
std::string SchedulerUpdate::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "3 scheduled updates. Priority should work. Stops in 4s. See console";
}
//------------------------------------------------------------------
//
// SchedulerUpdateAndCustom
//
//------------------------------------------------------------------
void SchedulerUpdateAndCustom::onEnter()
{
SchedulerTestLayer::onEnter();
scheduleUpdate();
schedule(CC_SCHEDULE_SELECTOR(SchedulerUpdateAndCustom::tick));
schedule(CC_SCHEDULE_SELECTOR(SchedulerUpdateAndCustom::stopSelectors), 0.4f);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdateAndCustom::update(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("update called:%f", dt);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdateAndCustom::tick(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("custom selector called:%f",dt);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdateAndCustom::stopSelectors(float dt)
2010-09-09 16:15:21 +08:00
{
log("SchedulerUpdateAndCustom::stopSelectors");
unscheduleAllCallbacks();
2010-09-09 16:15:21 +08:00
}
std::string SchedulerUpdateAndCustom::title() const
2010-09-09 16:15:21 +08:00
{
return "Schedule Update + custom selector";
}
std::string SchedulerUpdateAndCustom::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "Update + custom selector at the same time. Stops in 4s. See console";
}
//------------------------------------------------------------------
//
// SchedulerUpdateFromCustom
//
//------------------------------------------------------------------
void SchedulerUpdateFromCustom::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(CC_SCHEDULE_SELECTOR(SchedulerUpdateFromCustom::schedUpdate), 2.0f);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdateFromCustom::update(float dt)
2010-09-09 16:15:21 +08:00
{
CCLOG("update called:%f", dt);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdateFromCustom::schedUpdate(float dt)
2010-09-09 16:15:21 +08:00
{
unschedule(CC_SCHEDULE_SELECTOR(SchedulerUpdateFromCustom::schedUpdate));
2010-09-09 16:15:21 +08:00
scheduleUpdate();
schedule(CC_SCHEDULE_SELECTOR(SchedulerUpdateFromCustom::stopUpdate), 2.0f);
2010-09-09 16:15:21 +08:00
}
2012-06-08 13:55:28 +08:00
void SchedulerUpdateFromCustom::stopUpdate(float dt)
2010-09-09 16:15:21 +08:00
{
unscheduleUpdate();
unschedule(CC_SCHEDULE_SELECTOR(SchedulerUpdateFromCustom::stopUpdate));
2010-09-09 16:15:21 +08:00
}
std::string SchedulerUpdateFromCustom::title() const
2010-09-09 16:15:21 +08:00
{
return "Schedule Update in 2 sec";
}
std::string SchedulerUpdateFromCustom::subtitle() const
2010-09-09 16:15:21 +08:00
{
return "Update schedules in 2 secs. Stops 2 sec later. See console";
}
//------------------------------------------------------------------
//
// RescheduleSelector
//
//------------------------------------------------------------------
void RescheduleSelector::onEnter()
{
SchedulerTestLayer::onEnter();
_interval = 1.0f;
_ticks = 0;
schedule(CC_SCHEDULE_SELECTOR(RescheduleSelector::schedUpdate), _interval);
}
std::string RescheduleSelector::title() const
{
return "Reschedule Selector";
}
std::string RescheduleSelector::subtitle() const
{
return "Interval is 1 second, then 2, then 3...";
}
2012-06-08 13:55:28 +08:00
void RescheduleSelector::schedUpdate(float dt)
{
_ticks++;
2012-06-12 18:12:45 +08:00
CCLOG("schedUpdate: %.4f", dt);
if ( _ticks > 3 )
{
_interval += 1.0f;
schedule(CC_SCHEDULE_SELECTOR(RescheduleSelector::schedUpdate), _interval);
_ticks = 0;
}
}
// SchedulerDelayAndRepeat
void SchedulerDelayAndRepeat::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(CC_SCHEDULE_SELECTOR(SchedulerDelayAndRepeat::update), 0, 4 , 3.f);
CCLOG("update is scheduled should begin after 3 seconds");
}
std::string SchedulerDelayAndRepeat::title() const
{
return "Schedule with delay of 3 sec, repeat 4 times";
}
std::string SchedulerDelayAndRepeat::subtitle() const
{
return "After 5 x executed, method unscheduled. See console";
}
2012-06-08 13:55:28 +08:00
void SchedulerDelayAndRepeat::update(float dt)
{
log("update called:%f", dt);
}
// SchedulerTimeScale
ControlSlider* SchedulerTimeScale::sliderCtl()
{
ControlSlider * slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SchedulerTimeScale::sliderAction), Control::EventType::VALUE_CHANGED);
slider->setMinimumValue(-3.0f);
slider->setMaximumValue(3.0f);
slider->setValue(1.0f);
return slider;
}
void SchedulerTimeScale::sliderAction(Ref* sender, Control::EventType controlEvent)
{
ControlSlider* pSliderCtl = static_cast<ControlSlider*>(sender);
2012-06-08 13:55:28 +08:00
float scale;
scale = pSliderCtl->getValue();
Director::getInstance()->getScheduler()->setTimeScale(scale);
}
void SchedulerTimeScale::onEnter()
{
SchedulerTestLayer::onEnter();
auto s = Director::getInstance()->getWinSize();
// rotate and jump
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
auto jump1 = JumpBy::create(4, Vec2(-s.width+80,0), 100, 4);
auto jump2 = jump1->reverse();
auto rot1 = RotateBy::create(4, 360*2);
auto rot2 = rot1->reverse();
auto seq3_1 = Sequence::create(jump2, jump1, nullptr);
auto seq3_2 = Sequence::create(rot1, rot2, nullptr);
auto spawn = Spawn::create(seq3_1, seq3_2, nullptr);
auto action = Repeat::create(spawn, 50);
auto action2 = action->clone();
auto action3 = action->clone();
auto grossini = Sprite::create("Images/grossini.png");
auto tamara = Sprite::create("Images/grossinis_sister1.png");
auto kathia = Sprite::create("Images/grossinis_sister2.png");
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
grossini->setPosition(Vec2(40,80));
tamara->setPosition(Vec2(40,80));
kathia->setPosition(Vec2(40,80));
addChild(grossini);
addChild(tamara);
addChild(kathia);
grossini->runAction(Speed::create(action, 0.5f));
tamara->runAction(Speed::create(action2, 1.5f));
kathia->runAction(Speed::create(action3, 1.0f));
auto emitter = ParticleFireworks::create();
emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) );
addChild(emitter);
_sliderCtl = sliderCtl();
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_sliderCtl->setPosition(Vec2(s.width / 2.0f, s.height / 3.0f));
addChild(_sliderCtl);
}
void SchedulerTimeScale::onExit()
{
// restore scale
Director::getInstance()->getScheduler()->setTimeScale(1);
SchedulerTestLayer::onExit();
}
std::string SchedulerTimeScale::title() const
{
return "Scheduler timeScale Test";
}
std::string SchedulerTimeScale::subtitle() const
{
return "Fast-forward and rewind using scheduler.timeScale";
}
//TwoSchedulers
ControlSlider *TwoSchedulers::sliderCtl()
{
// auto frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f);
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
//[[UISlider alloc] initWithFrame:frame];
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), Control::EventType::VALUE_CHANGED);
// in case the parent view draws with a custom color or gradient, use a transparent color
//slider.backgroundColor = [UIColor clearColor];
slider->setMinimumValue(0.0f);
slider->setMaximumValue(2.0f);
//slider.continuous = YES;
slider->setValue(1.0f);
return slider;
}
void TwoSchedulers::sliderAction(Ref* sender, Control::EventType controlEvent)
{
2012-06-08 13:55:28 +08:00
float scale;
ControlSlider *slider = static_cast<ControlSlider*>(sender);
scale = slider->getValue();
if( sender == sliderCtl1 )
sched1->setTimeScale(scale);
else
sched2->setTimeScale(scale);
}
void TwoSchedulers::onEnter()
{
SchedulerTestLayer::onEnter();
auto s = Director::getInstance()->getWinSize();
// rotate and jump
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
auto jump1 = JumpBy::create(4, Vec2(0,0), 100, 4);
auto jump2 = jump1->reverse();
auto seq = Sequence::create(jump2, jump1, nullptr);
auto action = RepeatForever::create(seq);
//
// Center
//
auto grossini = Sprite::create("Images/grossini.png");
addChild(grossini);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
grossini->setPosition(Vec2(s.width/2,100));
grossini->runAction(action->clone());
auto defaultScheduler = Director::getInstance()->getScheduler();
//
// Left:
//
// Create a new scheduler, and link it to the main scheduler
sched1 = new (std::nothrow) Scheduler();
defaultScheduler->scheduleUpdate(sched1, 0, false);
// Create a new ActionManager, and link it to the new scheudler
actionManager1 = new (std::nothrow) ActionManager();
sched1->scheduleUpdate(actionManager1, 0, false);
for( unsigned int i=0; i < 10; i++ )
{
auto sprite = Sprite::create("Images/grossinis_sister1.png");
// IMPORTANT: Set the actionManager running any action
sprite->setActionManager(actionManager1);
addChild(sprite);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sprite->setPosition(Vec2(30+15*i,100));
sprite->runAction(action->clone());
}
//
// Right:
//
// Create a new scheduler, and link it to the main scheduler
sched2 = new (std::nothrow) Scheduler();;
defaultScheduler->scheduleUpdate(sched2, 0, false);
// Create a new ActionManager, and link it to the new scheudler
actionManager2 = new (std::nothrow) ActionManager();
sched2->scheduleUpdate(actionManager2, 0, false);
for( unsigned int i=0; i < 10; i++ ) {
auto sprite = Sprite::create("Images/grossinis_sister2.png");
// IMPORTANT: Set the actionManager running any action
sprite->setActionManager(actionManager2);
addChild(sprite);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sprite->setPosition(Vec2(s.width-30-15*i,100));
sprite->runAction(action->clone());
}
sliderCtl1 = sliderCtl();
addChild(sliderCtl1);
sliderCtl1->retain();
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sliderCtl1->setPosition(Vec2(s.width / 4.0f, VisibleRect::top().y - 20));
sliderCtl2 = sliderCtl();
addChild(sliderCtl2);
sliderCtl2->retain();
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
sliderCtl2->setPosition(Vec2(s.width / 4.0f*3.0f, VisibleRect::top().y-20));
}
TwoSchedulers::~TwoSchedulers()
{
auto defaultScheduler = Director::getInstance()->getScheduler();
2012-11-15 18:34:23 +08:00
defaultScheduler->unscheduleAllForTarget(sched1);
defaultScheduler->unscheduleAllForTarget(sched2);
sliderCtl1->release();
sliderCtl2->release();
sched1->release();
sched2->release();
actionManager1->release();
actionManager2->release();
}
std::string TwoSchedulers::title() const
{
return "Two custom schedulers";
}
std::string TwoSchedulers::subtitle() const
{
return "Three schedulers. 2 custom + 1 default. Two different time scales";
}
class TestNode2 : public Node
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TestNode2);
~TestNode2() {
cocos2d::log("Delete TestNode (should not crash)");
this->unscheduleAllCallbacks();
}
void update(float dt) {
}
};
void SchedulerIssue2268::onEnter()
{
SchedulerTestLayer::onEnter();
2013-11-14 07:55:36 +08:00
testNode = TestNode2::create();
testNode->retain();
testNode->schedule(SEL_SCHEDULE(&TestNode::update));
this->addChild(testNode);
this->scheduleOnce(SEL_SCHEDULE(&SchedulerIssue2268::update), 0.25f);
}
void SchedulerIssue2268::update(float dt)
{
2014-04-12 12:59:28 +08:00
if ( testNode != nullptr ) {
// do something with testNode
// at some point we are done, pause the nodes actions and schedulers
testNode->removeFromParentAndCleanup(false);
// at some other point we are completely done with the node and want to clear it
testNode->unscheduleAllCallbacks();
testNode->release();
2014-04-12 12:59:28 +08:00
testNode = nullptr;
}
}
SchedulerIssue2268::~SchedulerIssue2268()
{
2014-04-12 12:59:28 +08:00
CC_SAFE_RELEASE(testNode);
}
std::string SchedulerIssue2268::title() const
{
return "Issue #2268";
}
std::string SchedulerIssue2268::subtitle() const
{
return "Should not crash";
}
// ScheduleCallbackTest
ScheduleCallbackTest::~ScheduleCallbackTest()
{
}
std::string ScheduleCallbackTest::title() const
{
return "ScheduleCallbackTest";
}
std::string ScheduleCallbackTest::subtitle() const
{
return "\n\n\n\nPlease see console.\n\
schedule(lambda, ...)\n\
schedule(CC_CALLBACK_1(XXX::member_function), this), this, ...)\n\
schedule(global_function, ...)\n\
";
}
static void ScheduleCallbackTest_global_callback(float dt)
{
log("In the callback of schedule(global_function, ...), dt = %f", dt);
}
void ScheduleCallbackTest::onEnter()
{
SchedulerTestLayer::onEnter();
_scheduler->schedule([](float dt){
log("In the callback of schedule(lambda, ...), dt = %f", dt);
}, this, 1.0f, false, "lambda");
_scheduler->schedule(CC_CALLBACK_1(ScheduleCallbackTest::callback, this), this, 1.0f, false, "member_function");
_scheduler->schedule(ScheduleCallbackTest_global_callback, this, 1.0f, false, "global_function");
}
void ScheduleCallbackTest::callback(float dt)
{
log("In the callback of schedule(CC_CALLBACK_1(XXX::member_function), this), this, ...), dt = %f", dt);
}
// ScheduleUpdatePriority
std::string ScheduleUpdatePriority::title() const
{
return "ScheduleUpdatePriorityTest";
}
std::string ScheduleUpdatePriority::subtitle() const
{
return "click to change update priority with random value";
}
bool ScheduleUpdatePriority::onTouchBegan(Touch* touch, Event* event)
{
int priority = static_cast<int>(CCRANDOM_0_1() * 11) - 5; // -5 ~ 5
CCLOG("change update priority to %d", priority);
scheduleUpdateWithPriority(priority);
return true;
}
void ScheduleUpdatePriority::onEnter()
{
SchedulerTestLayer::onEnter();
scheduleUpdate();
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(ScheduleUpdatePriority::onTouchBegan, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}
void ScheduleUpdatePriority::onExit()
{
2014-06-30 18:22:58 +08:00
Node::onExit();
unscheduleUpdate();
}
void ScheduleUpdatePriority::update(float dt)
{
}
2015-01-28 11:31:52 +08:00
void SchedulerIssue10232::onEnter()
{
SchedulerTestLayer::onEnter();
this->scheduleOnce(SEL_SCHEDULE(&SchedulerIssue2268::update), 0.25f);
this->scheduleOnce([](float dt){
log("SchedulerIssue10232:Schedules a lambda function");
}, 0.25f,"SchedulerIssue10232");
}
void SchedulerIssue10232::update(float dt)
{
log("SchedulerIssue10232:Schedules a selector");
}
std::string SchedulerIssue10232::title() const
{
return "Issue #10232";
}
std::string SchedulerIssue10232::subtitle() const
{
return "Should not crash";
}