Gravity question

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

  1. JesseEtzler

    JesseEtzler New Member

    Joined:
    Jun 7, 2009
    Messages:
    19
    Likes Received:
    0
    Device:
    iPod touch
    I've got my gravity and jumping code setup but for some reason I get an error on this line of code... cube2.y += gravity; it keeps giving me the error "request for member "y" is not s structure or union :/ Is this supposed to be setup in another fashion or did I write this up all wrong ?
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    What is cube2? Does it indeed have a .y? Or are you trying to access cube2.center/origin/etc.y?
  3. JesseEtzler

    JesseEtzler New Member

    Joined:
    Jun 7, 2009
    Messages:
    19
    Likes Received:
    0
    Device:
    iPod touch
    cube2 is my UIImageView and it has all my other codes attached to it. Do I need to define and keep track of it's x and y with a CGpoint and such ? Also Gravity is an int that I declared that changes as certain if statements are called to check if it's on the ground or in the air at certain points.
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    UIImageView has no .y property. You will need to access either cube2.origin.y or cube2.center.y. The latter being, for some reason preferred by Apple; while the former is preferred by me.
  5. JesseEtzler

    JesseEtzler New Member

    Joined:
    Jun 7, 2009
    Messages:
    19
    Likes Received:
    0
    Device:
    iPod touch
    Got it working :] ended up making a CGpointMake and worked like a charm.

Share This Page