创建空白精灵
来源:互联网 发布:windows ftp命令详解 编辑:程序博客网 时间:2024/05/19 16:06
//创建空白精灵
Sprite* p=Sprite::create();p->setColor(Color3B::WHITE);p->setTextureRect(Rect(0,0,len,wid));
//创建遮盖层(即虽然可以点击,但却不做任何响应)
auto translucence = Sprite::create();
translucence->setColor(Color3B::WHITE);
translucence->setOpacity(150);
translucence->setTextureRect(Rect(0,0,size.width,size.height));
l->addChild(translucence);
translucence->setPosition(Vec2(size.width / 2, size.height / 2));
auto lis = EventListenerTouchOneByOne::create();
lis->setSwallowTouches(true);
lis->onTouchBegan = [](Touch* t, Event* e){
auto target = static_cast<Sprite*>(e->getCurrentTarget());
auto touchLocation = target->convertToNodeSpace(t->getLocation());
if (target->getBoundingBox().containsPoint(touchLocation))
CCLOG("s");
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(lis, translucence);
**使用setSwallowTouches(argc)// argc==true,两个重叠的精灵(添加在同一个父级容器里),触摸上面的精灵,下面的精灵将不会响应事件;
argc==false,下面的精灵将会响应事件。
使用时onTouchBegan的返回值必须为return true才起作用
**pauseEventListenersForTarget(node,true) //为true时,将会停止node(我测试的只有node为layer类型时才有效)本身以及其子节点的监听事件,也就不会响应事件,使用时通过有相应的点击事件来触发
resumeEventListenersForTarget (node,true) //起相反的作用
- 创建空白精灵
- 创建精灵池
- cocos2d-x创建精灵
- Cocos2d-x精灵创建
- cocos2d-x创建精灵
- cocos2dx创建精灵动作
- 创建精灵、执行动作
- display.newSprite创建精灵
- 精灵的创建
- Lua_创建精灵
- 精灵创建源码分析
- 使用SpriteFrameCache创建精灵
- Cocos2dx之精灵创建
- 精灵进程的创建
- 创建精灵的方法
- Cocos2d 创建一个精灵
- lua-精灵的创建
- cocos2d-x 创建精灵
- HDU
- Java异常处理机制
- 【Halcon笔记1】基于Halcon软件的【摄像机标定】以及【内部参数】和【外部参数】的求解过程【原理细节详解】
- 从Xib文件加载UIView的5种方式
- 4.1常用对象API(String类)
- 创建空白精灵
- 对比S3C6410外部中断STM32外部中断
- 【Noip模拟】仔排
- UVA10375唯一分解定理运用
- elasticsearch项目踩坑记
- cf851d
- Lintcode搜索插入位置
- HDU
- vim复制代码包含注释时格式会乱掉的解决办法