diff --git a/tests/Android.mk b/tests/Android.mk
index bb605055da..b2190200aa 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -25,7 +25,6 @@ tests/BugsTest/Bug-458/Bug-458.cpp \
tests/BugsTest/Bug-458/QuestionContainerSprite.cpp \
tests/ClickAndMoveTest/ClickAndMoveTest.cpp \
tests/CocosDenshionTest/CocosDenshionTest.cpp \
-tests/CocosNodeTest/CocosNodeTest.cpp \
tests/CurlTest/CurlTest.cpp \
tests/CurrentLanguageTest/CurrentLanguageTest.cpp \
tests/DirectorTest/DirectorTest.cpp \
@@ -40,6 +39,7 @@ tests/IntervalTest/IntervalTest.cpp \
tests/KeypadTest/KeypadTest.cpp \
tests/LabelTest/LabelTest.cpp \
tests/LayerTest/LayerTest.cpp \
+tests/NodeTest/NodeTest.cpp \
tests/TextInputTest/TextInputTest.cpp \
tests/MenuTest/MenuTest.cpp \
tests/MotionStreakTest/MotionStreakTest.cpp \
diff --git a/tests/test.win32/test.win32.vcproj b/tests/test.win32/test.win32.vcproj
index d7d5b5f179..65a697f973 100644
--- a/tests/test.win32/test.win32.vcproj
+++ b/tests/test.win32/test.win32.vcproj
@@ -335,18 +335,6 @@
>
-
-
-
-
-
-
@@ -850,6 +838,14 @@
+
+
+
+
autorelease();
return pLayer;
-}
-
-
-TestCocosNodeDemo::TestCocosNodeDemo(void)
-{
-}
-
-TestCocosNodeDemo::~TestCocosNodeDemo(void)
-{
-}
-
+}
+
+
+TestCocosNodeDemo::TestCocosNodeDemo(void)
+{
+}
+
+TestCocosNodeDemo::~TestCocosNodeDemo(void)
+{
+}
+
std::string TestCocosNodeDemo::title()
{
return "No title";
@@ -103,15 +105,15 @@ void TestCocosNodeDemo::onEnter()
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
- addChild(label, 1);
+ addChild(label, 10);
label->setPosition( CCPointMake(s.width/2, s.height-50) );
- std::string strSubtitle = subtitle();
- if( ! strSubtitle.empty() )
- {
- CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
- addChild(l, 1);
- l->setPosition( CCPointMake(s.width/2, s.height-80) );
+ std::string strSubtitle = subtitle();
+ if( ! strSubtitle.empty() )
+ {
+ CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
+ addChild(l, 1);
+ l->setPosition( CCPointMake(s.width/2, s.height-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestCocosNodeDemo::backCallback) );
@@ -125,7 +127,7 @@ void TestCocosNodeDemo::onEnter()
item2->setPosition( CCPointMake( s.width/2, 30) );
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
- addChild(menu, 1);
+ addChild(menu, 11);
}
void TestCocosNodeDemo::restartCallback(CCObject* pSender)
@@ -152,16 +154,16 @@ void TestCocosNodeDemo::backCallback(CCObject* pSender)
CCDirector::sharedDirector()->replaceScene(s);
s->release();
}
-
-
+
+
//------------------------------------------------------------------
//
// Test2
//
//------------------------------------------------------------------
-void Test2::onEnter()
-{
- TestCocosNodeDemo::onEnter();
+void Test2::onEnter()
+{
+ TestCocosNodeDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
@@ -206,7 +208,7 @@ std::string Test2::title()
return "anchorPoint and children";
}
-
+
//------------------------------------------------------------------
//
// Test4
@@ -215,8 +217,8 @@ std::string Test2::title()
#define SID_DELAY2 1
#define SID_DELAY4 2
-Test4::Test4()
-{
+Test4::Test4()
+{
CCSprite *sp1 = CCSprite::spriteWithFile(s_pPathSister1);
CCSprite *sp2 = CCSprite::spriteWithFile(s_pPathSister2);
@@ -227,8 +229,8 @@ Test4::Test4()
addChild(sp2, 0, 3);
schedule( schedule_selector(Test4::delay2), 2.0f);
- schedule( schedule_selector(Test4::delay4), 4.0f);
-}
+ schedule( schedule_selector(Test4::delay4), 4.0f);
+}
void Test4::delay2(ccTime dt)
{
@@ -248,14 +250,14 @@ std::string Test4::title()
return "tags";
}
-
+
//------------------------------------------------------------------
//
// Test5
//
//------------------------------------------------------------------
-Test5::Test5()
-{
+Test5::Test5()
+{
CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1);
CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2);
@@ -277,8 +279,8 @@ Test5::Test5()
sp1->runAction(forever);
sp2->runAction(forever2);
- schedule( schedule_selector(Test5::addAndRemove), 2.0f);
-}
+ schedule( schedule_selector(Test5::addAndRemove), 2.0f);
+}
void Test5::addAndRemove(ccTime dt)
{
@@ -302,14 +304,14 @@ std::string Test5::title()
{
return "remove and cleanup";
}
-
+
//------------------------------------------------------------------
//
// Test6
//
//------------------------------------------------------------------
-Test6::Test6()
-{
+Test6::Test6()
+{
CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1);
CCSprite* sp11 = CCSprite::spriteWithFile(s_pPathSister1);
@@ -338,8 +340,8 @@ Test6::Test6()
sp2->runAction(forever2);
sp21->runAction(forever21);
- schedule( schedule_selector(Test6::addAndRemove), 2.0f);
-}
+ schedule( schedule_selector(Test6::addAndRemove), 2.0f);
+}
void Test6::addAndRemove(ccTime dt)
{
@@ -370,8 +372,8 @@ std::string Test6::title()
// StressTest1
//
//------------------------------------------------------------------
-StressTest1::StressTest1()
-{
+StressTest1::StressTest1()
+{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSprite *sp1 = CCSprite::spriteWithFile(s_pPathSister1);
@@ -379,8 +381,8 @@ StressTest1::StressTest1()
sp1->setPosition( CCPointMake(s.width/2, s.height/2) );
- schedule( schedule_selector(StressTest1::shouldNotCrash), 1.0f);
-}
+ schedule( schedule_selector(StressTest1::shouldNotCrash), 1.0f);
+}
void StressTest1::shouldNotCrash(ccTime dt)
{
@@ -423,8 +425,8 @@ std::string StressTest1::title()
// StressTest2
//
//------------------------------------------------------------------
-StressTest2::StressTest2()
-{
+StressTest2::StressTest2()
+{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayer* sublayer = CCLayer::node();
@@ -449,9 +451,9 @@ StressTest2::StressTest2()
sublayer->addChild(fire, 2);
schedule(schedule_selector(StressTest2::shouldNotLeak), 6.0f);
-
- addChild(sublayer, 0, kTagSprite1);
-}
+
+ addChild(sublayer, 0, kTagSprite1);
+}
void StressTest2::shouldNotLeak(ccTime dt)
{
@@ -471,8 +473,8 @@ std::string StressTest2::title()
// SchedulerTest1
//
//------------------------------------------------------------------
-SchedulerTest1::SchedulerTest1()
-{
+SchedulerTest1::SchedulerTest1()
+{
CCLayer*layer = CCLayer::node();
//UXLOG("retain count after init is %d", layer->retainCount()); // 1
@@ -483,8 +485,8 @@ SchedulerTest1::SchedulerTest1()
//UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target.
layer->unschedule(schedule_selector(SchedulerTest1::doSomething));
- //UXLOG("retain count after unschedule is %d", layer->retainCount()); // STILL 3! (win32 is '2')
-}
+ //UXLOG("retain count after unschedule is %d", layer->retainCount()); // STILL 3! (win32 is '2')
+}
void SchedulerTest1::doSomething(ccTime dt)
{
@@ -501,352 +503,384 @@ std::string SchedulerTest1::title()
// NodeToWorld
//
//------------------------------------------------------------------
-NodeToWorld::NodeToWorld()
-{
- //
- // This code tests that nodeToParent works OK:
- // - It tests different anchor Points
- // - It tests different children anchor points
-
- CCSprite *back = CCSprite::spriteWithFile(s_back3);
- addChild( back, -10);
- back->setAnchorPoint( CCPointMake(0,0) );
- CCSize backSize = back->getContentSize();
-
- CCMenuItem *item = CCMenuItemImage::itemWithNormalImage(s_PlayNormal, s_PlaySelect);
- CCMenu *menu = CCMenu::menuWithItems(item, NULL);
- menu->alignItemsVertically();
- menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2));
- back->addChild(menu);
-
- CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360);
- CCAction* fe = CCRepeatForever::actionWithAction( rot);
- item->runAction( fe );
-
- CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0));
- CCActionInterval* move_back = move->reverse();
- CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
- CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
- back->runAction(fe2);
-}
-
-std::string NodeToWorld::title()
-{
- return "nodeToParent transform";
-}
-
+NodeToWorld::NodeToWorld()
+{
+ //
+ // This code tests that nodeToParent works OK:
+ // - It tests different anchor Points
+ // - It tests different children anchor points
+
+ CCSprite *back = CCSprite::spriteWithFile(s_back3);
+ addChild( back, -10);
+ back->setAnchorPoint( CCPointMake(0,0) );
+ CCSize backSize = back->getContentSize();
+
+ CCMenuItem *item = CCMenuItemImage::itemWithNormalImage(s_PlayNormal, s_PlaySelect);
+ CCMenu *menu = CCMenu::menuWithItems(item, NULL);
+ menu->alignItemsVertically();
+ menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2));
+ back->addChild(menu);
+
+ CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360);
+ CCAction* fe = CCRepeatForever::actionWithAction( rot);
+ item->runAction( fe );
+
+ CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0));
+ CCActionInterval* move_back = move->reverse();
+ CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
+ CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
+ back->runAction(fe2);
+}
+
+std::string NodeToWorld::title()
+{
+ return "nodeToParent transform";
+}
+
//------------------------------------------------------------------
//
// CameraOrbitTest
//
//------------------------------------------------------------------
-void CameraOrbitTest::onEnter()
-{
- TestCocosNodeDemo::onEnter();
- CCDirector::sharedDirector()->setProjection(kCCDirectorProjection3D);
-}
-
-void CameraOrbitTest::onExit()
-{
- CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
- TestCocosNodeDemo::onExit();
-}
-
-CameraOrbitTest::CameraOrbitTest()
-{
- CCSize s = CCDirector::sharedDirector()->getWinSize();
-
- CCSprite *p = CCSprite::spriteWithFile(s_back3);
- addChild( p, 0);
- p->setPosition( CCPointMake(s.width/2, s.height/2) );
- p->setOpacity( 128 );
-
- CCSprite* sprite;
- CCOrbitCamera* orbit;
- CCCamera* cam;
- CCSize ss;
-
- // LEFT
- s = p->getContentSize();
- sprite = CCSprite::spriteWithFile(s_pPathGrossini);
- sprite->setScale(0.5f);
- p->addChild(sprite, 0);
- sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) );
- cam = sprite->getCamera();
- orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 0, 0);
- sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
-
- // CENTER
- sprite = CCSprite::spriteWithFile(s_pPathGrossini);
- sprite->setScale( 1.0f );
- p->addChild(sprite, 0);
- sprite->setPosition( CCPointMake(s.width/4*2, s.height/2) );
- orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 45, 0);
- sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
-
-
- // RIGHT
- sprite = CCSprite::spriteWithFile(s_pPathGrossini);
- sprite->setScale( 2.0f );
- p->addChild(sprite, 0);
- sprite->setPosition( CCPointMake(s.width/4*3, s.height/2) );
- ss = sprite->getContentSize();
- orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 90, -45),
- sprite->runAction( CCRepeatForever::actionWithAction(orbit) );
-
-
- // PARENT
- orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 90);
- p->runAction( CCRepeatForever::actionWithAction( orbit ) );
-
- setScale( 1 );
-}
-
-std::string CameraOrbitTest::title()
-{
- return "Camera Orbit test";
-}
-
+void CameraOrbitTest::onEnter()
+{
+ TestCocosNodeDemo::onEnter();
+ CCDirector::sharedDirector()->setProjection(kCCDirectorProjection3D);
+}
+
+void CameraOrbitTest::onExit()
+{
+ CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
+ TestCocosNodeDemo::onExit();
+}
+
+CameraOrbitTest::CameraOrbitTest()
+{
+ CCSize s = CCDirector::sharedDirector()->getWinSize();
+
+ CCSprite *p = CCSprite::spriteWithFile(s_back3);
+ addChild( p, 0);
+ p->setPosition( CCPointMake(s.width/2, s.height/2) );
+ p->setOpacity( 128 );
+
+ CCSprite* sprite;
+ CCOrbitCamera* orbit;
+ CCCamera* cam;
+ CCSize ss;
+
+ // LEFT
+ s = p->getContentSize();
+ sprite = CCSprite::spriteWithFile(s_pPathGrossini);
+ sprite->setScale(0.5f);
+ p->addChild(sprite, 0);
+ sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) );
+ cam = sprite->getCamera();
+ orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 0, 0);
+ sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
+
+ // CENTER
+ sprite = CCSprite::spriteWithFile(s_pPathGrossini);
+ sprite->setScale( 1.0f );
+ p->addChild(sprite, 0);
+ sprite->setPosition( CCPointMake(s.width/4*2, s.height/2) );
+ orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 45, 0);
+ sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
+
+
+ // RIGHT
+ sprite = CCSprite::spriteWithFile(s_pPathGrossini);
+ sprite->setScale( 2.0f );
+ p->addChild(sprite, 0);
+ sprite->setPosition( CCPointMake(s.width/4*3, s.height/2) );
+ ss = sprite->getContentSize();
+ orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 90, -45),
+ sprite->runAction( CCRepeatForever::actionWithAction(orbit) );
+
+
+ // PARENT
+ orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 90);
+ p->runAction( CCRepeatForever::actionWithAction( orbit ) );
+
+ setScale( 1 );
+}
+
+std::string CameraOrbitTest::title()
+{
+ return "Camera Orbit test";
+}
+
//------------------------------------------------------------------
//
// CameraZoomTest
//
//------------------------------------------------------------------
-
-void CameraZoomTest::onEnter()
-{
- TestCocosNodeDemo::onEnter();
-
- CCDirector::sharedDirector()->setProjection(kCCDirectorProjection3D);
-}
-
-void CameraZoomTest::onExit()
-{
- CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
- TestCocosNodeDemo::onExit();
-}
-
-CameraZoomTest::CameraZoomTest()
-{
- CCSize s = CCDirector::sharedDirector()->getWinSize();
-
- CCSprite *sprite;
- CCCamera *cam;
-
- // LEFT
- sprite = CCSprite::spriteWithFile(s_pPathGrossini);
- addChild( sprite, 0);
- sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) );
- cam = sprite->getCamera();
- cam->setEyeXYZ(0, 0, 415);
-
- // CENTER
- sprite = CCSprite::spriteWithFile(s_pPathGrossini);
- addChild( sprite, 0, 40);
- sprite->setPosition(CCPointMake(s.width/4*2, s.height/2));
-// cam = [sprite camera);
-// [cam setEyeX:0 eyeY:0 eyeZ:415/2);
-
- // RIGHT
- sprite = CCSprite::spriteWithFile(s_pPathGrossini);
- addChild( sprite, 0, 20);
- sprite->setPosition(CCPointMake(s.width/4*3, s.height/2));
-// cam = [sprite camera);
-// [cam setEyeX:0 eyeY:0 eyeZ:-485);
-// [cam setCenterX:0 centerY:0 centerZ:0);
-
- m_z = 0;
- scheduleUpdate();
-}
-
-void CameraZoomTest::update(ccTime dt)
-{
- CCNode *sprite;
- CCCamera *cam;
-
- m_z += dt * 100;
-
- sprite = getChildByTag(20);
- cam = sprite->getCamera();
- cam->setEyeXYZ(0, 0, m_z);
-
- sprite = getChildByTag(40);
- cam = sprite->getCamera();
- cam->setEyeXYZ(0, 0, m_z);
-}
-
-std::string CameraZoomTest::title()
-{
- return "Camera Zoom test";
-}
-
+
+void CameraZoomTest::onEnter()
+{
+ TestCocosNodeDemo::onEnter();
+
+ CCDirector::sharedDirector()->setProjection(kCCDirectorProjection3D);
+}
+
+void CameraZoomTest::onExit()
+{
+ CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
+ TestCocosNodeDemo::onExit();
+}
+
+CameraZoomTest::CameraZoomTest()
+{
+ CCSize s = CCDirector::sharedDirector()->getWinSize();
+
+ CCSprite *sprite;
+ CCCamera *cam;
+
+ // LEFT
+ sprite = CCSprite::spriteWithFile(s_pPathGrossini);
+ addChild( sprite, 0);
+ sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) );
+ cam = sprite->getCamera();
+ cam->setEyeXYZ(0, 0, 415/2);
+ cam->setCenterXYZ(0, 0, 0);
+
+ // CENTER
+ sprite = CCSprite::spriteWithFile(s_pPathGrossini);
+ addChild( sprite, 0, 40);
+ sprite->setPosition(CCPointMake(s.width/4*2, s.height/2));
+
+ // RIGHT
+ sprite = CCSprite::spriteWithFile(s_pPathGrossini);
+ addChild( sprite, 0, 20);
+ sprite->setPosition(CCPointMake(s.width/4*3, s.height/2));
+
+ m_z = 0;
+ scheduleUpdate();
+}
+
+void CameraZoomTest::update(ccTime dt)
+{
+ CCNode *sprite;
+ CCCamera *cam;
+
+ m_z += dt * 100;
+
+ sprite = getChildByTag(20);
+ cam = sprite->getCamera();
+ cam->setEyeXYZ(0, 0, m_z);
+
+ sprite = getChildByTag(40);
+ cam = sprite->getCamera();
+ cam->setEyeXYZ(0, 0, -m_z);
+}
+
+std::string CameraZoomTest::title()
+{
+ return "Camera Zoom test";
+}
+
//------------------------------------------------------------------
//
// CameraCenterTest
//
//------------------------------------------------------------------
-CameraCenterTest::CameraCenterTest()
-{
- CCSize s = CCDirector::sharedDirector()->getWinSize();
-
- CCSprite *sprite;
- CCOrbitCamera *orbit;
-
- // LEFT-TOP
- sprite = new CCSprite();//::node();
- sprite->init();
- addChild( sprite, 0);
- sprite->setPosition(CCPointMake(s.width/5*1, s.height/5*1));
- sprite->setColor(ccRED);
- sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
- orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
- sprite->runAction(CCRepeatForever::actionWithAction( orbit ));
- sprite->release();
-// [sprite setAnchorPoint: CCPointMake(0,1));
-
-
-
- // LEFT-BOTTOM
- sprite = new CCSprite();//::node();
- sprite->init();
- addChild( sprite, 0, 40);
- sprite->setPosition(CCPointMake(s.width/5*1, s.height/5*4));
- sprite->setColor(ccBLUE);
- sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
- orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
- sprite->runAction(CCRepeatForever::actionWithAction( orbit ));
- sprite->release();
- // [sprite setAnchorPoint: CCPointMake(0,0));
-
-
- // RIGHT-TOP
- sprite = new CCSprite();//::node();
- sprite->init();
- addChild( sprite, 0);
- sprite->setPosition(CCPointMake(s.width/5*4, s.height/5*1));
- sprite->setColor(ccYELLOW);
- sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
- orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
- sprite->runAction(CCRepeatForever::actionWithAction( orbit) );
- sprite->release();
-// [sprite setAnchorPoint: CCPointMake(1,1));
-
-
- // RIGHT-BOTTOM
- sprite = new CCSprite();//::node();
- sprite->init();
- addChild( sprite, 0, 40);
- sprite->setPosition(CCPointMake(s.width/5*4, s.height/5*4));
- sprite->setColor(ccGREEN);
- sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
- orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
- sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
- sprite->release();
-// [sprite setAnchorPoint: CCPointMake(1,0));
-
- // CENTER
- sprite = new CCSprite();
- sprite->init();
- addChild( sprite, 0, 40);
- sprite->setPosition(CCPointMake(s.width/2, s.height/2));
- sprite->setColor(ccWHITE);
- sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
- orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
- sprite->runAction(CCRepeatForever::actionWithAction( orbit ) );
- sprite->release();
-// [sprite setAnchorPoint: CCPointMake(0.5f, 0.5f));
-}
-
-std::string CameraCenterTest::title()
-{
- return "Camera Center test";
-}
-
-std::string CameraCenterTest::subtitle()
-{
- return "Sprites should rotate at the same speed";
-}
-
+CameraCenterTest::CameraCenterTest()
+{
+ CCSize s = CCDirector::sharedDirector()->getWinSize();
+
+ CCSprite *sprite;
+ CCOrbitCamera *orbit;
+
+ // LEFT-TOP
+ sprite = CCSprite::spriteWithFile("Images/white-512x512.png");
+ addChild( sprite, 0);
+ sprite->setPosition(CCPointMake(s.width/5*1, s.height/5*1));
+ sprite->setColor(ccRED);
+ sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
+ orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
+ sprite->runAction(CCRepeatForever::actionWithAction( orbit ));
+// [sprite setAnchorPoint: CCPointMake(0,1));
+
+
+
+ // LEFT-BOTTOM
+ sprite = CCSprite::spriteWithFile("Images/white-512x512.png");
+ addChild( sprite, 0, 40);
+ sprite->setPosition(CCPointMake(s.width/5*1, s.height/5*4));
+ sprite->setColor(ccBLUE);
+ sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
+ orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
+ sprite->runAction(CCRepeatForever::actionWithAction( orbit ));
+
+
+ // RIGHT-TOP
+ sprite = CCSprite::spriteWithFile("Images/white-512x512.png");
+ addChild( sprite, 0);
+ sprite->setPosition(CCPointMake(s.width/5*4, s.height/5*1));
+ sprite->setColor(ccYELLOW);
+ sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
+ orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
+ sprite->runAction(CCRepeatForever::actionWithAction( orbit) );
+
+
+ // RIGHT-BOTTOM
+ sprite = CCSprite::spriteWithFile("Images/white-512x512.png");
+ addChild( sprite, 0, 40);
+ sprite->setPosition(CCPointMake(s.width/5*4, s.height/5*4));
+ sprite->setColor(ccGREEN);
+ sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
+ orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
+ sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
+
+ // CENTER
+ sprite = CCSprite::spriteWithFile("Images/white-512x512.png");
+ addChild( sprite, 0, 40);
+ sprite->setPosition(CCPointMake(s.width/2, s.height/2));
+ sprite->setColor(ccWHITE);
+ sprite->setTextureRect(CCRectMake(0, 0, 120, 50));
+ orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0);
+ sprite->runAction(CCRepeatForever::actionWithAction( orbit ) );
+}
+
+std::string CameraCenterTest::title()
+{
+ return "Camera Center test";
+}
+
+std::string CameraCenterTest::subtitle()
+{
+ return "Sprites should rotate at the same speed";
+}
+
//------------------------------------------------------------------
//
// ConvertToNode
//
-//------------------------------------------------------------------
-ConvertToNode::ConvertToNode()
-{
- setIsTouchEnabled(true);
- CCSize s = CCDirector::sharedDirector()->getWinSize();
-
- CCRotateBy* rotate = CCRotateBy::actionWithDuration(10, 360);
- CCRepeatForever* action = CCRepeatForever::actionWithAction(rotate);
- for(int i = 0; i < 3; i++)
- {
- CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png");
- sprite->setPosition(ccp( s.width/4*(i+1), s.height/2));
-
- CCSprite *point = CCSprite::spriteWithFile("Images/r1.png");
- point->setScale(0.25f);
- point->setPosition(sprite->getPosition());
- addChild(point, 10, 100 + i);
-
- switch(i)
- {
- case 0:
- sprite->setAnchorPoint(CCPointZero);
- break;
- case 1:
- sprite->setAnchorPoint(ccp(0.5f, 0.5f));
- break;
- case 2:
- sprite->setAnchorPoint(ccp(1,1));
- break;
- }
-
- point->setPosition(sprite->getPosition());
-
- CCRepeatForever* copy = (CCRepeatForever*) action->copy();
- copy->autorelease();
- sprite->runAction(copy);
- addChild(sprite, i);
- }
-}
-
-void ConvertToNode::ccTouchesEnded(CCSet* touches, CCEvent *event)
-{
- for( CCSetIterator it = touches->begin(); it != touches->end(); ++it)
- {
- CCTouch* touch = (CCTouch*)(*it);
- CCPoint location = touch->locationInView();
-
- location = CCDirector::sharedDirector()->convertToGL(location);
-
- for( int i = 0; i < 3; i++)
- {
- CCNode *node = getChildByTag(100+i);
- CCPoint p1, p2;
-
- p1 = node->convertToNodeSpaceAR(location);
- p2 = node->convertToNodeSpace(location);
-
- CCLOG("AR: x=%.2f, y=%.2f -- Not AR: x=%.2f, y=%.2f", p1.x, p1.y, p2.x, p2.y);
- }
- }
-}
-
-std::string ConvertToNode::title()
-{
- return "Convert To Node Space";
-}
-
-std::string ConvertToNode::subtitle()
-{
- return "testing convertToNodeSpace / AR. Touch and see console";
-}
-
-void CocosNodeTestScene::runThisTest()
-{
- CCLayer* pLayer = nextCocosNodeAction();
- addChild(pLayer);
-
- CCDirector::sharedDirector()->replaceScene(this);
-}
+//------------------------------------------------------------------
+ConvertToNode::ConvertToNode()
+{
+ setIsTouchEnabled(true);
+ CCSize s = CCDirector::sharedDirector()->getWinSize();
+
+ CCRotateBy* rotate = CCRotateBy::actionWithDuration(10, 360);
+ CCRepeatForever* action = CCRepeatForever::actionWithAction(rotate);
+ for(int i = 0; i < 3; i++)
+ {
+ CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png");
+ sprite->setPosition(ccp( s.width/4*(i+1), s.height/2));
+
+ CCSprite *point = CCSprite::spriteWithFile("Images/r1.png");
+ point->setScale(0.25f);
+ point->setPosition(sprite->getPosition());
+ addChild(point, 10, 100 + i);
+
+ switch(i)
+ {
+ case 0:
+ sprite->setAnchorPoint(CCPointZero);
+ break;
+ case 1:
+ sprite->setAnchorPoint(ccp(0.5f, 0.5f));
+ break;
+ case 2:
+ sprite->setAnchorPoint(ccp(1,1));
+ break;
+ }
+
+ point->setPosition(sprite->getPosition());
+
+ CCRepeatForever* copy = (CCRepeatForever*) action->copy();
+ copy->autorelease();
+ sprite->runAction(copy);
+ addChild(sprite, i);
+ }
+}
+
+void ConvertToNode::ccTouchesEnded(CCSet* touches, CCEvent *event)
+{
+ for( CCSetIterator it = touches->begin(); it != touches->end(); ++it)
+ {
+ CCTouch* touch = (CCTouch*)(*it);
+ CCPoint location = touch->locationInView();
+
+ location = CCDirector::sharedDirector()->convertToGL(location);
+
+ for( int i = 0; i < 3; i++)
+ {
+ CCNode *node = getChildByTag(100+i);
+ CCPoint p1, p2;
+
+ p1 = node->convertToNodeSpaceAR(location);
+ p2 = node->convertToNodeSpace(location);
+
+ CCLOG("AR: x=%.2f, y=%.2f -- Not AR: x=%.2f, y=%.2f", p1.x, p1.y, p2.x, p2.y);
+ }
+ }
+}
+
+std::string ConvertToNode::title()
+{
+ return "Convert To Node Space";
+}
+
+std::string ConvertToNode::subtitle()
+{
+ return "testing convertToNodeSpace / AR. Touch and see console";
+}
+
+/// NodeOpaqueTest
+
+NodeOpaqueTest::NodeOpaqueTest()
+{
+ CCSprite *background = NULL;
+
+ for (int i = 0; i < 50; i++)
+ {
+ background = CCSprite::spriteWithFile("Images/background1.png");
+ background->setGLServerState((ccGLServerState)(background->getGLServerState() & (~CC_GL_BLEND)));
+ background->setAnchorPoint(CCPointZero);
+ addChild(background);
+ }
+}
+
+std::string NodeOpaqueTest::title()
+{
+ return "Node Opaque Test";
+}
+
+std::string NodeOpaqueTest::subtitle()
+{
+ return "Node rendered with GL_BLEND disabled";
+}
+
+/// NodeNonOpaqueTest
+
+NodeNonOpaqueTest::NodeNonOpaqueTest()
+{
+ CCSprite *background = NULL;
+
+ for (int i = 0; i < 50; i++)
+ {
+ background = CCSprite::spriteWithFile("Images/background1.jpg");
+ background->setGLServerState((ccGLServerState)(background->getGLServerState() | CC_GL_BLEND));
+ background->setAnchorPoint(CCPointZero);
+ addChild(background);
+ }
+}
+
+std::string NodeNonOpaqueTest::title()
+{
+ return "Node Non Opaque Test";
+}
+
+std::string NodeNonOpaqueTest::subtitle()
+{
+ return "Node rendered with GL_BLEND enabled";
+}
+
+void CocosNodeTestScene::runThisTest()
+{
+ CCLayer* pLayer = nextCocosNodeAction();
+ addChild(pLayer);
+
+ CCDirector::sharedDirector()->replaceScene(this);
+}
diff --git a/tests/tests/CocosNodeTest/CocosNodeTest.h b/tests/tests/NodeTest/NodeTest.h
similarity index 86%
rename from tests/tests/CocosNodeTest/CocosNodeTest.h
rename to tests/tests/NodeTest/NodeTest.h
index cbbfc7c98d..317ecb2199 100644
--- a/tests/tests/CocosNodeTest/CocosNodeTest.h
+++ b/tests/tests/NodeTest/NodeTest.h
@@ -1,15 +1,15 @@
-#ifndef _COCOSNODE_TEST_H_
-#define _COCOSNODE_TEST_H_
-
-////----#include "cocos2d.h"
-#include "../testBasic.h"
-
+#ifndef _NODE_TEST_H_
+#define _NODE_TEST_H_
+
+////----#include "cocos2d.h"
+#include "../testBasic.h"
+
class TestCocosNodeDemo : public CCLayer
{
-public:
- TestCocosNodeDemo(void);
- ~TestCocosNodeDemo(void);
-
+public:
+ TestCocosNodeDemo(void);
+ ~TestCocosNodeDemo(void);
+
virtual std::string title();
virtual std::string subtitle();
virtual void onEnter();
@@ -21,14 +21,14 @@ public:
class Test2 : public TestCocosNodeDemo
{
-public:
+public:
virtual void onEnter();
virtual std::string title();
};
class Test4 : public TestCocosNodeDemo
{
-public:
+public:
Test4();
void delay2(ccTime dt);
void delay4(ccTime dt);
@@ -38,7 +38,7 @@ public:
class Test5 : public TestCocosNodeDemo
{
-public:
+public:
Test5();
void addAndRemove(ccTime dt);
@@ -47,7 +47,7 @@ public:
class Test6 : public TestCocosNodeDemo
{
-public:
+public:
Test6();
void addAndRemove(ccTime dt);
@@ -58,7 +58,7 @@ class StressTest1 : public TestCocosNodeDemo
{
void shouldNotCrash(ccTime dt);
void removeMe(CCNode* node);
-public:
+public:
StressTest1();
virtual std::string title();
@@ -67,7 +67,7 @@ public:
class StressTest2 : public TestCocosNodeDemo
{
void shouldNotLeak(ccTime dt);
-public:
+public:
StressTest2();
virtual std::string title();
@@ -75,7 +75,7 @@ public:
class SchedulerTest1 : public TestCocosNodeDemo
{
-public:
+public:
SchedulerTest1();
void doSomething(ccTime dt);
@@ -84,14 +84,14 @@ public:
class NodeToWorld : public TestCocosNodeDemo
{
-public:
+public:
NodeToWorld();
virtual std::string title();
};
class CameraOrbitTest : public TestCocosNodeDemo
{
-public:
+public:
CameraOrbitTest();
virtual void onEnter();
@@ -102,7 +102,7 @@ public:
class CameraZoomTest : public TestCocosNodeDemo
{
float m_z;
-public:
+public:
CameraZoomTest();
void update(ccTime dt);
@@ -114,7 +114,7 @@ public:
class CameraCenterTest : public TestCocosNodeDemo
{
-public:
+public:
CameraCenterTest();
virtual std::string title();
virtual std::string subtitle();
@@ -129,6 +129,22 @@ public:
virtual std::string subtitle();
};
+class NodeOpaqueTest : public TestCocosNodeDemo
+{
+public:
+ NodeOpaqueTest();
+ virtual std::string title();
+ virtual std::string subtitle();
+};
+
+class NodeNonOpaqueTest : public TestCocosNodeDemo
+{
+public:
+ NodeNonOpaqueTest();
+ virtual std::string title();
+ virtual std::string subtitle();
+};
+
class CocosNodeTestScene : public TestScene
{
public:
diff --git a/tests/tests/tests.h b/tests/tests/tests.h
index 5eecac6e4d..a4c6b01d37 100644
--- a/tests/tests/tests.h
+++ b/tests/tests/tests.h
@@ -11,7 +11,6 @@
#include "ActionsEaseTest/ActionsEaseTest.h"
#include "MotionStreakTest/MotionStreakTest.h"
#include "DrawPrimitivesTest/DrawPrimitivesTest.h"
-#include "CocosNodeTest/CocosNodeTest.h"
#include "TouchesTest/TouchesTest.h"
#include "MenuTest/MenuTest.h"
#include "ActionManagerTest/ActionManagerTest.h"
@@ -42,6 +41,7 @@
#include "FontTest/FontTest.h"
#include "CurrentLanguageTest/CurrentLanguageTest.h"
#include "TextureCacheTest/TextureCacheTest.h"
+#include "NodeTest/NodeTest.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
#include "ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h"
@@ -114,7 +114,7 @@ const std::string g_aTestNames[TESTS_COUNT] = {
"ActionsEaseTest",
"MotionStreakTest",
"DrawPrimitivesTest",
- "CocosNodeTest",
+ "NodeTest",
"TouchesTest",
"MenuTest",
"ActionManagerTest",