Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Dialog Box System  (Read 3660 times)
0 Members and 1 Guest are viewing this topic.
Offline Luminem

Senior Newbie

« Posted 2012-12-21 17:43:26 »

Hi guys... this is easy :s how can i make a dialog system?... I wanna say write dialogs in a text file and insert them inside the game. Actually i have a system that load the dialogs and show them at the screen but, how can i do for "dialog jumps" i.e "First" show the first ten lines of dialogs, and after you need press enter to show more lines. :S How can i do that?

Simply Perfect
Offline tyeeeee1
« Reply #1 - Posted 2012-12-21 18:19:09 »

Well I'm not entirely sure how you want it to work but I'd just save everything as string variables, then load them into a JTextArea and put in an actionlistiner that changes the displayed message whenever the user presses the enter key.
Offline Luminem

Senior Newbie

« Reply #2 - Posted 2012-12-22 10:53:10 »

I thought to use an array of strings to do it but i'm not sure. And i'm using it inside my game like the classic dialogs of Zelda or Pokemon.

Simply Perfect
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline masteryoom

JGO Coder

Medals: 5
Projects: 2

If you look closely, you might see it turning...

« Reply #3 - Posted 2012-12-22 23:11:32 »

In .properties file:
Dialogfor(insert name): Bla BLa BLA!!!


Offline alesky

Junior Devvie

Medals: 3
Exp: 15 years


« Reply #4 - Posted 2012-12-23 11:39:28 »

how can i do for "dialog jumps" i.e "First" show the first ten lines of dialogs,

first, what technologies are u using?  Java2D or other? because the solution can give yoou completely different answers
for Java2D for example exists already API to support text management
but i f you are using UI component (Jtext etc...) is a completely different story.

Ok hire i will suppose that you are using JAva2D.
in this case you can find hire the official tutorial of the Oracle that show how to use the text in a Java2D graphic context
they are no more of 4-5 capiton very easy to undestand

what you have to look is this caption
it will solve your problem to fix in you dialog box (drawing area) the text that you want to insert

after you need press enter to show more lines. :S How can i do that?
instead regarding the way to insert dialog box that evolve the internal text after return press, can be easy and there are 1000 solution, but each one of this solution will be incorrect if it is not easy adaptable to the framework that you implemented.

for example if u have the text in the file you can do like this
  • 1-load the text that you want to print and transform in a array of chars
  • 2-give this array as parameter to your dialog box
  • 3-the dialog box contain an internal state that is the index where to start to use the character in the array, for example when it will start for the first time the index will be 0,
  • 4-the dialog box print the x characted that are possible in concordance with its size and update the index
  • 5-at each press enter continue the iteration 3 and 4 until the text is finish

but be carefull this solution has a problem for example its eat chatacters!!!!
immagin that you want to write this string in your dialog
"test string, i like write text in java" that is 38 chars
and your dialog write only 10 characters the result after any press return is
1 return "test strin"
2 return "g, i like w"
3 return "rite text i"
4 return "n java"

so take care to raffinate the algorithm to don't cut the words, for exaple you can use a StringTokenizer to reconize words


Offline Luminem

Senior Newbie

« Reply #5 - Posted 2012-12-24 11:05:42 »

okay Cheesy i understand it but now i have a tiny question. Can i put a dialog between 2 "characters" in the same file or i must create a file for every "single dialog"?

Simply Perfect
Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (863 views)
2018-03-24 14:47:39

ivj94 (124 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!