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

      1. <small id='vL5U6'></small><noframes id='vL5U6'>

        <tfoot id='vL5U6'></tfoot>

        cocos2d中没有正确检测到CGPath

        CGPath is not detected properly in cocos2d(cocos2d中没有正确检测到CGPath)

      2. <legend id='V2qxu'><style id='V2qxu'><dir id='V2qxu'><q id='V2qxu'></q></dir></style></legend>

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

          <tfoot id='V2qxu'></tfoot>
          1. <i id='V2qxu'><tr id='V2qxu'><dt id='V2qxu'><q id='V2qxu'><span id='V2qxu'><b id='V2qxu'><form id='V2qxu'><ins id='V2qxu'></ins><ul id='V2qxu'></ul><sub id='V2qxu'></sub></form><legend id='V2qxu'></legend><bdo id='V2qxu'><pre id='V2qxu'><center id='V2qxu'></center></pre></bdo></b><th id='V2qxu'></th></span></q></dt></tr></i><div id='V2qxu'><tfoot id='V2qxu'></tfoot><dl id='V2qxu'><fieldset id='V2qxu'></fieldset></dl></div>
              <bdo id='V2qxu'></bdo><ul id='V2qxu'></ul>
                  <tbody id='V2qxu'></tbody>
                  本文介绍了cocos2d中没有正确检测到CGPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  通过帮助和建议,我为我的精灵创建了一条路径,以便只能触摸不透明的部分.这是我想出的路径:

                  Through help and suggestions, I created a path for my sprite so that only the non-transparent parts can be touched. This is the path I came up with:

                      path = CGPathCreateMutable();
                      CGPathMoveToPoint(path, NULL, endTouch.x, endTouch.y);
                      CGPathAddLineToPoint(path, NULL, 0, 250);
                      CGPathAddLineToPoint(path, NULL, 30, 0);
                      CGPathCloseSubpath(path);
                  

                  这适用于我的所有其他课程,除了一个.无论我在哪里点击,xcode 都会使用此代码在外部"打印:

                  This works for all my other classes except for one. No matter where I tap, xcode keeps printing "outside" using this code:

                  for(int i = 0; i < [sprArray count]; i++)
                  {
                      CCSprite *sprite = (CCSprite *)[sprArray objectAtIndex:i];
                      if(CGRectContainsPoint([sprite boundingBox], location))
                      {
                          selectedSprite = sprite;
                          location = [selectedSprite convertToNodeSpace:location];
                          if (CGPathContainsPoint(path, NULL, location, NO) ) 
                          {
                              NSLog(@"inside");
                          }
                          else 
                          {
                              NSLog(@"outside");
                          }
                  
                          break;
                      }
                  }
                  

                  如果我进入 if 条件,我只能移动我的精灵,否则,即使我点击实际的彩色精灵,它也不会得到我设置的路径.我的测量值有误吗?如果没有,我做错了什么?这与我尝试使用的图像相似...

                  I can only move my sprites if I get inside the if-condition, not else but even if I tap on the actual, colored sprite, it doesn't get the path I set. Are my measurements wrong? If not, what am I doing wrong? This is similar to the image I'm trying to use...

                  推荐答案

                  这仅适用于图像大小相同的情况.根据图像大小计算坐标.

                  This works only if image size is same. Depending on image size calculate coordinates.

                  CGPathMoveToPoint(path,    NULL,   54, 0 ); //1: 54 = distance from left, 0 = dis fem bottom
                  CGPathAddLineToPoint(path, NULL,   28, 34 );
                  CGPathAddLineToPoint(path, NULL,   36, 76 );
                  CGPathAddLineToPoint(path, NULL,   51, 104 );
                  CGPathAddLineToPoint(path, NULL,   46, 147 );
                  CGPathAddLineToPoint(path, NULL,   67, 147 );
                  CGPathAddLineToPoint(path, NULL,   70, 105 );
                  CGPathAddLineToPoint(path, NULL,   56, 66 );
                  CGPathAddLineToPoint(path, NULL,   52, 42 );
                  CGPathAddLineToPoint(path, NULL,   67, 20 );
                  CGPathAddLineToPoint(path, NULL,   92, 0 );
                  CGPathCloseSubpath(path);
                  

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

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

                  相关文档推荐

                  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 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                    <legend id='0vULT'><style id='0vULT'><dir id='0vULT'><q id='0vULT'></q></dir></style></legend>

                    <small id='0vULT'></small><noframes id='0vULT'>

                      <bdo id='0vULT'></bdo><ul id='0vULT'></ul>
                        <tbody id='0vULT'></tbody>

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