Start Simple Game

Discussion in 'iOS Programming' started by testgame, Aug 31, 2010.

  1. testgame macrumors newbie

    Joined:
    Jun 9, 2010
    #1
    Hello,

    I m new to iPhone Platform.I want to make simple game.

    In my game i need some data like (Score, levelnumber,etc) throughout game. How can i declare this variables. I know only one way. But i think it is not proper. Create one global.h file. add all global variables in this file & import global.h file when i want to use this data.

    I heard about delegate & protocol.

    Please tell me which is best way to transfer data between views & track global data throughout app.

    Thanks in Advance.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Either put properties in your application delegate object which is easily available via the global singleton UIApplication or create your own singleton object that represents the game in progress. For one or two items of data I'd go the first way, more than that the second.
     
  3. rossipoo macrumors regular

    Joined:
    Jun 7, 2009
    #3
    Another way would be to send notifications with pertinent userInfo when game data changes, and then objects can register to recieve notification that interest them. For example you could subclass a uiLabel which watches for gameScoreChange notifications, and changes it's text to the new score.
     
  4. testgame thread starter macrumors newbie

    Joined:
    Jun 9, 2010
    #4

    Thank u very much to both for replying.

    This answers will really help me.
     

Share This Page