From 9fbe1fef967268daf5853b696bd0288d894a6c65 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 12 Jun 2012 16:56:34 +0800 Subject: [PATCH] issue #1310: synchronize some codes --- .../project.pbxproj.REMOVED.git-id | 2 +- .../ChipmunkAccelTouchTest.cpp | 2 +- tests/tests/DirectorTest/DirectorTest.cpp | 211 ----------------- tests/tests/DirectorTest/DirectorTest.h | 40 ---- .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 10 +- .../EffectsAdvancedTest.cpp | 8 +- tests/tests/EffectsTest/EffectsTest.cpp | 20 +- tests/tests/HiResTest/HiResTest.cpp | 223 ------------------ tests/tests/HiResTest/HiResTest.h | 45 ---- .../MotionStreakTest/MotionStreakTest.cpp | 107 +++++++-- .../tests/MotionStreakTest/MotionStreakTest.h | 16 +- .../PerformanceParticleTest.cpp | 2 +- .../PerformanceTest/PerformanceSpriteTest.cpp | 4 +- tests/tests/controller.cpp | 4 - tests/tests/tests.h | 6 - 15 files changed, 122 insertions(+), 578 deletions(-) delete mode 100644 tests/tests/DirectorTest/DirectorTest.cpp delete mode 100644 tests/tests/DirectorTest/DirectorTest.h delete mode 100644 tests/tests/HiResTest/HiResTest.cpp delete mode 100644 tests/tests/HiResTest/HiResTest.h diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 8f63248979..ef267a6614 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -c16d1dddb12b5a7e7e715f234dfd031657369f96 \ No newline at end of file +108734e79d5bc98e94e74a0803cbcc30dd687eb7 \ No newline at end of file diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index b61104d6d8..5920602936 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -119,7 +119,7 @@ void ChipmunkAccelTouchTestLayer::initPhysics() CCSize s = CCDirector::sharedDirector()->getWinSize(); // init chipmunk - cpInitChipmunk(); + //cpInitChipmunk(); m_pSpace = cpSpaceNew(); diff --git a/tests/tests/DirectorTest/DirectorTest.cpp b/tests/tests/DirectorTest/DirectorTest.cpp deleted file mode 100644 index 2867a698a7..0000000000 --- a/tests/tests/DirectorTest/DirectorTest.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include "DirectorTest.h" -#include "../testResource.h" - -#define MAX_LAYER 1 - -CCLayer* nextDirectorTestCase(); -CCLayer* backDirectorTestCase(); -CCLayer* restartDirectorTestCase(); - -static int sceneIdx=-1; -//static ccDeviceOrientation s_currentOrientation = CCDeviceOrientationPortrait; - -CCLayer* createTestCaseLayer(int index) -{ - switch (index) - { - case 0: - { - Director1* pRet = new Director1(); - pRet->init(); - pRet->autorelease(); - return pRet; - } - default: - return NULL; - } -} - -CCLayer* nextDirectorTestCase() -{ - sceneIdx++; - sceneIdx = sceneIdx % MAX_LAYER; - - return createTestCaseLayer(sceneIdx); -} - -CCLayer* backDirectorTestCase() -{ - sceneIdx--; - if( sceneIdx < 0 ) - sceneIdx += MAX_LAYER; - - return createTestCaseLayer(sceneIdx); -} - -CCLayer* restartDirectorTestCase() -{ - return createTestCaseLayer(sceneIdx); -} - -///--------------------------------------- -// -// DirectorTest -// -///--------------------------------------- -bool DirectorTest::init() -{ - bool bRet = false; - do - { - CC_BREAK_IF(! CCLayer::init()); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); - addChild(label, 1); - label->setPosition(ccp(s.width/2, s.height-50)); - - std::string sSubtitle = subtitle(); - if (sSubtitle.length()) - { - CCLabelTTF *l = CCLabelTTF::labelWithString(sSubtitle.c_str(), "Thonburi", 16); - addChild(l, 1); - l->setPosition(ccp(s.width/2, s.height-80)); - } - - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(DirectorTest::backCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(DirectorTest::restartCallback)); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(DirectorTest::nextCallback)); - - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition(CCPointZero); - item1->setPosition(ccp( s.width/2 - 100,30)); - item2->setPosition(ccp( s.width/2, 30)); - item3->setPosition(ccp( s.width/2 + 100,30)); - - bRet = true; - } while (0); - - return bRet; -} - -void DirectorTest::restartCallback(CCObject* pSender) -{ - CCScene *s = new DirectorTestScene(); - s->addChild(restartDirectorTestCase()); - CCDirector::sharedDirector()->replaceScene(s); - s->autorelease(); -} - -void DirectorTest::nextCallback(CCObject* pSender) -{ - CCScene *s = new DirectorTestScene(); - s->addChild(nextDirectorTestCase()); - CCDirector::sharedDirector()->replaceScene(s); - s->autorelease(); -} - -void DirectorTest::backCallback(CCObject* pSender) -{ - CCScene *s = new DirectorTestScene(); - s->addChild(backDirectorTestCase()); - CCDirector::sharedDirector()->replaceScene(s); - s->autorelease(); -} - -std::string DirectorTest::title() -{ - return "No title"; -} - -std::string DirectorTest::subtitle() -{ - return ""; -} - -///--------------------------------------- -// -// Director1 -// -///--------------------------------------- -bool Director1::init() -{ - bool bRet = false; - - do - { - CC_BREAK_IF(! DirectorTest::init()); - - setIsTouchEnabled(true); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCMenuItem *item = CCMenuItemFont::itemWithString("Rotate Device", this, menu_selector(Director1::rotateDevice)); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); - menu->setPosition(ccp( s.width/2, s.height/2)); - addChild(menu); - - bRet = true; - } while (0); - - return bRet; -} - -void Director1::newOrientation() -{ - -} - -void Director1::rotateDevice(CCObject* pSender) -{ - newOrientation(); - restartCallback(NULL); -} - -void Director1::ccTouchesEnded(CCSet * touches, CCEvent* event) -{ - CCSetIterator it; - CCTouch* touch; - - for( it = touches->begin(); it != touches->end(); it++) - { - touch = (CCTouch*)(*it); - - if(!touch) - break; - CCPoint a = touch->locationInView(); - - CCDirector *director = CCDirector::sharedDirector(); - CCPoint b = director->convertToUI(director->convertToGL(a)); - CCLog("(%d,%d) == (%d,%d)", (int) a.x, (int)a.y, (int)b.x, (int)b.y ); - } -} - -std::string Director1::title() -{ - return "Testing conversion"; -} - -std::string Director1::subtitle() -{ - return "Tap screen and see the debug console"; -} - -///--------------------------------------- -// -// DirectorTestScene -// -///--------------------------------------- -void DirectorTestScene::runThisTest() -{ - //s_currentOrientation = CCDeviceOrientationPortrait; - CCLayer* pLayer = nextDirectorTestCase(); - addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(this); -} - -void DirectorTestScene::MainMenuCallback(CCObject* pSender) -{ - //CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait); - TestScene::MainMenuCallback(pSender); -} diff --git a/tests/tests/DirectorTest/DirectorTest.h b/tests/tests/DirectorTest/DirectorTest.h deleted file mode 100644 index e5d0ad1f6c..0000000000 --- a/tests/tests/DirectorTest/DirectorTest.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __DIRECTOR_TEST_H__ -#define __DIRECTOR_TEST_H__ - -#include "../testBasic.h" - -class DirectorTest: public CCLayer -{ -public: - virtual bool init(); - - void restartCallback(CCObject* pSender); - void nextCallback(CCObject* pSender); - void backCallback(CCObject* pSender); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class Director1 : public DirectorTest -{ -public: - virtual bool init(); - - void newOrientation(); - void rotateDevice(CCObject* pSender); - void ccTouchesEnded(CCSet * touches, CCEvent* event); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class DirectorTestScene : public TestScene -{ -public: - virtual void runThisTest(); - - virtual void MainMenuCallback(CCObject* pSender); -}; - -#endif diff --git a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 67d30e156f..a012a8bf57 100644 --- a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -72,6 +72,11 @@ void DrawPrimitivesTest::draw() ccDrawPoly( vertices, 5, false); CHECK_GL_ERROR_DEBUG(); + + // filled poly + glLineWidth(1); + CCPoint filledVertices[] = { ccp(0,120), ccp(50,120), ccp(50,170), ccp(25,200), ccp(0,170) }; + ccDrawSolidPoly(filledVertices, 5, ccc4f(0.5f, 0.5f, 1, 1 ) ); // closed purble poly ccDrawColor4B(255, 0, 255, 255); @@ -90,8 +95,9 @@ void DrawPrimitivesTest::draw() ccDrawCubicBezier(ccp(s.width/2, s.height/2), ccp(s.width/2+30,s.height/2+50), ccp(s.width/2+60,s.height/2-50),ccp(s.width, s.height/2),100); CHECK_GL_ERROR_DEBUG(); - //draw a solid polygon - CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)}; + + //draw a solid polygon + CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)}; ccDrawSolidPoly( vertices3, 4, ccc4f(1,1,0,1) ); // restore original values diff --git a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 6e5b8195fa..683b11e083 100644 --- a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -343,10 +343,10 @@ void EffectAdvanceTextLayer::onEnter(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( ccp( size.width/2 - 100,30) ); - item2->setPosition( ccp( size.width/2, 30) ); - item3->setPosition( ccp( size.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(ccp(size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(ccp(size.width/2, item2->getContentSize().height/2)); + item3->setPosition(ccp(size.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } diff --git a/tests/tests/EffectsTest/EffectsTest.cpp b/tests/tests/EffectsTest/EffectsTest.cpp index 2d067b22fe..e282e5b415 100644 --- a/tests/tests/EffectsTest/EffectsTest.cpp +++ b/tests/tests/EffectsTest/EffectsTest.cpp @@ -343,19 +343,19 @@ TextLayer::TextLayer(void) float x,y; - CCSize size = CCDirector::sharedDirector()->getWinSize(); - x = size.width; - y = size.height; + CCSize s = CCDirector::sharedDirector()->getWinSize(); + x = s.width; + y = s.height; CCNode* node = CCNode::node(); CCActionInterval* effect = getAction(); - node->runAction(effect) - ; + node->runAction(effect); addChild(node, 0, kTagBackground); CCSprite *bg = CCSprite::spriteWithFile(s_back3); node->addChild(bg, 0); - bg->setAnchorPoint( CCPointZero ); +// bg->setAnchorPoint( CCPointZero ); + bg->setPosition(ccp(s.width/2, s.height/2)); CCSprite* grossini = CCSprite::spriteWithFile(s_pPathSister2); node->addChild(grossini, 1); @@ -383,10 +383,10 @@ TextLayer::TextLayer(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( size.width/2 - 100,30) ); - item2->setPosition( CCPointMake( size.width/2, 30) ); - item3->setPosition( CCPointMake( size.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); diff --git a/tests/tests/HiResTest/HiResTest.cpp b/tests/tests/HiResTest/HiResTest.cpp deleted file mode 100644 index 8869250937..0000000000 --- a/tests/tests/HiResTest/HiResTest.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "HiResTest.h" -#include "../testResource.h" - -#define MAX_LAYERS 2; -static int sceneIdx = -1; - -CCLayer* nextHiResAction(); -CCLayer* restartHiResAction(); -CCLayer* backHiResAction(); - -CCLayer* createHiResLayer(int idx) -{ - CCLayer* pLayer = NULL; - - switch (idx) - { - case 0: - CCDirector::sharedDirector()->enableRetinaDisplay(false); - pLayer = new HiResTest1(); - break; - case 1: - CCDirector::sharedDirector()->enableRetinaDisplay(true); - pLayer = new HiResTest2(); - break; - } - - return pLayer; -} - -CCLayer* nextHiResAction() -{ - sceneIdx++; - sceneIdx = sceneIdx % MAX_LAYERS; - - CCLayer* pLayer = createHiResLayer(sceneIdx); - return pLayer; -} - -CCLayer* restartHiResAction() -{ - CCLayer* pLayer = createHiResLayer(sceneIdx); - return pLayer; -} - -CCLayer* backHiResAction() -{ - sceneIdx--; - if( sceneIdx < 0 ) - sceneIdx += MAX_LAYERS; - - CCLayer* pLayer = createHiResLayer(sceneIdx); - return pLayer; -} - -//////////////////////////////////// -// -// HiResDemo -// -/////////////////////////////////// -void HiResDemo::onEnter() -{ - CCLayer::onEnter(); - - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); - label->setPosition(ccp(s.width/2, s.height-50)); - addChild(label, 1); - - std::string sSubTitle = subtitle(); - if (sSubTitle.length()) - { - CCLabelTTF *subLabel = CCLabelTTF::labelWithString(sSubTitle.c_str(), "Thonburi", 16); - subLabel->setPosition(ccp(s.width/2, s.height-80)); - addChild(subLabel, 1); - } - - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) ); - - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); - - addChild(menu, 1); -} - -std::string HiResDemo::title() -{ - return "No title"; -} - -std::string HiResDemo::subtitle() -{ - return ""; -} - -void HiResDemo::restartCallback(CCObject* pSender) -{ - CCLayer* pLayer = restartHiResAction(); - - if (pLayer) - { - pLayer->autorelease(); - CCScene* pScene = new HiResTestScene(); - pScene->addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(pScene); - pScene->release(); - } -} - -void HiResDemo::nextCallback(CCObject* pSender) -{ - CCLayer* pLayer = nextHiResAction(); - - if (pLayer) - { - pLayer->autorelease(); - CCScene* pScene = new HiResTestScene(); - pScene->addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(pScene); - pScene->release(); - } -} - -void HiResDemo::backCallback(CCObject* pSender) -{ - CCLayer* pLayer = backHiResAction(); - - if (pLayer) - { - pLayer->autorelease(); - CCScene* pScene = new HiResTestScene(); - pScene->addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(pScene); - pScene->release(); - } -} - -//////////////////////////////////// -// -// HiResTest1 -// -/////////////////////////////////// -void HiResTest1::onEnter() -{ - - HiResDemo::onEnter(); - - CCSize size = CCDirector::sharedDirector()->getWinSize(); - - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png"); - addChild(sprite); - sprite->setPosition(ccp(size.width/2, size.height/2)); -} - -std::string HiResTest1::title() -{ - return "High resolution image test"; -} - -std::string HiResTest1::subtitle() -{ - return "Image without high resolution resource"; -} - -//////////////////////////////////// -// -// HiResTest2 -// -/////////////////////////////////// -void HiResTest2::onEnter() -{ - - HiResDemo::onEnter(); - - CCSize size = CCDirector::sharedDirector()->getWinSize(); - - CCSprite *sprite = CCSprite::spriteWithFile("Images/bugs/picture.png"); - addChild(sprite); - sprite->setPosition(ccp(size.width/2, size.height/2)); -} - -std::string HiResTest2::title() -{ - return "High resolution image test"; -} - -std::string HiResTest2::subtitle() -{ - return "Image with high resolution resource"; -} - -//////////////////////////////////// -// -// HiResTestScene -// -/////////////////////////////////// -bool HiResTestScene::sm_bRitinaDisplay = false; - -void HiResTestScene::runThisTest() -{ - //sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay(); - - CCLayer* pLayer = nextHiResAction(); - addChild(pLayer); - - pLayer->release(); - CCDirector::sharedDirector()->replaceScene(this); -} - -void HiResTestScene::MainMenuCallback(CCObject* pSender) -{ - CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay); - TestScene::MainMenuCallback(pSender); -} diff --git a/tests/tests/HiResTest/HiResTest.h b/tests/tests/HiResTest/HiResTest.h deleted file mode 100644 index b77bbf1493..0000000000 --- a/tests/tests/HiResTest/HiResTest.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _HIRES_TEST_H_ -#define _HIRES_TEST_H_ - -#include "../testBasic.h" - -class HiResDemo : public CCLayer -{ -public: - virtual std::string title(); - virtual std::string subtitle(); - virtual void onEnter(); - - void restartCallback(CCObject* pSender); - void nextCallback(CCObject* pSender); - void backCallback(CCObject* pSender); -}; - -class HiResTest1 : public HiResDemo -{ -public: - virtual void onEnter(); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class HiResTest2 : public HiResDemo -{ -public: - virtual void onEnter(); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class HiResTestScene : public TestScene -{ -public: - virtual void runThisTest(); - virtual void MainMenuCallback(CCObject* pSender); - - static bool sm_bRitinaDisplay; -}; - -#endif diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 013bb30b97..f1eef8fff9 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -1,6 +1,12 @@ #include "MotionStreakTest.h" #include "../testResource.h" +enum { + kTagLabel = 1, + kTagSprite1 = 2, + kTagSprite2 = 3, +}; + CCLayer* nextMotionAction(); CCLayer* backMotionAction(); CCLayer* restartMotionAction(); @@ -20,16 +26,16 @@ void MotionStreakTest1::onEnter() // the root object just rotates around m_root = CCSprite::spriteWithFile(s_pPathR1); addChild(m_root, 1); - m_root->setPosition( CCPointMake(s.width/2, s.height/2) ); + m_root->setPosition(ccp(s.width/2, s.height/2)); // the target object is offset from root, and the streak is moved to follow it m_target = CCSprite::spriteWithFile(s_pPathR1); m_root->addChild(m_target); - m_target->setPosition( CCPointMake(100,0) ); + m_target->setPosition(ccp(s.width/4, 0)); // create the streak object and add it to the scene - m_streak = CCMotionStreak::streakWithFade(2, 3, 32, ccGREEN, s_streak); - addChild( m_streak ); + streak = CCMotionStreak::streakWithFade(2, 3, 32, ccGREEN, s_streak); + addChild(streak); // schedule an update on each frame so we can syncronize the streak with the target schedule(schedule_selector(MotionStreakTest1::onUpdate)); @@ -50,15 +56,12 @@ void MotionStreakTest1::onEnter() CCTintTo::actionWithDuration(0.2f, 255, 255, 255), NULL)); - m_streak->runAction(colorAction); - - // weak ref - streak = m_streak; + streak->runAction(colorAction); } void MotionStreakTest1::onUpdate(float delta) { - m_streak->setPosition( m_target->convertToWorldSpace(CCPointZero) ); + streak->setPosition( m_target->convertToWorldSpace(CCPointZero) ); } std::string MotionStreakTest1::title() @@ -81,13 +84,10 @@ void MotionStreakTest2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // create the streak object and add it to the scene - m_streak = CCMotionStreak::streakWithFade(3, 3, 64, ccWHITE, s_streak ); - addChild( m_streak ); + streak = CCMotionStreak::streakWithFade(3, 3, 64, ccWHITE, s_streak ); + addChild(streak); - m_streak->setPosition( CCPointMake(s.width/2, s.height/2) ); - - // weak ref - streak = m_streak; + streak->setPosition( CCPointMake(s.width/2, s.height/2) ); } void MotionStreakTest2::ccTouchesMoved(CCSet* touches, CCEvent* event) @@ -98,7 +98,7 @@ void MotionStreakTest2::ccTouchesMoved(CCSet* touches, CCEvent* event) CCPoint touchLocation = touch->locationInView(); touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation ); - m_streak->setPosition( touchLocation ); + streak->setPosition( touchLocation ); } std::string MotionStreakTest2::title() @@ -106,6 +106,47 @@ std::string MotionStreakTest2::title() return "MotionStreak test"; } +//------------------------------------------------------------------ +// +// Issue1358 +// +//------------------------------------------------------------------ + +void Issue1358::onEnter() +{ + MotionStreakTest::onEnter(); + + // ask director the the window size + CCSize size = CCDirector::sharedDirector()->getWinSize(); + + streak = CCMotionStreak::streakWithFade(2.0f, 1.0f, 50.0f, ccc3(255, 255, 0), "Icon.png"); + addChild(streak); + + + m_center = ccp(size.width/2, size.height/2); + m_fRadius = size.width/3; + m_fAngle = 0.0f; + + schedule(schedule_selector(Issue1358::update), 0); +} + +void Issue1358::update(float dt) +{ + m_fAngle += 1.0f; + streak->setPosition(ccp(m_center.x + cosf(m_fAngle/180 * M_PI)*m_fRadius, + m_center.y + sinf(m_fAngle/ 180 * M_PI)*m_fRadius)); +} + +std::string Issue1358::title() +{ + return "Issue 1358"; +} + +std::string Issue1358::subtitle() +{ + return "The tail should use the texture"; +} + //------------------------------------------------------------------ // // MotionStreakTest @@ -121,7 +162,7 @@ std::string MotionStreakTest2::title() static int sceneIdx = -1; -#define MAX_LAYER 2 +#define MAX_LAYER 3 CCLayer* createMotionLayer(int nIndex) { @@ -129,6 +170,7 @@ CCLayer* createMotionLayer(int nIndex) { case 0: return new MotionStreakTest1(); case 1: return new MotionStreakTest2(); + case 2: return new Issue1358(); } return NULL; @@ -180,6 +222,11 @@ std::string MotionStreakTest::title() return "No title"; } +std::string MotionStreakTest::subtitle() +{ + return ""; +} + void MotionStreakTest::onEnter() { CCLayer::onEnter(); @@ -187,8 +234,16 @@ void MotionStreakTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); - addChild(label, 1); - label->setPosition( CCPointMake(s.width/2, s.height-50) ); + addChild(label, 0, kTagLabel); + label->setPosition(CCPointMake(s.width/2, s.height-50)); + + string subTitle = this->subtitle(); + if (subTitle.size() > 0) + { + CCLabelTTF *l = CCLabelTTF::labelWithString(subTitle.c_str(), "Thonburi", 16); + addChild(l, 1); + l->setPosition(ccp(s.width/2, s.height-80)); + } CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(MotionStreakTest::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(MotionStreakTest::restartCallback) ); @@ -196,22 +251,22 @@ void MotionStreakTest::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); CCMenuItemToggle *itemMode = CCMenuItemToggle::itemWithTarget(this, menu_selector(MotionStreakTest::modeCallback), - CCMenuItemFont::itemWithString("Fast"), - CCMenuItemFont::itemWithString("Slow"), + CCMenuItemFont::itemWithString("Use High Quality Mode"), + CCMenuItemFont::itemWithString("Use Fast Mode"), NULL); CCMenu *menuMode = CCMenu::menuWithItems(itemMode, NULL); addChild(menuMode); - menuMode->setPosition(ccp(30, 65)); + menuMode->setPosition(ccp(s.width/2, s.height/4)); } void MotionStreakTest::modeCallback(CCObject *pSender) diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.h b/tests/tests/MotionStreakTest/MotionStreakTest.h index 0925f46a96..bde330acfb 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.h +++ b/tests/tests/MotionStreakTest/MotionStreakTest.h @@ -13,6 +13,7 @@ public: ~MotionStreakTest(void); virtual std::string title(); + virtual std::string subtitle(); virtual void onEnter(); void restartCallback(CCObject* pSender); @@ -28,7 +29,6 @@ class MotionStreakTest1 : public MotionStreakTest protected: CCNode* m_root; CCNode* m_target; - CCMotionStreak* m_streak; public: virtual void onEnter(); @@ -41,7 +41,6 @@ class MotionStreakTest2 : public MotionStreakTest protected: CCNode* m_root; CCNode* m_target; - CCMotionStreak* m_streak; public: virtual void onEnter(); @@ -49,6 +48,19 @@ public: virtual std::string title(); }; +class Issue1358 : public MotionStreakTest +{ +public: + virtual std::string title(); + virtual std::string subtitle(); + virtual void onEnter(); + virtual void update(float dt); +private: + CCPoint m_center; + float m_fRadius; + float m_fAngle; +}; + class MotionStreakTestScene : public TestScene { public: diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index fec426fcf6..88abd0ddc9 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -13,7 +13,7 @@ enum { enum { kMaxParticles = 14000, - kNodesIncrease = 100, + kNodesIncrease = 500, }; static int s_nParCurIdx = 0; diff --git a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp index 22ac12bdf6..bb80ddca78 100644 --- a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp @@ -1,8 +1,8 @@ #include "PerformanceSpriteTest.h" enum { - kMaxNodes = 5000, - kNodesIncrease = 50, + kMaxNodes = 50000, + kNodesIncrease = 250, TEST_COUNT = 7, }; diff --git a/tests/tests/controller.cpp b/tests/tests/controller.cpp index 84904394db..1f722aa004 100644 --- a/tests/tests/controller.cpp +++ b/tests/tests/controller.cpp @@ -81,8 +81,6 @@ static TestScene* CreateTestScene(int nIdx) pScene = new Box2dTestBedScene(); break; case TEST_EFFECT_ADVANCE: pScene = new EffectAdvanceScene(); break; - case TEST_HIRES: - pScene = new HiResTestScene(); break; case TEST_ACCELEROMRTER: pScene = new AccelerometerTestScene(); break; #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) @@ -104,8 +102,6 @@ static TestScene* CreateTestScene(int nIdx) #endif case TEST_USERDEFAULT: pScene = new UserDefaultTestScene(); break; - case TEST_DIRECTOR: - pScene = new DirectorTestScene(); break; case TEST_BUGS: pScene = new BugsTestScene(); break; case TEST_FONTS: diff --git a/tests/tests/tests.h b/tests/tests/tests.h index d790dd5614..993be8bb71 100644 --- a/tests/tests/tests.h +++ b/tests/tests/tests.h @@ -27,7 +27,6 @@ #include "Box2DTest/Box2dTest.h" #include "Box2DTestBed/Box2dView.h" #include "EffectsAdvancedTest/EffectsAdvancedTest.h" -#include "HiResTest/HiResTest.h" #include "AccelerometerTest/AccelerometerTest.h" #include "KeypadTest/KeypadTest.h" #include "PerformanceTest/PerformanceTest.h" @@ -35,7 +34,6 @@ #include "CocosDenshionTest/CocosDenshionTest.h" #include "CurlTest/CurlTest.h" #include "UserDefaultTest/UserDefaultTest.h" -#include "DirectorTest/DirectorTest.h" #include "BugsTest/BugsTest.h" #include "Texture2dTest/Texture2dTest.h" #include "FontTest/FontTest.h" @@ -88,7 +86,6 @@ enum TEST_BOX2D, TEST_BOX2DBED, TEST_EFFECT_ADVANCE, - TEST_HIRES, TEST_ACCELEROMRTER, TEST_KEYPAD, TEST_COCOSDENSHION, @@ -96,7 +93,6 @@ enum TEST_ZWOPTEX, TEST_CURL, TEST_USERDEFAULT, - TEST_DIRECTOR, TEST_BUGS, TEST_FONTS, TEST_CURRENT_LANGUAGE, @@ -137,7 +133,6 @@ const std::string g_aTestNames[TESTS_COUNT] = { "Box2dTest", "Box2dTestBed", "EffectAdvancedTest", - "HiResTest", "Accelerometer", "KeypadTest", "CocosDenshionTest", @@ -145,7 +140,6 @@ const std::string g_aTestNames[TESTS_COUNT] = { "ZwoptexTest", "CurlTest", "UserDefaultTest", - "DirectorTest", "BugsTest", "FontTest", "CurrentLanguageTest",