.h

#include "cocos2d.h"
#include "cocos-ext.h"
#include "ui/CocosGUI.h"
#include "cocostudio/CocoStudio.h"
USING_NS_CC; USING_NS_CC_EXT;
using namespace ui;
RichText* _richText;

    void  touchEvent(Ref *pSender, TouchEventType type);

.cpp

  layout = Layout::create();
layout->setSize(Size(widgetSize.width, widgetSize.height)); //横向排列,这里相似Android里的线性布局
//layout->setLayoutType(LAYOUT_RELATIVE);
/*以图片为背景*/
layout->setBackGroundImageScale9Enabled(true);
layout->setBackGroundImage("green_edit.png"); layout->setPosition(Point(0,0));
addChild(layout); /******************************************************************************************/
_richText = RichText::create(); _richText->ignoreContentAdaptWithSize(false);
_richText->setSize(Size(300, 500)); RichElementText* re1 = RichElementText::create(1, Color3B::WHITE, 255, "This color is White.", "Helvetica", 30);
RichElementText* re2 = RichElementText::create(2, Color3B::YELLOW, 255, "And this is yellow. ", "Helvetica", 30);
RichElementText* re3 = RichElementText::create(3, Color3B::BLUE, 255, "This one is blue. ", "Helvetica", 30);
RichElementText* re4 = RichElementText::create(4, Color3B::GREEN, 255, "And green. ", "Helvetica", 30);
RichElementText* re5 = RichElementText::create(5, Color3B::RED, 255, "Last one is red ", "Helvetica", 30); RichElementImage* reimg = RichElementImage::create(6, Color3B::WHITE, 255, "sliderballnormal.png");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("100.ExportJson");
cocostudio::Armature* pAr = cocostudio::Armature::create("100");
pAr->getAnimation()->play("Animation1"); RichElementCustomNode* recustom = RichElementCustomNode::create(1, Color3B::WHITE, 255, pAr);
RichElementText* re6 = RichElementText::create(7, Color3B::ORANGE, 255, "Have fun!!", "Helvetica", 30);
_richText->pushBackElement(re1);
_richText->insertElement(re2, 1);
_richText->pushBackElement(re3);
_richText->pushBackElement(re4);
_richText->pushBackElement(re5);
_richText->insertElement(reimg, 2);
_richText->pushBackElement(recustom);
_richText->pushBackElement(re6); _richText->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2));
_richText->setLocalZOrder(10); layout->addChild(_richText);
Button* button = Button::create("animationbuttonnormal.png", "animationbuttonpressed.png");
button->setTouchEnabled(true);
button->setTitleText("switch");
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5));
button->addTouchEventListener(this, toucheventselector(LayoutTest::touchEvent));
button->setLocalZOrder(10);
layout->addChild(button);
void LayoutTest::touchEvent(cocos2d::Ref *pSender, TouchEventType type)
{
switch (type) {
case cocos2d::ui::TOUCH_EVENT_BEGAN:
log("TOUCH_EVENT_BEGAN");
break; case cocos2d::ui::TOUCH_EVENT_MOVED:
log("TOUCH_EVENT_MOVED");
break; case cocos2d::ui::TOUCH_EVENT_ENDED:
if (_richText->isIgnoreContentAdaptWithSize())
{
_richText->ignoreContentAdaptWithSize(false);
_richText->setSize(Size(300, 500));
}
else
{
_richText->ignoreContentAdaptWithSize(true);
} break;
case cocos2d::ui::TOUCH_EVENT_CANCELED:
log("TOUCH_EVENT_CANCELED");
break; default:
break;
}
}

