Pexel Detection

Discussion in 'iOS Development' started by JoshuaCaputo, Jun 7, 2009.

  1. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    No... That's extremely easy. It's all CGPoint and CGRect.
  3. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    could you elaborate on that. C:
  4. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Every UIView has a CGRect that is its frame, a rectangle that is the space that the view is contained in. There are calls that see if rects intersect, you can check if two points are the same, anything. With a little work you can tell if a view is in a certain area.
  5. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    Well I know that

    (UIView).rect
    if (CGRectIntersectsRect([rect], [rect]){
    ect

    but the color collision, is his post misleading me?
  6. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    It's not that those red, black, and blue colors are literally there. It's to visually show you that he checks to see if the figure is in one of those regions.
  7. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Those colors are literally there, but hidden. That's actually fantastically clever. I would have drawn paths and checked my point relative to that. Clearly, the way I would have done it is super fail prone. The colors are simple, elegant, and te perfect solution.

    Great find!
  8. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    Im glad I helped you but you should help me by explaining how to achieve this.

    The way I am doing it is also very fail prone and I found this a few months ago but never have found how to do it.

    It would be an infinite help to Territory War.
  9. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    Yep, it's a great technique, will use it if I ever need to.

    I wouldn't use filled shapes though, I'd use just the outlines.

    And using CGRectIntersectsRect wouldn't have worked, as it checks for the View frame, which is a rectangle.
    That'd work if you have a lot of flat platforms, but not with slopes.
  10. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    AHHHH! so then what do you use!, thats my question in general!

Share This Page