Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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 1188 times)
0 Members and 1 Guest are viewing this topic.
Offline Luminem

Senior Newbie





« Posted 2012-12-21 18: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 19: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 11: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-23 00:11:32 »

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

 Grin

Smiley
Offline alesky

Junior Member


Medals: 2


mmm....


« Reply #4 - Posted 2012-12-23 12: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
http://docs.oracle.com/javase/tutorial/2d/text/index.html

what you have to look is this caption
http://docs.oracle.com/javase/tutorial/2d/text/drawmulstring.html
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

bye 


 
Offline Luminem

Senior Newbie





« Reply #5 - Posted 2012-12-24 12: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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (52 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!