Merge branch 'develop_migrate_math_lib_merge' into develop_migrate_math_lib

This commit is contained in:
Huabing.Xu 2014-04-24 17:16:51 +08:00
commit 1137df57e0
5 changed files with 16 additions and 11 deletions

View File

@ -248,18 +248,16 @@ void LabelAtlas::updateColor()
} }
//CCLabelAtlas - draw //CCLabelAtlas - draw
#if CC_LABELATLAS_DEBUG_DRAW
void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
{ {
AtlasNode::draw(renderer, transform, transformUpdated); AtlasNode::draw(renderer, transform, transformUpdated);
#if CC_LABELATLAS_DEBUG_DRAW
_customDebugDrawCommand.init(_globalZOrder); _customDebugDrawCommand.init(_globalZOrder);
_customDebugDrawCommand.func = CC_CALLBACK_0(LabelAtlas::drawDebugData, this,transform,transformUpdated); _customDebugDrawCommand.func = CC_CALLBACK_0(LabelAtlas::drawDebugData, this,transform,transformUpdated);
renderer->addCommand(&_customDebugDrawCommand); renderer->addCommand(&_customDebugDrawCommand);
#endif
} }
#if CC_LABELATLAS_DEBUG_DRAW
void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated) void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated)
{ {
Director* director = Director::getInstance(); Director* director = Director::getInstance();

View File

@ -82,7 +82,10 @@ public:
virtual void setString(const std::string &label) override; virtual void setString(const std::string &label) override;
virtual const std::string& getString(void) const override; virtual const std::string& getString(void) const override;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
#if CC_LABELATLAS_DEBUG_DRAW
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
#endif
protected: protected:
LabelAtlas() LabelAtlas()
@ -98,7 +101,7 @@ protected:
#if CC_LABELATLAS_DEBUG_DRAW #if CC_LABELATLAS_DEBUG_DRAW
CustomCommand _customDebugDrawCommand; CustomCommand _customDebugDrawCommand;
void drawDebugData(const Matrix& transform, bool transformUpdated); void drawDebugData(const Matrix& transform, bool transformUpdated);
#endif //CC_SPRITE_DEBUG_DRAW #endif
// string to render // string to render
std::string _string; std::string _string;

View File

@ -206,18 +206,16 @@ Rect LabelBMFont::getBoundingBox() const
{ {
return _label->getBoundingBox(); return _label->getBoundingBox();
} }
#if CC_LABELBMFONT_DEBUG_DRAW
void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
{ {
Node::draw(renderer, transform, transformUpdated); Node::draw(renderer, transform, transformUpdated);
#if CC_LABELBMFONT_DEBUG_DRAW
_customDebugDrawCommand.init(_globalZOrder); _customDebugDrawCommand.init(_globalZOrder);
_customDebugDrawCommand.func = CC_CALLBACK_0(LabelBMFont::drawDebugData, this,transform,transformUpdated); _customDebugDrawCommand.func = CC_CALLBACK_0(LabelBMFont::drawDebugData, this,transform,transformUpdated);
renderer->addCommand(&_customDebugDrawCommand); renderer->addCommand(&_customDebugDrawCommand);
#endif
} }
#if CC_LABELBMFONT_DEBUG_DRAW
void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated) void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated)
{ {
Director* director = Director::getInstance(); Director* director = Director::getInstance();

View File

@ -123,13 +123,15 @@ public:
virtual Rect getBoundingBox() const override; virtual Rect getBoundingBox() const override;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
#if CC_LABELBMFONT_DEBUG_DRAW
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
private: #endif
private:
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW
CustomCommand _customDebugDrawCommand; CustomCommand _customDebugDrawCommand;
void drawDebugData(const Matrix& transform, bool transformUpdated); void drawDebugData(const Matrix& transform, bool transformUpdated);
#endif // CC_LABELBMFONT_DEBUG_DRAW #endif
// name of fntFile // name of fntFile
std::string _fntFile; std::string _fntFile;

View File

@ -1111,6 +1111,10 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
{ {
if (!dynamic_cast<Layout*>(widget)) if (!dynamic_cast<Layout*>(widget))
{ {
if (child->getPositionType() == cocos2d::ui::POSITION_PERCENT)
{
child->setPositionPercent(Vector2(child->getPositionPercent().x + 0.5f, child->getPositionPercent().y + 0.5f));
}
child->setPosition(Vector2(child->getPositionX() + widget->getSize().width / 2.0f, child->getPositionY() + widget->getSize().height / 2.0f)); child->setPosition(Vector2(child->getPositionX() + widget->getSize().width / 2.0f, child->getPositionY() + widget->getSize().height / 2.0f));
} }
widget->addChild(child); widget->addChild(child);