<tfoot id='o0OX9'></tfoot>

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

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

        显示 CGRect 边框的简单方法?

        Simple way to display the borders of a CGRect?(显示 CGRect 边框的简单方法?)
        <tfoot id='knLCp'></tfoot>

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

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

                <tbody id='knLCp'></tbody>
            • <legend id='knLCp'><style id='knLCp'><dir id='knLCp'><q id='knLCp'></q></dir></style></legend>

                • <bdo id='knLCp'></bdo><ul id='knLCp'></ul>
                  本文介绍了显示 CGRect 边框的简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试寻找一种方法来在我的 iOS 程序中显示某些 CGRect 的边框以进行调试.有没有一种相当简单的方法来做到这一点?我只需要查看程序在哪里创建这些矩形,这样我就可以追踪一些奇怪的触摸行为(或缺少这些行为).

                  I'm trying to find a way to display the borders of some CGRects in my iOS program for debugging purposes. Is there a fairly simple way to do this? I just need to see where the program is creating these rectangles, so I can track down some odd touch behaviors (or lack thereof).

                  我的类init方法:

                  // Initialize with points and a line number, then draw a rectangle 
                  // in the shape of the line
                  -(id)initWithPoint:(CGPoint)sP :(int)w :(int)h :(int)lN :(int)t {
                      if ((self = [super init])) {
                          startP = sP;
                          lineNum = lN;
                          width = w;
                          height = h;
                          int type = t;
                          self.gameObjectType = kPathType;
                  
                          // Draw the path sprite
                          path = [CCSprite spriteWithFile: @"line.png" rect:CGRectMake(0, 0, 5, height)];
                          ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
                          [path.texture setTexParameters:&params];
                  
                          if(type == 1) {
                              path.position = ccp(startP.x, startP.y);
                          } else {
                              path.rotation = 90;
                              path.anchorPoint = ccp(0, 0);
                              path.position = ccp(startP.x, startP.y-2);
                          }
                  
                          [self addChild:path];
                  
                          // Draw the "bounding" box
                          pathBox = CGRectMake(path.position.x - (path.contentSize.width/2), path.position.y - (path.contentSize.height/2), path.contentSize.width * 10, path.contentSize.height);
                      }
                      return self;
                  }
                  

                  pathBox 是有问题的矩形.

                  推荐答案

                  我或多或少地想出了怎么做:只是像这样在我的类中扩展了 draw 方法:

                  I figured out more-or-less how to do it: just extended the draw method in my class like so:

                  -(void) draw {
                      glColor4f(0, 1.0, 0, 1.0);
                      glLineWidth(2.0f);
                      [super draw];
                  
                      CGRect pathBox = CGRectMake(path.position.x - (path.contentSize.width/2), path.position.y - (path.contentSize.height/2), path.contentSize.width * 10, path.contentSize.height);
                      CGPoint verts[4] = {
                        ccp(pathBox.origin.x, pathBox.origin.y),
                        ccp(pathBox.origin.x + pathBox.size.width, pathBox.origin.y),
                        ccp(pathBox.origin.x + pathBox.size.width, pathBox.origin.y + pathBox.size.height),
                        ccp(pathBox.origin.x, pathBox.origin.y + pathBox.size.height)
                      };
                  
                      ccDrawPoly(verts, 4, YES);
                  }
                  

                  感谢 Cocos2D 网站上的 Blue Ether 的提醒:http://www.cocos2d-iphone.org/forum/topic/21718?replies=5#post-120691

                  Thanks to Blue Ether over at the Cocos2D site for the heads-up: http://www.cocos2d-iphone.org/forum/topic/21718?replies=5#post-120691

                  这篇关于显示 CGRect 边框的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 场景重启?)
                  <tfoot id='K6JRw'></tfoot>
                    <bdo id='K6JRw'></bdo><ul id='K6JRw'></ul>

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

                        • <small id='K6JRw'></small><noframes id='K6JRw'>

                            <tbody id='K6JRw'></tbody>
                            <legend id='K6JRw'><style id='K6JRw'><dir id='K6JRw'><q id='K6JRw'></q></dir></style></legend>