• cocos2dx动作类游戏,人物排序(层次关系)


     1 void WGBattleLayer::RoleSeqencingZ()
    2 {
    3 int length = (int)this->vector_All_Roles_->size();
    4 for (int i=0;i<length;i++)
    5 {
    6 for (int j=0;j<length - i - 1;j++)
    7 {
    8 //NO.1
    9 WGRole* RoleA = this->vector_All_Roles_->at(j);
    10 WGRole* RoleB = this->vector_All_Roles_->at(j + 1);
    11 if (RoleA != NULL && RoleB != NULL)
    12 {
    13 if (RoleA->getRoleCurrentHealthPoint() > 0 && RoleB->getRoleCurrentHealthPoint() > 0)
    14 {
    15 CCRect tempRectA = RoleA->GetTouchRect();
    16 CCRect tempRectB = RoleB->GetTouchRect();
    17 //NO.2 矩形相交
    18 if ( true == CCRect::CCRectIntersectsRect(tempRectA,tempRectB))
    19 {
    20 int A_Z = RoleA->getZOrder();
    21 int B_Z = RoleB->getZOrder();
    22 CCPoint A_P = RoleA->GetBottomPoint();
    23 CCPoint B_P = RoleB->GetBottomPoint();
    24 //NO.3 更改Z
    25 if(A_P.y < B_P.y)
    26 {
    27 if (A_Z < B_Z)
    28 {
    29 this->reorderChild(RoleA,B_Z);
    30 this->reorderChild(RoleB,A_Z);
    31 }
    32 }else{
    33 if (A_Z > B_Z)
    34 {
    35 this->reorderChild(RoleA,B_Z);
    36 this->reorderChild(RoleB,A_Z);
    37 }
    38 }
    39 }
    40 }
    41 }
    42 }
    43 }
    44 }

    http://user.qzone.qq.com/418319859/blog/1325057411

  • 相关阅读:
    react结合antd4.0和umi3.0的404界面
    小程序自带组件自定义tabbar
    移动安全学习清单
    跨域资源共享 CORS 详解(转)
    docker常用命令总结
    XSS绕过小结
    mysql的order by注入
    本地文件包含漏洞利用姿势
    XSS绕过<>进行测试
    clamscan+clam-freshclam.service服务启停
  • 原文地址:https://www.cnblogs.com/GameDeveloper/p/2304877.html
Copyright © 2020-2023  润新知