资源简介
实现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
相关资源
- cocos2d-x飞机大战项目
- Cocos2d-x开发游戏的坐标系知识介绍
- Cocos2d-x 3.x 头像选择器功能扩展Image
- 节奏大师源码
- 炸弹人(cocos2d-x 3.2)
- Cocos2d-x 瓦片地图操作Demo-双指缩放、
- cocos2d-x游戏源码236061
- cocos2d-x 别踩白块源码
- Cocos2d-x《大抗战》塔防射击游戏源代
- 基于cocos开发的飞机大战含素材资源
- 迷失航线-Cocos2d-x项目实战-射击类游戏
- BulletWar游戏源码coco2d-x开发 lua
- cocos2d-x塔防实现
- cocos2d-x游戏开发系列教程-坦克大战游
- cocos2d-x 2048小游戏源码+素材
- 坦克大战 类和图片资源
- 游戏:猫狗大作战
- Cocos2d-x滑雪游戏源码.zip
- cocos2d-x完整RPG游戏源代码(配套资源
- 用Cocos2d-x编写大富翁游戏源码,可联
- 植物大战僵尸源码
- TowerDefense cocos2d-x
- Cocos2d-x3.2塔防游戏源代码
- 格斗横版过关类手游cocos2d-x lua源码
- Cocos Studio 创建帧动画
- 使用Cocos2d-X开发中国象棋
- Cocos2d-x时钟
- Cocos2d-x之Lua核心编程_PDF 高清 带索引
- Cocos2d-x高级开发教程:制作自己的《
- cocos2d-x半即时战斗rpg游戏demo源码
评论
共有 条评论