×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    3

    Passing variables from one class to another

    I seem to have a problem with what should be something I can normally do.
    I must be getting rusty.
    Anyways what I'm trying to do is trying to pass variables from my menu class into the game class for example:
    I have a team selection menu and i select team 1 and colour red.
    This equates to Team = 1, colour =2 for example.
    I then switch to the next class and displayable to the game engine.
    I would obviously want to use the variables stored from the previous class but using a method like this:

    MenuScreen

    Code:
    public int getVariables()
        {	
    	return TeamArray[GeneralSelected][SoldierStereotypeSelected][ColourSelected];	
        }
    and then calling it in the game engine class

    Code:
    menu.getVariables ();
    is not going to work.
    Tried but never really expected it to work.
    Hopefully I've gotten the idea across of what I'm trying to do.

  2. #2
    Super Contributor
    Join Date
    Jun 2007
    Location
    Mumbai
    Posts
    539

    Re: Passing variables from one class to another

    Hey..are your team and color are member of Class Menu? If that is a case then u can make a constructor in which u pass color and the team, and u will get object of that class with those parameters.

Similar Threads

  1. External Linking Error (Undefined Symbol)
    By nile_mail in forum Symbian
    Replies: 2
    Last Post: 2008-08-05, 13:10
  2. Linking Error(Undefined Symbol)
    By nile_mail in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 10
    Last Post: 2008-03-26, 23:32
  3. need information about j2me polish
    By rathikathangaraj in forum Mobile Java General
    Replies: 4
    Last Post: 2007-12-19, 09:01
  4. 2 TRgb class variables crash app ??
    By sandopolus in forum Symbian
    Replies: 1
    Last Post: 2006-05-20, 23:28
  5. Exceptions while loading application
    By avinash_rs in forum Mobile Java General
    Replies: 0
    Last Post: 2003-06-09, 10:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×