mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1007 from minggo/gles20
issue #1310: synchronize some codes
This commit is contained in:
commit
1d77d53af3
|
@ -1 +1 @@
|
|||
c16d1dddb12b5a7e7e715f234dfd031657369f96
|
||||
108734e79d5bc98e94e74a0803cbcc30dd687eb7
|
|
@ -119,7 +119,7 @@ void ChipmunkAccelTouchTestLayer::initPhysics()
|
|||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
// init chipmunk
|
||||
cpInitChipmunk();
|
||||
//cpInitChipmunk();
|
||||
|
||||
m_pSpace = cpSpaceNew();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
|
@ -73,6 +73,11 @@ void DrawPrimitivesTest::draw()
|
|||
|
||||
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);
|
||||
glLineWidth(2);
|
||||
|
@ -90,6 +95,7 @@ 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)};
|
||||
ccDrawSolidPoly( vertices3, 4, ccc4f(1,1,0,1) );
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -13,7 +13,7 @@ enum {
|
|||
|
||||
enum {
|
||||
kMaxParticles = 14000,
|
||||
kNodesIncrease = 100,
|
||||
kNodesIncrease = 500,
|
||||
};
|
||||
|
||||
static int s_nParCurIdx = 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "PerformanceSpriteTest.h"
|
||||
|
||||
enum {
|
||||
kMaxNodes = 5000,
|
||||
kNodesIncrease = 50,
|
||||
kMaxNodes = 50000,
|
||||
kNodesIncrease = 250,
|
||||
|
||||
TEST_COUNT = 7,
|
||||
};
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue