axmol/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp

633 lines
20 KiB
C++
Raw Normal View History

2015-04-23 18:03:03 +08:00
#include "SpritePolygonTest.h"
#include "../testResource.h"
2015-06-04 15:43:31 +08:00
#include "ui/CocosGUI.h"
2015-04-23 18:03:03 +08:00
USING_NS_CC;
2015-07-31 15:49:44 +08:00
2015-04-23 18:03:03 +08:00
SpritePolygonTest::SpritePolygonTest()
{
ADD_TEST_CASE(SpritePolygonTest1);
2015-06-04 15:43:31 +08:00
ADD_TEST_CASE(SpritePolygonTest2);
2015-07-31 15:49:44 +08:00
ADD_TEST_CASE(SpritePolygonTest3);
ADD_TEST_CASE(SpritePolygonTest4);
ADD_TEST_CASE(SpritePolygonTest5);
ADD_TEST_CASE(SpritePolygonPerformanceTestDynamic);
ADD_TEST_CASE(SpritePerformanceTestDynamic);
2015-04-23 18:03:03 +08:00
}
2015-07-31 15:49:44 +08:00
2015-08-26 18:14:25 +08:00
SpritePolygonTestCase::SpritePolygonTestCase()
{
_isDebugDraw = true;
_isNeedDebugMenu = true;
}
SpritePolygonTestCase::~SpritePolygonTestCase()
{
_drawNodes.clear();
}
void SpritePolygonTestCase::onEnter()
{
TestCase::onEnter();
Director::getInstance()->setClearColor(Color4F(102.0f/255.0f, 184.0f/255.0f, 204.0f/255.0f, 1.0f));
}
void SpritePolygonTestCase::onExit()
2015-06-04 15:43:31 +08:00
{
Director::getInstance()->setClearColor(Color4F::BLACK);
2015-08-26 18:14:25 +08:00
TestCase::onExit();
}
bool SpritePolygonTestCase::init()
{
if(TestCase::init())
{
if (_isNeedDebugMenu)
{
TTFConfig ttfConfig("fonts/arial.ttf", 10);
auto label = Label::createWithTTF(ttfConfig,"DebugDraw OFF");
auto menuItem = MenuItemLabel::create(label, [=](Ref *ref){
if (_isDebugDraw){
_isDebugDraw = false;
label->setString("DebugDraw ON");
for (int i = 0; i < _drawNodes.size(); i++)
{
_drawNodes.at(i)->setVisible(false);
}
}else{
_isDebugDraw = true;
label->setString("DebugDraw OFF");
for (int i = 0; i < _drawNodes.size(); i++)
{
_drawNodes.at(i)->setVisible(true);
updateDrawNode();
}
}
});
auto menu = Menu::create(menuItem, nullptr);
menu->setPosition(Vec2::ZERO);
menuItem->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
menuItem->setPosition( VisibleRect::leftBottom() + Vec2(0, VisibleRect::leftTop().y/4));
this->addChild(menu, 9999);
}
return true;
}
return false;
2015-06-04 15:43:31 +08:00
}
2015-07-31 15:49:44 +08:00
2015-08-26 18:14:25 +08:00
void SpritePolygonTestCase::updateDrawNode()
{
if (_isDebugDraw && _drawNodes.size() > 0) {
for (int i = 0; i < _drawNodes.size(); i++)
{
auto drawnode = _drawNodes.at(i);
auto sp = (Sprite*)drawnode->getParent();
if(!sp) return;
auto polygoninfo = sp->getPolygonInfo();
drawnode->clear();
auto count = polygoninfo.triangles.indexCount/3;
auto indices = polygoninfo.triangles.indices;
auto verts = polygoninfo.triangles.verts;
for(ssize_t i = 0; i < count; i++)
{
//draw 3 lines
Vec3 from =verts[indices[i*3]].vertices;
Vec3 to = verts[indices[i*3+1]].vertices;
drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
from =verts[indices[i*3+1]].vertices;
to = verts[indices[i*3+2]].vertices;
drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
from =verts[indices[i*3+2]].vertices;
to = verts[indices[i*3]].vertices;
drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
}
}
}
}
bool SpritePolygonTestDemo::init()
{
if (SpritePolygonTestCase::init()) {
initSprites();
initTouches();
return true;
}
return false;
}
void SpritePolygonTestDemo::initTouches()
2015-06-04 15:43:31 +08:00
{
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = [&](Touch* touch, Event* event){
return true;
};
touchListener->onTouchMoved = [&](Touch* touch, Event* event){
auto pos = touch->getDelta();
2015-08-26 18:14:25 +08:00
float newScale = clampf(_polygonSprite->getScale() + pos.x * 0.01f, 0.1f, 2.f);
_polygonSprite->setScale(newScale);
_normalSprite->setScale(newScale);
updateDrawNode();
2015-06-04 15:43:31 +08:00
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
}
2015-07-31 15:49:44 +08:00
2015-08-26 18:14:25 +08:00
SpritePolygonTest1::SpritePolygonTest1()
{
_title = "SpritePolygon Creation";
_subtitle = "Sprite::create(AutoPolygon::generatePolygon(filename))";
}
void SpritePolygonTest1::initSprites()
2015-06-04 15:43:31 +08:00
{
auto s = Director::getInstance()->getWinSize();
auto offset = Vec2(0.15*s.width,0);
2015-08-26 18:14:25 +08:00
auto filename = s_pathGrossini;
//Sprite
auto pinfo = AutoPolygon::generatePolygon(filename);
_polygonSprite = Sprite::create(pinfo);
_polygonSprite->setTag(101);
addChild(_polygonSprite);
_polygonSprite->setPosition(Vec2(s)/2 + offset);
_normalSprite = Sprite::create(filename);
_normalSprite->setTag(100);
addChild(_normalSprite);
_normalSprite->setPosition(Vec2(s)/2 - offset);
//DrawNode
auto spDrawNode = DrawNode::create();
spDrawNode->setTag(_normalSprite->getTag());
spDrawNode->clear();
_normalSprite->addChild(spDrawNode);
_drawNodes.pushBack(spDrawNode);
auto sppDrawNode = DrawNode::create();
sppDrawNode->setTag(_polygonSprite->getTag());
sppDrawNode->clear();
_polygonSprite->addChild(sppDrawNode);
_drawNodes.pushBack(sppDrawNode);
//Label
2015-06-04 15:43:31 +08:00
TTFConfig ttfConfig("fonts/arial.ttf", 8);
std::string temp = "Sprite:\nPixels drawn: ";
2015-08-26 18:14:25 +08:00
auto spSize = _normalSprite->getContentSize();
2015-06-04 15:43:31 +08:00
auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString());
2015-08-26 18:14:25 +08:00
_normalSprite->addChild(spArea);
2015-06-04 15:43:31 +08:00
spArea->setAnchorPoint(Vec2(0,1));
temp = "SpritePolygon:\nPixels drawn: ";
auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString();
auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount);
2015-08-26 18:14:25 +08:00
_polygonSprite->addChild(sppArea);
2015-06-04 15:43:31 +08:00
sppArea->setAnchorPoint(Vec2(0,1));
2015-08-26 18:14:25 +08:00
updateDrawNode();
2015-06-04 15:43:31 +08:00
}
2015-07-31 15:49:44 +08:00
2015-06-04 15:43:31 +08:00
SpritePolygonTest2::SpritePolygonTest2()
{
_title = "SpritePolygon Creation with a rect";
_subtitle = "Sprite::create(AutoPolygon::generatePolygon(filename, rect))";
}
2015-07-31 15:49:44 +08:00
2015-08-26 18:14:25 +08:00
void SpritePolygonTest2::initSprites()
2015-06-04 15:43:31 +08:00
{
2015-08-26 18:14:25 +08:00
auto s = Director::getInstance()->getWinSize();
auto offset = Vec2(0.15*s.width,0);
2015-06-04 15:43:31 +08:00
auto filename = s_pathGrossini;
Rect head = Rect(30,25,25,25);
2015-08-26 18:14:25 +08:00
//Sprite
2015-06-04 15:43:31 +08:00
auto pinfo = AutoPolygon::generatePolygon(filename, head);
2015-08-26 18:14:25 +08:00
_polygonSprite = Sprite::create(pinfo);
_polygonSprite->setTag(101);
addChild(_polygonSprite);
_polygonSprite->setPosition(Vec2(s)/2 + offset);
2015-06-04 15:43:31 +08:00
2015-08-26 18:14:25 +08:00
_normalSprite = Sprite::create(filename,head);
_normalSprite->setTag(100);
addChild(_normalSprite);
_normalSprite->setPosition(Vec2(s)/2 - offset);
//DrawNode
auto spDrawNode = DrawNode::create();
_drawNodes.pushBack(spDrawNode);
spDrawNode->setTag(_normalSprite->getTag());
spDrawNode->clear();
_normalSprite->addChild(spDrawNode);
auto sppDrawNode = DrawNode::create();
_drawNodes.pushBack(sppDrawNode);
sppDrawNode->setTag(_polygonSprite->getTag());
sppDrawNode->clear();
_polygonSprite->addChild(sppDrawNode);
2015-06-04 15:43:31 +08:00
2015-08-26 18:14:25 +08:00
//Label
2015-06-04 15:43:31 +08:00
TTFConfig ttfConfig("fonts/arial.ttf", 8);
std::string temp = "Sprite:\nPixels drawn: ";
2015-08-26 18:14:25 +08:00
auto spSize = _normalSprite->getContentSize();
2015-06-04 15:43:31 +08:00
auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString());
2015-08-26 18:14:25 +08:00
_normalSprite->addChild(spArea);
2015-06-04 15:43:31 +08:00
spArea->setAnchorPoint(Vec2(0,1));
temp = "SpritePolygon:\nPixels drawn: ";
auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString();
auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount);
2015-08-26 18:14:25 +08:00
_polygonSprite->addChild(sppArea);
2015-06-04 15:43:31 +08:00
sppArea->setAnchorPoint(Vec2(0,1));
2015-08-26 18:14:25 +08:00
updateDrawNode();
}
bool SpritePolygonTestSlider::init()
{
if(SpritePolygonTestCase::init())
{
initSliders();
initSprites();
return true;
}
return false;
}
void SpritePolygonTestSlider::initSliders()
{
auto vsize =Director::getInstance()->getVisibleSize();
cocos2d::ui::Slider* slider = cocos2d::ui::Slider::create();
slider->loadBarTexture("cocosui/sliderTrack.png");
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
slider->setPosition(Vec2(vsize.width/2, vsize.height/4));
slider->addEventListener(CC_CALLBACK_2(SpritePolygonTestSlider::changeEpsilon, this));
slider->setPercent((int)(sqrtf(1.0f/19.0f)*100));
auto ttfConfig = TTFConfig("fonts/arial.ttf", 8);
_epsilonLabel = Label::createWithTTF(ttfConfig, "Epsilon: 2.0");
addChild(_epsilonLabel);
_epsilonLabel->setPosition(Vec2(vsize.width/2, vsize.height/4 + 15));
addChild(slider);
}
void SpritePolygonTestSlider::makeSprites(const std::string* list, const int count, const float y)
{
auto vsize =Director::getInstance()->getVisibleSize();
float offset = (vsize.width-100)/(count-1);
for(int i = 0; i < count; i++)
{
auto sp = makeSprite(list[i], Vec2(50+offset*i, y));
addChild(sp);
}
}
void SpritePolygonTestSlider::changeEpsilon(cocos2d::Ref *pSender, cocos2d::ui::Slider::EventType type)
{
if (type == cocos2d::ui::Slider::EventType::ON_PERCENTAGE_CHANGED)
{
cocos2d::ui::Slider* slider = dynamic_cast<cocos2d::ui::Slider*>(pSender);
float epsilon = powf(slider->getPercent()/100.0,2)*19.0f + 1.0f;
for(auto child : _children)
{
if(child->getName().size())
{
Sprite *sp = (Sprite*)child;
auto file = sp->getName();
auto pinfo = AutoPolygon::generatePolygon(file, Rect::ZERO, epsilon);
sp->setPolygonInfo(pinfo);
updateLabel(sp, pinfo);
}
}
_epsilonLabel->setString("Epsilon: "+ Value(epsilon).asString());
updateDrawNode();
}
}
void SpritePolygonTestSlider::updateLabel(const cocos2d::Sprite *sp, const PolygonInfo &pinfo)
{
Label *label = (Label*)(sp->getChildByName(sp->getName()));
auto filename = sp->getName();
auto size = pinfo.rect.size/Director::getInstance()->getContentScaleFactor();
label->setString(filename+"\nVerts: "+Value((int)pinfo.getVertCount()).asString()+ "\nPixels: "+Value((int)(pinfo.getArea()/(size.width*size.height)*100)).asString()+"%");
}
Sprite* SpritePolygonTestSlider::makeSprite(const std::string &filename, const Vec2 &pos)
{
//Sprite
auto quadSize = Sprite::create(filename)->getContentSize();
int originalSize = quadSize.width * quadSize.height;
auto pinfo = AutoPolygon::generatePolygon(filename);
auto ret = Sprite::create(pinfo);
ret->setName(filename);
ret->setTag(_tagIndex);
_tagIndex++;
ret->setPosition(pos);
//DrawNode
auto drawNode = DrawNode::create();
_drawNodes.pushBack(drawNode);
drawNode->setTag(ret->getTag());
drawNode->clear();
ret->addChild(drawNode);
//Label
auto ttfConfig = TTFConfig("fonts/arial.ttf", 8);
auto spArea = Label::createWithTTF(ttfConfig, filename+"\nVerts: "+Value((int)pinfo.getVertCount()).asString()+ "\nPixels: "+Value((int)(pinfo.getArea()/originalSize*100)).asString()+"%");
ret->addChild(spArea);
spArea->setAnchorPoint(Vec2(0,1));
spArea->setName(filename);
ret->setAnchorPoint(Vec2(0.5, 0));
updateDrawNode();
return ret;
2015-06-04 15:43:31 +08:00
}
2015-07-31 15:49:44 +08:00
SpritePolygonTest3::SpritePolygonTest3()
{
_title = "Optimization Value (default:2.0)";
_subtitle = "";
2015-08-26 18:14:25 +08:00
_tagIndex = 100;
}
void SpritePolygonTest3::initSprites()
{
2015-07-31 15:49:44 +08:00
auto vsize =Director::getInstance()->getVisibleSize();
std::string list[] = {
"Images/arrows.png",
"Images/CyanTriangle.png",
s_pathB2,
"Images/elephant1_Diffuse.png"
};
int count = 4;
makeSprites(list, count, vsize.height/2);
}
2015-06-04 15:43:31 +08:00
2015-07-31 15:49:44 +08:00
SpritePolygonTest4::SpritePolygonTest4()
{
_title = "Optimization Value (default:2.0)";
_subtitle = "";
2015-08-26 18:14:25 +08:00
_tagIndex = 100;
}
void SpritePolygonTest4::initSprites()
{
2015-07-31 15:49:44 +08:00
auto vsize =Director::getInstance()->getVisibleSize();
int count = 3;
std::string list[] = {
s_pathGrossini,
"Images/grossinis_sister1.png",
"Images/grossinis_sister2.png"
};
makeSprites(list, count, vsize.height/5*2);
}
SpritePolygonTest5::SpritePolygonTest5()
{
_title = "SpritePolygon Actions";
_subtitle = "Touch screen to add sprite with random action.";
2015-08-26 18:14:25 +08:00
_tagIndex = 100;
}
bool SpritePolygonTest5::init()
{
if (SpritePolygonTestCase::init())
{
_polygonInfo = AutoPolygon::generatePolygon(s_pathGrossini);
loadDefaultSprites();
initTouch();
scheduleUpdate();
return true;
}
return false;
2015-07-31 15:49:44 +08:00
}
void SpritePolygonTest5::initTouch()
{
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = [&](Touch* touch, Event* event){
return true;
};
touchListener->onTouchEnded = [&](Touch* touch, Event* event){
auto pos = touch->getLocation();
addSpritePolygon(pos);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
}
void SpritePolygonTest5::loadDefaultSprites()
{
auto s = Director::getInstance()->getVisibleSize();
const int DEFAULT_SPRITEPOLYGON_COUNT = 8;
Sprite* sprites[DEFAULT_SPRITEPOLYGON_COUNT];
for (int i = 0; i < DEFAULT_SPRITEPOLYGON_COUNT; i++) {
sprites[i] = Sprite::create(_polygonInfo);
2015-08-26 18:14:25 +08:00
sprites[i]->setTag(_tagIndex);
_tagIndex++;
2015-07-31 15:49:44 +08:00
sprites[i]->setPosition(s.width * CCRANDOM_0_1(), s.height * CCRANDOM_0_1());
this->addChild(sprites[i]);
2015-08-26 18:14:25 +08:00
auto drawNode = DrawNode::create();
_drawNodes.pushBack(drawNode);
drawNode->setTag(sprites[i]->getTag());
drawNode->clear();
sprites[i]->addChild(drawNode);
2015-07-31 15:49:44 +08:00
}
sprites[0]->setColor(Color3B::RED);
sprites[1]->setOpacity(100);
sprites[2]->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png"));
sprites[3]->setTextureRect(Rect(0,0,100,30));
sprites[4]->setScale(0.5f, 2.0f);
sprites[5]->setFlippedY(true);
sprites[6]->setSkewX(60);
sprites[7]->setRotation(90);
2015-08-26 18:14:25 +08:00
updateDrawNode();
2015-07-31 15:49:44 +08:00
}
void SpritePolygonTest5::addSpritePolygon(const Vec2& pos)
{
auto sprite = Sprite::create(_polygonInfo);
2015-08-26 18:14:25 +08:00
sprite->setTag(_tagIndex);
_tagIndex++;
2015-07-31 15:49:44 +08:00
sprite->setPosition(pos);
this->addChild(sprite);
2015-08-26 18:14:25 +08:00
auto drawNode = DrawNode::create();
_drawNodes.pushBack(drawNode);
drawNode->setTag(sprite->getTag());
drawNode->clear();
sprite->addChild(drawNode);
2015-07-31 15:49:44 +08:00
ActionInterval* action;
float random = CCRANDOM_0_1();
if( random < 0.20 )
action = ScaleBy::create(3, 2);
else if(random < 0.40)
action = RotateBy::create(3, 360);
else if( random < 0.60)
action = Blink::create(1, 3);
else if( random < 0.8 )
action = TintBy::create(2, 0, -255, -255);
else
action = FadeOut::create(2);
2015-08-26 18:14:25 +08:00
auto seq = Sequence::create( action, action->reverse(), nullptr );
sprite->runAction(RepeatForever::create(seq));
}
void SpritePolygonTest5::update(float dt)
{
updateDrawNode();
2015-07-31 15:49:44 +08:00
}
2015-06-04 15:43:31 +08:00
SpritePolygonPerformance::SpritePolygonPerformance()
{
TTFConfig ttfConfig("fonts/arial.ttf", 10);
2015-08-26 18:14:25 +08:00
_perfLabel = Label::createWithTTF(ttfConfig, "performance test");
addChild(_perfLabel);
_perfLabel->setPosition(Director::getInstance()->getVisibleSize().width/2, 80);
2015-08-26 18:14:25 +08:00
_spriteCount = _vertCount = _triCount = _pixelCount = _continuousLowDt =0;
auto size = Director::getInstance()->getVisibleSize();
2015-08-26 18:14:25 +08:00
_elapsedTime = 0;
_posX = _leftX = size.width*0.15;
_rightX = size.width*0.85;
_posY = size.height/2;
2015-04-28 20:10:56 +08:00
prevDt = 0.016f;
goRight = true;
ended = false;
2015-08-26 18:14:25 +08:00
_continuousHighDtTime = 0.0;
_waitingTime = 0.0;
_isNeedDebugMenu = false;
}
bool SpritePolygonPerformance::init()
{
if (SpritePolygonTestCase::init()) {
initIncrementStats();
scheduleUpdate();
return true;
}
return false;
}
2015-07-31 15:49:44 +08:00
void SpritePolygonPerformance::updateLabel()
{
2015-08-26 18:14:25 +08:00
std::string temp = "Nodes: " + Value(_spriteCount).asString() + " Triangles: " + Value(_triCount).asString() + "\nPixels: " + Value(_pixelCount).asString() + " Vertices: " + Value(_vertCount).asString();
if(!ended)
2015-08-26 18:14:25 +08:00
_perfLabel->setString("Nodes: " + Value(_spriteCount).asString() + " Triangles: " + Value(_triCount).asString() + "\nPixels: " + Value(_pixelCount).asString() + " Vertices: " + Value(_vertCount).asString());
}
2015-07-31 15:49:44 +08:00
Node *SpritePolygonPerformance::makeSprite()
{
2015-08-26 18:14:25 +08:00
return nullptr;
}
2015-07-31 15:49:44 +08:00
void SpritePolygonPerformance::update(float dt)
{
dt = dt*0.3 + prevDt*0.7;
prevDt = dt;
2015-08-26 18:14:25 +08:00
_elapsedTime += dt;
int loops = (0.025-dt)*1000;
if(dt < 0.025 && loops>0)
{
2015-08-26 18:14:25 +08:00
_continuousHighDtTime = clampf(_continuousHighDtTime-dt*2, 0.0, 1.0);
_waitingTime = clampf(_waitingTime-dt, 0.0, 5.0);
_continuousLowDt++;
}
else
{
2015-08-26 18:14:25 +08:00
_continuousHighDtTime+=dt;
_continuousLowDt = 0;
}
2015-08-26 18:14:25 +08:00
if (_continuousLowDt >= 5 && loops > 0) {
for(int i = 0; i < loops; i++)
{
if(_posX >= _rightX)
{
goRight = false;
}
else if(_posX <= _leftX)
{
goRight = true;
}
auto s = makeSprite();
addChild(s);
s->setPosition(_posX, _posY);
if(goRight)
_posX++;
else
_posX--;
incrementStats();
}
updateLabel();
}
//if we have 10 continuous low dt, then we will start to create more sprites
2015-08-26 18:14:25 +08:00
else if(_continuousHighDtTime >= .5 || _waitingTime > 3.0){
// its now 1 seconds with high DT time, time to end
ended = true;
unscheduleUpdate();
2015-08-26 18:14:25 +08:00
_perfLabel->setString("Test ended in " + Value(_elapsedTime).asString() + " seconds\nNodes: " + Value(_spriteCount).asString() + " Triangles: " + Value(_triCount).asString() + "\nPixels: " + Value(_pixelCount).asString() + " Vertices: " + Value(_vertCount).asString());
_subtitleLabel->setString("Test ended");
}
else{
2015-08-26 18:14:25 +08:00
_waitingTime += dt;
}
}
2015-07-31 15:49:44 +08:00
void SpritePolygonPerformance::incrementStats()
{
2015-08-26 18:14:25 +08:00
_spriteCount ++;
_vertCount += _incVert;
_triCount += _incTri;
_pixelCount += _incPix;
}
2015-07-31 15:49:44 +08:00
2015-06-04 15:43:31 +08:00
void SpritePolygonPerformanceTestDynamic::initIncrementStats()
{
2015-08-26 18:14:25 +08:00
_pinfo = AutoPolygon::generatePolygon(s_pathGrossini);
_incVert = _pinfo.getVertCount();
_incTri = _pinfo.getTrianglesCount();
_incPix = _pinfo.getArea();
}
SpritePolygonPerformanceTestDynamic::SpritePolygonPerformanceTestDynamic()
{
_title = "Dynamic SpritePolygon Performance";
_subtitle = "Test running, please wait until it ends";
}
2015-07-31 15:49:44 +08:00
2015-06-04 15:43:31 +08:00
Sprite* SpritePolygonPerformanceTestDynamic::makeSprite()
{
2015-06-04 15:43:31 +08:00
auto ret = Sprite::create(_pinfo);
ret->runAction(RepeatForever::create(RotateBy::create(1.0,360.0)));
return ret;
}
2015-06-04 15:43:31 +08:00
SpritePerformanceTestDynamic::SpritePerformanceTestDynamic()
{
2015-06-04 15:43:31 +08:00
_title = "Dynamic Sprite Performance";
_subtitle = "Test running, please wait until it ends";
}
2015-07-31 15:49:44 +08:00
2015-06-04 15:43:31 +08:00
void SpritePerformanceTestDynamic::initIncrementStats()
{
auto t = Sprite::create(s_pathGrossini);
_incVert = 4;
_incTri = 2;
_incPix = t->getContentSize().width * t->getContentSize().height;
}
2015-07-31 15:49:44 +08:00
Sprite* SpritePerformanceTestDynamic::makeSprite()
{
2015-06-04 15:43:31 +08:00
auto ret = Sprite::create(s_pathGrossini);
ret->runAction(RepeatForever::create(RotateBy::create(1.0,360.0)));
return ret;
}