<tfoot id='nEwVG'></tfoot>

      <bdo id='nEwVG'></bdo><ul id='nEwVG'></ul>
  • <small id='nEwVG'></small><noframes id='nEwVG'>

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

      1. cocos2d中如何对多个精灵进行像素完美碰撞?

        How to do pixel perfect collision on many sprites in cocos2d?(cocos2d中如何对多个精灵进行像素完美碰撞?)
          <tbody id='A60Bt'></tbody>
      2. <small id='A60Bt'></small><noframes id='A60Bt'>

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

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

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

                  问题描述

                  在我的应用程序中,我有一个玩家和许多敌人(大约 100 多个)..我不想使用 CGRects,因为它不适合敌人.有没有例子如何在 cocos2d 中使用许多精灵进行像素完美碰撞检测?

                  in my app I have a player and many enemies (about 100+)..I don't want to use CGRects because it doesn't fits to the enemies. Is there any example how to do pixel perfect collision detection in cocos2d with many sprites?

                  一些解释会很棒;)

                  非常感谢!

                  编辑:我正在使用 CCSprite 和 .png 文件.png 具有透明度,但它应该只检测非透明像素上的碰撞.

                  EDIT: I'm using CCSprite and .png files. the png has transparency but it should only detect a collision on non-transparency pixels.

                  我的敌人是圆形的.

                  推荐答案

                  圆-圆碰撞最简单..计算最快..希望你知道玩家的半径和敌人的半径..让20是玩家的半径和 10 是敌人的半径.. 一个简单的计算是:

                  Circle-circle collision is the easiest.. And computing is the fastest.. I hope you know the radius of the player and radius of enemy.. Let 20 be radius of player and 10 be radius of enemy.. A simple calculation would be:

                  float dx = player.spr.x - enemy.spr.x;
                  float dy = player.spr.y - enemy.spr.y;
                  float dxy = dx*dx + dy*dy;
                  float collisionRad = (20+10)*(20+10);
                  
                  if(dxy<= collisionRad)
                  {
                  //collision
                  }
                  

                  我们正在使用勾股定理计算 2 点之间的距离.http://en.wikipedia.org/wiki/Pythagorean_theorem

                  We are calculating distance between 2 points using the Pythagorean Theorem.. http://en.wikipedia.org/wiki/Pythagorean_theorem

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

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

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(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 场景重启?)
                  [ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
                • <i id='QRYGd'><tr id='QRYGd'><dt id='QRYGd'><q id='QRYGd'><span id='QRYGd'><b id='QRYGd'><form id='QRYGd'><ins id='QRYGd'></ins><ul id='QRYGd'></ul><sub id='QRYGd'></sub></form><legend id='QRYGd'></legend><bdo id='QRYGd'><pre id='QRYGd'><center id='QRYGd'></center></pre></bdo></b><th id='QRYGd'></th></span></q></dt></tr></i><div id='QRYGd'><tfoot id='QRYGd'></tfoot><dl id='QRYGd'><fieldset id='QRYGd'></fieldset></dl></div>

                  • <legend id='QRYGd'><style id='QRYGd'><dir id='QRYGd'><q id='QRYGd'></q></dir></style></legend>
                    <tfoot id='QRYGd'></tfoot>
                      • <small id='QRYGd'></small><noframes id='QRYGd'>

                          <tbody id='QRYGd'></tbody>

                            <bdo id='QRYGd'></bdo><ul id='QRYGd'></ul>