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

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

    Hello!

    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
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    hello, I can't understand your needs.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    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
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    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, 09:26 AM
  2. Replies: 12
    Last Post: 11-26-2010, 08:33 AM
  3. Replies: 1
    Last Post: 11-04-2010, 06: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, 01:05 PM
  5. Replies: 5
    Last Post: 01-11-2009, 10: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
  •