資源簡介
實(shí)現(xiàn)cocos2d-x Label不同文字不同顏色

代碼片段和文件信息
/****************************************************************************
?Copyright?(c)?2013??????Zynga?Inc.
?Copyright?(c)?2013-2014?Chukong?Technologies?Inc.
?http://www.cocos2d-x.org
?Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy
?of?this?software?and?associated?documentation?files?(the?“Software“)?to?deal
?in?the?Software?without?restriction?including?without?limitation?the?rights
?to?use?copy?modify?merge?publish?distribute?sublicense?and/or?sell
?copies?of?the?Software?and?to?permit?persons?to?whom?the?Software?is
?furnished?to?do?so?subject?to?the?following?conditions:
?The?above?copyright?notice?and?this?permission?notice?shall?be?included?in
?all?copies?or?substantial?portions?of?the?Software.
?THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR
?IMPLIED?INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY
?FITNESS?FOR?A?PARTICULAR?PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL?THE
?AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?ANY?CLAIM?DAMAGES?OR?OTHER
?LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?ARISING?FROM
?OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN
?THE?SOFTWARE.
?****************************************************************************/
#include?“2d/CCLabel.h“
#include?“2d/CCFont.h“
#include?“2d/CCFontAtlasCache.h“
#include?“2d/CCFontAtlas.h“
#include?“2d/CCSprite.h“
#include?“2d/CCSpriteBatchNode.h“
#include?“2d/CCDrawNode.h“
#include?“2d/CCCamera.h“
#include?“base/ccUTF8.h“
#include?“platform/CCFileUtils.h“
#include?“renderer/CCRenderer.h“
#include?“renderer/ccGLStateCache.h“
#include?“base/CCDirector.h“
#include?“base/CCEventListenerCustom.h“
#include?“base/CCEventDispatcher.h“
#include?“base/CCEventCustom.h“
NS_CC_BEGIN
/**
?*?LabelLetter?used?to?update?the?quad?in?texture?atlas?without?SpriteBatchNode.
?*/
class?LabelLetter?:?public?Sprite
{
public:
????LabelLetter()
????{
????????_textureAtlas?=?nullptr;
????}
????static?LabelLetter*?createWithTexture(Texture2D?*texture?const?Rect&?rect?bool?rotated?=?false)
????{
????????auto?letter?=?new?(std::nothrow)?LabelLetter();
????????if?(letter?&&?letter->initWithTexture(texture?rect?rotated))
????????{
????????????letter->setVisible(false);
????????????letter->autorelease();
????????????return?letter;
????????}
????????CC_SAFE_DELETE(letter);
????????return?nullptr;
????}
????
????CREATE_FUNC(LabelLetter);
????virtual?void?updateTransform()?override
????{
????????if?(isDirty())
????????{
????????????_transformToBatch?=?getNodeToParentTransform();
????????????Size?&size?=?_rect.size;
????????????float?x1?=?_offsetPosition.x;
????????????float?y1?=?_offsetPosition.y;
????????????float?x2?=?x1?+?size.width;
????????????float?y2?=?y1?+?size.height;
????????????if?(_flippedX)
????????????{
????????????????std::swap(x1?x2);
????????????}
????????????if?(_flippedY)
????????????{
????????????????std::swap(y1?y2);
????????????}
????????????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-09-04?14:36??code\
?????文件???????52691??2016-07-31?11:34??code\CCLabel.cpp
?????文件???????20349??2016-07-29?14:35??code\CCLabel.h
?????文件???????13961??2016-07-29?14:37??code\CCLabelTextFormatter.cpp
?????文件???????????0??2015-09-06?08:34??code\CCLabelTextFormatter.h
評論
共有 條評論