资源简介
实现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);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 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
相关资源
- 17种cocos2d-x小游戏源码+素材,从2.x到
- Cocos2d-x 3.2 自动更新 -- 使用AssetsMana
- Tiled Map Editor(一)
- Tiled Map Editor(三)
- cocos2d-x3.10 翻页、翻牌效果的实现
- cocos2d-x游戏源码
- Cocos2d-x实战 Lua卷 PDF电子书 带书签目
- cocos2d-x从入门到精通经典视频
- cocos引擎老版本集合cocos2d-x-2.2.1 - 3
- Cocos2d-x入门视频教程全7讲
- cocos2d-X 3.x游戏案例开发大全随书光盘
- cocos2d-x扫雷
- cocos2d-x Box2d点击随机生成刚体
- cocos2d-x 游戏俄罗斯方块
- cocos2d-x 滚动文字(CCLabelTTF)
- Cocos2d-x 三消游戏源码
- 用cocos2d-x 3.2物理引擎实现的Flappy Bi
- cocos2d-x 俄罗斯方块Tetris源码
- cocos2d-x 水果忍者
- cocos2d-x3.1—微信打飞机源码及素材
- cocos2d-x3.2贪吃蛇游戏代码与资源
评论
共有 条评论