Colisions?

Discussion in 'iOS Development' started by tom10122, Apr 26, 2010.

  1. tom10122

    tom10122 New Member

    Joined:
    Apr 24, 2010
    Messages:
    16
    Likes Received:
    0
    how would i make it so tht when an imag/object collides with something it changes its direction
  2. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    short of using a full-fledged physics engine, here are some helpful functions:

    CGRectIntersectsRect()
    CGRectContainsPoint() // maybe
  3. tom10122

    tom10122 New Member

    Joined:
    Apr 24, 2010
    Messages:
    16
    Likes Received:
    0
    thnx

    thnx how would i use them(me = noob)
  4. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    well, CGRectIntersectsRect() takes two CGRect structs as arguments, and returns type 'bool' (a C99 type, same as BOOL for our purposes.

    get the frames of the two views you want to "check", pass them to the function...evaluate the result in an if statement...simple.

    if you have trouble with that, I advise you to take a step back and learn Objective-C (including underlying C language features)
  5. tom10122

    tom10122 New Member

    Joined:
    Apr 24, 2010
    Messages:
    16
    Likes Received:
    0
    thnx this is perfect

Share This Page