void Node::bringToFront(void)
{
auto parent = this->getParent();
if (parent != nullptr && parent->getChildrenCount() >= 2) { auto& siblings = parent->getChildren(); auto last = *siblings.rbegin();
auto topOrderOfArrival = last->getOrderOfArrival();
auto topLocalZOrder = last->getLocalZOrder(); for (size_t idx = siblings.size() - 1; idx > 0; --idx)
{
auto sibling = siblings.at(idx);
if (sibling != this) {
sibling->setOrderOfArrival(siblings.at(idx - 1)->getOrderOfArrival());
sibling->_setLocalZOrder(siblings.at(idx - 1)->getLocalZOrder());
}
else {
break;
}
} this->setOrderOfArrival(topOrderOfArrival);
this->_setLocalZOrder(topLocalZOrder); std::sort(std::begin(siblings), std::end(siblings), nodeComparisonLess);
_eventDispatcher->setDirtyForNode(this);
}
} void Node::sendToBack(void)
{
auto parent = this->getParent();
if (parent != nullptr && parent->getChildrenCount() >= 2) { auto& siblings = parent->getChildren();
auto start = *siblings.begin();
auto bottomOrderOfArrival = start->getOrderOfArrival();
auto bottomLocalZOrder = start->getLocalZOrder(); for (size_t idx = 0; idx < siblings.size() - 1; ++idx)
{
auto c = siblings.at(idx);
if (c != this) {
c->setOrderOfArrival(siblings.at(idx + 1)->getOrderOfArrival());
c->_setLocalZOrder(siblings.at(idx + 1)->getLocalZOrder());
}
else {
break;
}
} this->setOrderOfArrival(bottomOrderOfArrival);
this->_setLocalZOrder(bottomLocalZOrder); std::sort(std::begin(siblings), std::end(siblings), nodeComparisonLess);
_eventDispatcher->setDirtyForNode(this);
}
}

cocos2d-x-3.x bringToFront &amp; sendToBack实现的更多相关文章

  1. iPhone How-to:如何调整UIView的Z-Order

    转自:http://bj007.blog.51cto.com/1701577/541572 在界面设计中,最终用户看到的呈现通常是由不同层的视图组成的,通过控制视图的层次就可以实现不同的效果和功能.而 ...

  2. Z Order of Controls in Delphi VCL

    Get and set the Z Order of controls at runtime in Delphi VCL. If you are looking for a FireMonkey so ...

  3. Z Order of Controls in Delphi FireMonkey(Tom Yu的博客)

    Get and set the Z Order of controls at runtime in Delphi FireMonkey. This is a follow on to my earli ...

  4. Delphi XE2 之 FireMonkey 入门(2)

    FireMonkey 的控件都是自己绘制的(而不是基于系统组件), 我想它们应该是基于一些基本图形; 就从基本图形开始吧. FMX.Objects 单元给出的类: TShape //基本图形的基类 T ...

  5. 关于sendtoback()和bringtofront() 的理解

    如下的代码: button2.Dock = DockStyle.Top; button1.SendToBack(); button1.Dock = DockStyle.Top; button3.Doc ...

  6. 小尝试一下 cocos2d

    好奇 cocos2d 到底是怎样一个框架,正好有个项目需要一个游戏框架,所以稍微了解了一下.小结一下了解到的情况. 基本概念 首先呢,因为 cocos2d 是基于 pyglet 做的,你完全可以直接用 ...

  7. 采用cocos2d-x lua 制作数字滚动效果样例

    require "Cocos2d"require "Cocos2dConstants"local testscene = class("testsce ...

  8. Cocos2d 利用继承Draw方法制作可显示三维数据(宠物三维等)的三角形显示面板

    很久没有写博客了,这段时间比较忙,又是搬家又是做自己的项目,还有太多琐碎的事情缠身,好不容易抽出时间把最近自己做的一些简单例子记录一下. 在我的项目中,我需要一个显示面板来显示游戏中的一个三维数据,例 ...

  9. iPhone开发与cocos2d 经验谈

    转CSDN jilongliang : 首先,对于一个完全没有mac开发经验,甚至从没摸过苹果系统的开发人员来说,首先就是要熟悉apple的那一套开发框架(含开发环境IDE.开发框架uikit,还有开 ...

随机推荐

  1. iOS 9下支持的键盘类型:

    http://blog.csdn.net/cloudox_/article/details/50532124

  2. ogre3D学习基础11 -- 交换两个场景管理器

    这一节,练习一下前几次学习的内容,功能很简单,就是建立两个不同的场景管理器,当按下键盘上某个键时切换镜头. 基本框架不变,这个监听器继承了两个父类,一个是我们的老朋友ExampleFrameListe ...

  3. day04_01 知识回顾、算术运算符

    ","和"+"的区别 除法运算,整除//,别名"地板除" 取余数 2**10 2的10次方 指数运算 指数运算符优先级要比乘法要高,所以先算 ...

  4. Wannafly挑战赛5

    珂朵莉与宇宙 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 65536K,其他语言131072K64bit IO Format: %lld 题目描述 星神是来自宇宙的 所以珂朵莉也是吧 ...

  5. 解决面试问题中的top k问题 Leetcode

    https://leetcode.com/problems/kth-largest-element-in-an-array/ 使用堆,堆插入一个数据是logk,删除一个数据是logk,复杂度为logk ...

  6. div固定在屏幕底部

    项目中需要实现div一直显示在屏幕的底部,不管页面有多长或者多端都需要满足. 在网上找的用js实现的,移动时会闪动,效果不是特别好.也可能是没找到好的. 相比js,我更希望使用css实现 1 < ...

  7. BZOJ2527 [Poi2011]Meteors 【整体二分 + 树状数组】

    题目 Byteotian Interstellar Union有N个成员国.现在它发现了一颗新的星球,这颗星球的轨道被分为M份(第M份和第1份相邻),第i份上有第Ai个国家的太空站. 这个星球经常会下 ...

  8. P1382 楼房 (扫描线,线段树)

    题目描述 地平线(x轴)上有n个矩(lou)形(fang),用三个整数h[i],l[i],r[i]来表示第i个矩形:矩形左下角为(l[i],0),右上角为(r[i],h[i]).地平线高度为0.在轮廓 ...

  9. bzoj 4566 [Haoi2016]找相同字符SA

    4566: [Haoi2016]找相同字符 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 128  Solved: 75[Submit][Status ...

  10. LA 6450 social advertising(dfs剪枝)

    6450 Social AdvertisingYou have decided to start up a new social networking company. Other existing ...