cocos2d-x3.0 RichText的更多相关文章

  1. 如何在Cocos2D 1.0 中掩饰一个精灵(六)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 掩饰一个精灵:实现代码 打开HelloWorldLayer.m并 ...

  2. 如何在Cocos2D 1.0 中掩饰一个精灵(一)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 原帖来自Ray Wunderlich写的精彩的文章 How To ...

  3. Cocos2D v2.0至v3.x简洁转换指南(三)

    Cocos2D 3.3中的注意事项 如果你在使用Cocos2D 3.3+(是SpriteBuilder 1.3+的一部分)你将不得不替分别的换所有存在的UITouch和UITouchEvent为CCT ...

  4. Cocos2D v2.0至v3.x简洁转换指南(二)

    触摸处理 我们在稍后将完成Cocos2d 3.0中触摸处理的完整教程.而现在最重要的是知道如何去启用触摸处理在你的CCNode中: self.userInteractionEnabled = TRUE ...

  5. 如何将各种低版本的discuz版本升级到discuz x3.0

    最近在做discuz改版的项目,遇到了很多问题,相信很多拥有discuz论坛的版主,站长和程序猿在升级或改版discuz的过程中遇到过和我一样的问题,所以我开了一个discuz专栏,为大家讲解一下di ...

  6. cocos2d 2.0和UIKit混合编程, Push CCDirector的时候出现黑屏的天坑

    症状 使用cocos2d 2.0和UIKit混合编程, 有一块用cocos2d编写的小程序, 将CCDirector push到一个UINavigationController里面. 虽然事先在后台初 ...

  7. cocos2d-x3.0创建第一个jsb游戏

    第一步: 最新的cocos2d-x.下载地址https://github.com/cocos2d/cocos2d-x github上最新的引擎,值得注意的是官网上发布的引擎是稳定版.选择哪种就看个人喜 ...

  8. cocos2d(3.0)一些基础的东西

    1.创建项目后环境配置: 附加文件夹:加入 $(EngineRoot) $(EngineRoot)cocos $(EngineRoot)cocos\editor-support $(EngineRoo ...

  9. 如何在Cocos2D 1.0 中掩饰一个精灵(五)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 掩饰和CCRenderTexture CCRenderTextu ...

随机推荐

  1. IntelliJ IDEA 去除IDE自动的参数名 提示功能

  2. OutLook中添加Exchange失败问题

    问题: 在邮件中添加账户后,打开outlook时报出错误:无法启动 Microsoft Outlook. 无法打开 Outlook 窗口. 无法打开此文件夹集合. 必须先使用当前的配置文件连接到 Mi ...

  3. Knockout.Js官网学习(模版绑定)

    模板绑定器 如今页面结构越来越复杂,仅仅依靠foreach已经不足以我们的使用,这个时候我们就需要模板的存在,模板的优点自然很多,首先会让页面整洁,同时修改起来也可以方面的定位,最重要的是ko可以条件 ...

  4. day9--多线程与多进程

        线程:     什么是线程? 线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位.一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线 ...

  5. day9--paramiko模块

    志不坚者智不达 paramiko:在Linux链接其他机器,每台Linux机器都有一个SSHClient:Python自己也写了一个SSHClient,那么Python写paramiko创建SSHCl ...

  6. 使用spring-boot-maven-plugin插件打包spring boot项目

    在spring-boot项目中使用spring-boot-maven-plugin插件进行打包,输出可执行JAR包.项目包含多个模块,当打完包后在本地的maven仓库中发现输出的可执行JAR非常小,并 ...

  7. Codeforces Round #239 (Div. 1) 二项式差分

    C - Curious Array 思路:对于区间[l, r]每个数加上C(i - l + k, k), 可以在l处+1, 在r+1处-1, 然后做k+1次求前缀和操作,然后就可以写啦. 然后逐层求前 ...

  8. 8-7 Unique Snowflakes UVA11572

    输入一个长度为n n<=10 6  的序列A  找到一个尽量长的连续子序列  使得该序列中没有相同的元素 用滑动窗口法   时间复杂度n  好神奇 此题非常经典 map   410ms #inc ...

  9. nginx卸载与安装

    1.卸载 在前面曾经安装过一次,这一次卸载再重新安装. 直接删除文件夹 2.更新软件源 3.依赖包安装 4.下载源码包并解压 5.增加用户组 6.安装 三个步骤 ./configure make ma ...

  10. python3下django连接mysql数据库

    1.安装pymysql pip install pymysql 有一点需要注意,有的系统(比如ubuntu16.04)同时安装了python2和python3,而比较新的django需要在python ...