View Full Version : best way for speech
teenagegluesniffer
06-01-2006, 08:35 PM
Okay, I know how i'm going to do..I just don't know the best way to go about actually doing it.
Here is how I was thinking of doing it, set up a text box in it's own layer and if you run into some one and hit enter or whateverthat layer becomes visible and that persons text shows up in it.
Is there a better way to do it than this one?
Do something like
if(this.hitTest(_root.person1)){
_root.talk1._visible=true
}else{
_root.talk1._visible=false
}
arkhan
06-02-2006, 05:26 AM
well..that would be the simplest way you can do it, but it sounds functional if all you want to do it show the 'dialog baloon'.
cryzabey
06-02-2006, 06:11 AM
if you exited the dialog box wouldn't you still be touching him so it would open again?
do something like
if(this.hitTest(_root.person1)){
if (Key.isDown(Key.SPACE)) {
_root.talk1._visible=true
}else{
_root.talk1._visible=false
}
}
arkhan
06-02-2006, 07:19 AM
personally I would do it in some other way..but I think the best way would be to following example:
function talk(){
var K = Key.getAscii()
if(K==32){//32 is ASCII spacebar
if(it.hitTest(that)){
if(that.baloon._visible){
that.baloon._visible=false
}else{
that.baloon._visible=true
}
}else{
that.baloon._visible=false
}
if(it.hitTest(other)){
if(other.baloon._visible){
other.baloon._visible=false
}else{
other.baloon._visible=true
}
}else{
other.baloon._visible=false
}
}
}
other.baloon._visible=false
that.baloon._visible=false
var list = new Object();
list.onKeyDown = talk;
Key.addListener(list);
the hitTests can be within a loop of objects currently on screen for sake of simplicity.
The Brown Cow
06-02-2006, 11:05 AM
I would have a movieclip of a window, with a dynamic textfield inside it. When the dialog box is displayed, set the text of the textbox to whatever needs to be said (which can come from variables ingame or from external files).
char1_hello = "Hi there, welcome to the game.";
dialog_mc.display_txt.text = char1_hello;
teenagegluesniffer
06-02-2006, 01:14 PM
Well, the first idea is what I was talking about doing, and have tried before.
I think I will do something similar to what arkhan said, I hadn't thought of doing that before. Thanks.
vBulletin® v3.7.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.