Results 1 to 4 of 4
  1. #1
    MadsPH is offline Member
    Join Date
    Jul 2011
    Rep Power

    Default Way to get a String AND an int, from an int


    I'm currently writing a game, where I'm implementing dialogues. I found that it's easiest if each dialogue link to the next dialogue in the chain, with an ID. Therefore, they all have ID's.

    Now, when I get to a dialogue where the player needs to select different options, it gets a little hard.
    I need to have a list of sorts, with the different options and the ID each option would lead to.
    I also need to be able to draw each element, and highlight one of them.

    I thought about having an array with Strings (for the different choices), but I also need the ID-int.
    The index of the array would be used to tell the options apart, because I need to be able to highlight one, and grab the object thats selected.

    Is there anything that could suit my needs?

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Zurich, Switzerland
    Rep Power


    hello, I can't understand your needs.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    On vacation
    Rep Power


    I need to have a list of sorts, with the different options and the ID each option
    Would a HashMap with the key = an option and the value = the ID do it?

  4. #4
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Camp Lejuene, North Carolina
    Rep Power


    A HashMap or a multi-dimensional Array might solve your problem. Depending on how you set up your dialog system.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

Similar Threads

  1. Replies: 6
    Last Post: 12-06-2010, 10:26 AM
  2. Replies: 12
    Last Post: 11-26-2010, 09:33 AM
  3. Replies: 1
    Last Post: 11-04-2010, 07:53 PM
  4. combine string[] into string like perl's join function
    By tekberg in forum Advanced Java
    Replies: 9
    Last Post: 02-23-2009, 02:05 PM
  5. Replies: 5
    Last Post: 01-11-2009, 11:12 AM

Posting Permissions

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