.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;
private:
cocos2d::SpriteBatchNode *mgr;; cocos2d::Sprite *sp1;
cocos2d::Sprite *sp2;
cocos2d::Sprite *sp3;
cocos2d::Sprite *sp4;
cocos2d::Sprite *sp5;
cocos2d::Sprite *sp6;
cocos2d::Sprite *sp7;
cocos2d::Sprite *sp8;
cocos2d::Sprite *sp9;

.cpp

    auto listener = EventListenerTouchAllAtOnce::create();

        auto label = Label::createWithTTF("vertexZ = 50", "Marker Felt.ttf", 64);
label->setPosition(Point(size.width / 2, size.height * 0.25f));
this->addChild(label); auto label2 = Label::createWithTTF("vertexZ = 0", "Marker Felt.ttf", 64);
label2->setPosition(Point(size.width / 2, size.height * 0.5f));
this->addChild(label2); auto label3 = Label::createWithTTF("vertexZ = -50", "Marker Felt.ttf", 64);
label3->setPosition(Point(size.width / 2, size.height * 0.75f));
this->addChild(label3); label->setPositionZ(50);
label2->setPositionZ(0);
label3->setPositionZ(-50); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("circle.plist");
mgr = SpriteBatchNode::create("circle.png", 9);
this->addChild(mgr);
auto sp1 = Sprite::createWithSpriteFrameName("circle.png");
sp2 = Sprite::createWithSpriteFrameName("circle.png");
sp3 = Sprite::createWithSpriteFrameName("circle.png");
sp4 = Sprite::createWithSpriteFrameName("circle.png");
sp5 = Sprite::createWithSpriteFrameName("circle.png");
sp6 = Sprite::createWithSpriteFrameName("circle.png");
sp7 = Sprite::createWithSpriteFrameName("circle.png");
sp8 = Sprite::createWithSpriteFrameName("circle.png");
sp9 = Sprite::createWithSpriteFrameName("circle.png"); mgr->addChild(sp1, 9);
mgr->addChild(sp2, 8);
mgr->addChild(sp3, 7);
mgr->addChild(sp4, 6);
mgr->addChild(sp5, 5);
mgr->addChild(sp6, 4);
mgr->addChild(sp7, 3);
mgr->addChild(sp8, 2);
mgr->addChild(sp9, 1); sp1->setPositionZ(400);
sp2->setPositionZ(300);
sp3->setPositionZ(200);
sp4->setPositionZ(100);
sp5->setPositionZ(0);
sp6->setPositionZ(-100);
sp7->setPositionZ(-200);
sp8->setPositionZ(-300);
sp9->setPositionZ(-400); sp9->setScale(2);
sp9->setColor(Color3B::YELLOW); //[=]能够掉用外部变量
listener->onTouchesBegan = [=](const std::vector<Touch *> &touches, cocos2d::Event *unused_event)
{
for (auto &item:touches) {
auto touch = static_cast<Touch*>(item);
auto location = touch->getLocation(); sp1->setPosition(location);
sp2->setPosition(location);
sp3->setPosition(location);
sp4->setPosition(location);
sp5->setPosition(location);
sp6->setPosition(location);
sp7->setPosition(location);
sp8->setPosition(location);
sp9->setPosition(location);
}
}; listener->onTouchesMoved = [=](const std::vector<Touch*>& touches,Event* unused_event)
{
for (auto &item:touches) {
auto touch = static_cast<Touch*>(item);
auto location = touch->getLocation(); sp1->setPosition(location);
sp2->setPosition(location);
sp3->setPosition(location);
sp4->setPosition(location);
sp5->setPosition(location);
sp6->setPosition(location);
sp7->setPosition(location);
sp8->setPosition(location);
sp9->setPosition(location);
} }; listener->onTouchesEnded = [=](const std::vector<Touch *> &touches, cocos2d::Event *unused_event){
auto texture = RenderTexture::create(512, 512);
if (NULL == texture)
{
return;
}
texture->setAnchorPoint(Point(0, 0));
texture->setKeepMatrix(true);
texture->begin(); this->visit(); texture->end(); auto sprite = Sprite::createWithTexture(texture->getSprite()->getTexture()); sprite->setPosition(Point(256, 256));
sprite->setOpacity(182);
sprite->setFlippedY(1);
this->addChild(sprite, 999999);
sprite->setColor(Color3B::GREEN); sprite->runAction(Sequence::create(FadeTo::create(2, 0),
Hide::create(),
NULL)); }; _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

Cocos2d-x3.0 RenderTexture(三)的更多相关文章

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

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

  2. Python黑帽编程3.0 第三章 网络接口层攻击基础知识

    3.0 第三章 网络接口层攻击基础知识 首先还是要提醒各位同学,在学习本章之前,请认真的学习TCP/IP体系结构的相关知识,本系列教程在这方面只会浅尝辄止. 本节简单概述下OSI七层模型和TCP/IP ...

  3. ORACLE SQL前端补0的三种方式。

    前端补0的三种方式. select lpad(sal,8,'0') from emp;select to_char(sal,'00000000') from emp;select substr('00 ...

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

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

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

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

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

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

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

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

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

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

  9. XHTML 1.0 的三种 XML 文档类型 DOCTYPE

    XHTML 1.0 的三种 XML 文档类型 XHTML 1.0 规定了三种 XML 文档类型 XHTML 1.0 Strict <!DOCTYPE html PUBLIC "-//W ...

随机推荐

  1. [Algorithm]扔杯问题

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  2. vmware笔试题目

    http://discuss.acmcoder.com/topic/58db8e2ebb0f44ba0e94e670 上面是完整的题目,下面一下我自己的想法. http://discuss.acmco ...

  3. vue项目中阻止浏览器返回上一页

    vue项目中在某个页面阻止浏览器返回上一页,适用移动端.PC端. 使用场景例如: 首页 与 A页面     来回跳转,那样点击浏览器返回时也会来回跳转,本想当页面在首页的时候就不再返回了,所以这个时候 ...

  4. Spring《七》ApplicationContext

    1.国际化支持 getMessage()提供了国际化支持. Bean中必须定义为messageSource. <bean id="messageSource" class=& ...

  5. Centos7下Docker的使用

    一.安装Docker 1.1.查看原有系统是否已经安装docker yum list installed | grep docker 1.2.如果有则不需要继续安装,想重新安装,先卸载 yum -y ...

  6. P1410 子序列

    题目描述 给定一个长度为N(N为偶数)的序列,问能否将其划分为两个长度为N/2的严格递增子序列, 输入输出格式 输入格式: 若干行,每行表示一组数据.对于每组数据,首先输入一个整数N,表示序列的长度. ...

  7. 微信小程序video组件出现无法播放或卡顿

    微信小程序使用video组件播放视频的时候,会出现卡顿或者无法播放的问题,加一个custom-cache=”true“即可解决,这个属性文档上没有,是从小程序开发社区中get到的.

  8. String[]转化暴露“思维误区”

    那天写code,用到这个,强转,将页面传来的值转换为数组,结果是,当页面传来的只有一个值时,它是无法转换为数组的,只能获得1个string,只有length>1时才会转化为数组的形式,报的错误是 ...

  9. [翻译]内存一致性模型 --- memory consistency model

    I will just give the analogy with which I understand memory consistency models (or memory models, fo ...

  10. Verilog之openMSP430(1)

    openMSP430_IO interrupt Verilog file: omsp_gpio.v //================================================ ...