• <tfoot id='9tijy'></tfoot>
    <legend id='9tijy'><style id='9tijy'><dir id='9tijy'><q id='9tijy'></q></dir></style></legend>

      <i id='9tijy'><tr id='9tijy'><dt id='9tijy'><q id='9tijy'><span id='9tijy'><b id='9tijy'><form id='9tijy'><ins id='9tijy'></ins><ul id='9tijy'></ul><sub id='9tijy'></sub></form><legend id='9tijy'></legend><bdo id='9tijy'><pre id='9tijy'><center id='9tijy'></center></pre></bdo></b><th id='9tijy'></th></span></q></dt></tr></i><div id='9tijy'><tfoot id='9tijy'></tfoot><dl id='9tijy'><fieldset id='9tijy'></fieldset></dl></div>
        • <bdo id='9tijy'></bdo><ul id='9tijy'></ul>

      1. <small id='9tijy'></small><noframes id='9tijy'>

        如何检测 cocos2d 中精灵的碰撞

        How to detect collision of sprite in cocos2d(如何检测 cocos2d 中精灵的碰撞)

        <small id='4W00E'></small><noframes id='4W00E'>

        1. <i id='4W00E'><tr id='4W00E'><dt id='4W00E'><q id='4W00E'><span id='4W00E'><b id='4W00E'><form id='4W00E'><ins id='4W00E'></ins><ul id='4W00E'></ul><sub id='4W00E'></sub></form><legend id='4W00E'></legend><bdo id='4W00E'><pre id='4W00E'><center id='4W00E'></center></pre></bdo></b><th id='4W00E'></th></span></q></dt></tr></i><div id='4W00E'><tfoot id='4W00E'></tfoot><dl id='4W00E'><fieldset id='4W00E'></fieldset></dl></div>
          <tfoot id='4W00E'></tfoot>
          <legend id='4W00E'><style id='4W00E'><dir id='4W00E'><q id='4W00E'></q></dir></style></legend>
                <tbody id='4W00E'></tbody>

                • <bdo id='4W00E'></bdo><ul id='4W00E'></ul>
                  本文介绍了如何检测 cocos2d 中精灵的碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想检测一个精灵与另一个精灵的碰撞.但我想检查精灵是否与其他精灵的左侧部分接触或与精灵的右侧部分接触.我正在使用下面的代码来检测碰撞.但这会检测整体碰撞(精灵在其他精灵的任何点接触).但是如果精灵被触摸到其他精灵的正面,则要算作碰撞.

                  i want to detect collision of a sprite with another sprite. but i want to check whether the sprite is touched with left part of other sprite or touched with right part of sprite. i am using below code for detecting collision. but this detect the overall collision(sprite touched to at any point of other sprite). but want to count is as collision if the sprite is touched to front side of other sprite.

                  if (CGRectIntersectsRect(sprite1.boundingBox, sprite2.boundingBox)) {
                              NSLog(@"sprite1 to delete");
                   }
                  

                  有人知道怎么做吗?

                  推荐答案

                  你能比较一下碰撞时精灵的位置吗?

                  Would you be able to compare the positions of the sprites at the time of collision?

                  假设 sprite1.anchorpoint, sprite2.anchorpoint = ccp(0,0).检测到碰撞时:

                  Assume sprite1.anchorpoint, sprite2.anchorpoint = ccp(0,0). At time when collision is detected:

                  // left part of sprite 1 touched right part of sprite 2
                  if (sprite1.position.x == sprite2.position.x + sprite2.contentSize.width.x) {
                  
                  }
                  // right part of sprite 1 touched left part of sprite 2
                  else if (sprite1.position.x + sprite1.contentSize.width.x == sprite2.position.x) {
                  
                  }
                  

                  这篇关于如何检测 cocos2d 中精灵的碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)

                  <small id='Jg7Wc'></small><noframes id='Jg7Wc'>

                    • <bdo id='Jg7Wc'></bdo><ul id='Jg7Wc'></ul>

                        <tfoot id='Jg7Wc'></tfoot>
                              <tbody id='Jg7Wc'></tbody>
                          • <i id='Jg7Wc'><tr id='Jg7Wc'><dt id='Jg7Wc'><q id='Jg7Wc'><span id='Jg7Wc'><b id='Jg7Wc'><form id='Jg7Wc'><ins id='Jg7Wc'></ins><ul id='Jg7Wc'></ul><sub id='Jg7Wc'></sub></form><legend id='Jg7Wc'></legend><bdo id='Jg7Wc'><pre id='Jg7Wc'><center id='Jg7Wc'></center></pre></bdo></b><th id='Jg7Wc'></th></span></q></dt></tr></i><div id='Jg7Wc'><tfoot id='Jg7Wc'></tfoot><dl id='Jg7Wc'><fieldset id='Jg7Wc'></fieldset></dl></div>

                            <legend id='Jg7Wc'><style id='Jg7Wc'><dir id='Jg7Wc'><q id='Jg7Wc'></q></dir></style></legend>