Merge pull request #4656 from dabingnn/develop_FixTestCase_LabelTest

Develop fix test case label test
This commit is contained in:
James Chen 2013-12-24 23:20:45 -08:00
commit 3da854c8cd
2 changed files with 36 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#include "LabelTest.h" #include "LabelTest.h"
#include "../testResource.h" #include "../testResource.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h"
enum { enum {
kTagTileMap = 1, kTagTileMap = 1,
@ -207,12 +209,20 @@ void Atlas1::draw()
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// GL_TEXTURE_2D // GL_TEXTURE_2D
_textureAtlas->drawQuads(); CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(Atlas1::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
// [textureAtlas drawNumberOfQuads:3]; // [textureAtlas drawNumberOfQuads:3];
} }
void Atlas1::onDraw()
{
_textureAtlas->drawQuads();
}
std::string Atlas1::title() const std::string Atlas1::title() const
{ {
return "CCTextureAtlas"; return "CCTextureAtlas";
@ -515,6 +525,14 @@ Atlas4::Atlas4()
} }
void Atlas4::draw() void Atlas4::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(Atlas4::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
}
void Atlas4::onDraw()
{ {
auto s = Director::getInstance()->getWinSize(); auto s = Director::getInstance()->getWinSize();
DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) ); DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) );
@ -1594,6 +1612,14 @@ std::string LabelBMFontBounds::subtitle() const
} }
void LabelBMFontBounds::draw() void LabelBMFontBounds::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
}
void LabelBMFontBounds::onDraw()
{ {
auto labelSize = label1->getContentSize(); auto labelSize = label1->getContentSize();
auto origin = Director::getInstance()->getWinSize(); auto origin = Director::getInstance()->getWinSize();

View File

@ -36,6 +36,8 @@ public:
virtual std::string title() const override; virtual std::string title() const override;
virtual std::string subtitle() const override; virtual std::string subtitle() const override;
virtual void draw(); virtual void draw();
protected:
void onDraw();
}; };
class LabelAtlasTest : public AtlasDemo class LabelAtlasTest : public AtlasDemo
@ -102,6 +104,8 @@ public:
virtual std::string title() const override; virtual std::string title() const override;
virtual std::string subtitle() const override; virtual std::string subtitle() const override;
protected:
void onDraw();
}; };
class Atlas5 : public AtlasDemo class Atlas5 : public AtlasDemo
@ -372,6 +376,8 @@ public:
virtual void draw(); virtual void draw();
virtual std::string title() const override; virtual std::string title() const override;
virtual std::string subtitle() const override; virtual std::string subtitle() const override;
protected:
void onDraw();
private: private:
LabelBMFont *label1; LabelBMFont *label1;
}; };