Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Text and voice scene. Lock movement in the x-axis or keyboard control?  (Read 12129 times)

0 Members and 1 Guest are viewing this topic.

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile

Hey Wintermute community!

I searched through this forum and only found partial answers to my questions, that is why I decided to ask them here, in the new topic.

1. What is the easiest and smoothest way to create a scene with just text on screen and voice behind, maybe with some background image or just against black screen? I found an advice about making a text window and then unloading it, but what about text AND voice (talk)?

2. Is there a way to kinda lock actors' movement in the x-axis, so that they moved in a straight horizontal line, without swaying up and down in the y-axis? The point is there won't be any depth in my game, everything's pretty flat. Previously I asked this in one of the previous topics and anarchist shared a brilliant idea of making two blocked regions with a narrow walking path between them for actors. Still, sometimes I notice actor sprites do sway up and down a bit within that walking stripe. Is there a code to ban actors from moving in the y-axis at all or is keyboard control with LEFT and RIGHT keys the only way to provide movement in a perfect horizontal line?

What do you think? Maybe someone has already solved such things in their games?

THANK YOU for your ideas and experience!
 
Logged
Owls are not what they seem...

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #1 on: November 29, 2017, 10:24:57 PM »

(1) What I did was create an empty scene and then:

In scene_init.script

Code: WME Script
  1. Game.Interactive = false;
  2. var YourWindow = Game.LoadWindow("interface\YourWindow\YourWindow.window");
  3. YourWindow.Center();
  4. Game.FadeIn(2000);
  5.  

Then, in YourWindow.script

Code: WME Script
  1. #include "scripts\base.inc"
  2. #include "scripts\keys.inc"
  3.  
  4. Game.PlayMusicChannel(0, "your_sound_file.ogg", true);
  5.  

YourWindow should be sized so that it covers the whole scene.
Logged

NAItReIN

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 69
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #2 on: November 30, 2017, 02:42:53 PM »

Hi guys  :)

Quote
1. What is the easiest and smoothest way to create a scene with just text on screen and voice behind, maybe with some background image or just against black screen? I found an advice about making a text window and then unloading it, but what about text AND voice (talk)?

As anarchist wrote you can do it with window. But be sure there is also other way how to achieve this.
1. Add new entity to your project, for example entities\speaker\speaker.entity
You can set subtitles possition as you wish.
If you want to have an invisible entity you can use only one bitmap with pink color. This makes the sprite invisible.

SubtitlesPosRelativeSpecifies whether the SubtitlesPosX and SubtitlesPosY attributes are relative to default position, or absolute screen coordinates
SubtitlesPosXThe X position of speech subtitles (either relative to speaker's position or absolute screen coordinates)
SubtitlesPosYThe Y position of speech subtitles (either relative to speaker's position or absolute screen coordinates)
SubtitlesWidthWidth of speech subtitles. Set to zero to restore the default behavior.
SubtitlesPosXCenterSpecifies if the SubtitlesPosX attribute affects the center of the subtitle or its left side.
For futher information see WME Documentation, section Scripting in WME, Script language reference and at last Entity object.

Now open your scene_init.script and load your entity to your current scene. Note: you don´t need to unload entity from memory because when you leave current scene the game will unload your entity automatically.

Code: WME Script
  1. // we want an invisible speaker
  2. var entSpeaker = Scene.LoadEntity("entities\speaker\speaker.entity");
  3. entSpeaker.Talk("Hi Indra Anagram, how are you today?");
« Last Edit: November 30, 2017, 03:35:00 PM by NAItReIN »
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #3 on: December 01, 2017, 08:26:54 PM »

Hey anarchist!

I am sorry for being slow with reply.

In scene_init.script

Code: WME Script
  1. Game.Interactive = false;
  2. var YourWindow = Game.LoadWindow("interface\YourWindow\YourWindow.window");
  3. YourWindow.Center();
  4. Game.FadeIn(2000);
  5.  

I created a window that covers the whole screen and followed every step of your detailed advice. The only problem I encountered was YourWindow.Center(); line. As Debugging console says:

Quote
0:42:19:  Maximum texture size: 4096x4096
0:42:19:  Engine initialized in 81 ms
0:42:19: 
0:42:20:  'WINDOW' keyword expected.
0:42:20:  Error parsing WINDOW file 'interface\YourWindow\YourWindow.window'
0:42:20:  Runtime error. Script 'scenes\Text1\scr\scene_init.script', line 30
0:42:20:    Call to undefined method 'Center'. Ignored.

What is the function of 'Center' in this code? How do I define it?

THANK YOU for your kind help, anarchist!
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #4 on: December 01, 2017, 08:35:15 PM »

Hello, NAItReIN!

I am sorry it took me so long to answer your message. I created an invisible entity, just like you wrote and it worked. As I run the scene, text appears at the top of screen. However, I've got two questions:

SubtitlesPosRelativeSpecifies whether the SubtitlesPosX and SubtitlesPosY attributes are relative to default position, or absolute screen coordinates
SubtitlesPosXThe X position of speech subtitles (either relative to speaker's position or absolute screen coordinates)
SubtitlesPosYThe Y position of speech subtitles (either relative to speaker's position or absolute screen coordinates)
SubtitlesWidthWidth of speech subtitles. Set to zero to restore the default behavior.
SubtitlesPosXCenterSpecifies if the SubtitlesPosX attribute affects the center of the subtitle or its left side.
For futher information see WME Documentation, section Scripting in WME, Script language reference and at last Entity object.

1. Where do I specify SubtitlesPosX etc.? What file should it be in?
2. How do I play the voice file at the same time with the text being on screen?

THANK YOU, NAItReIN! You and anarchist are amazing. Seriously, guys.
Logged
Owls are not what they seem...

NAItReIN

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 69
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #5 on: December 02, 2017, 12:44:34 AM »

Hi Indra Anagram  :)

Quote
1. Where do I specify SubtitlesPosXetc.? What file should it be in?
Let me show you an example. Open your speaker.script and write something like this:

Code: WME Script
  1. #include "scripts\base.inc"
  2. this.SubtitlesPosRelative = false;
  3. this.SubtitlesPosX = 250;
  4. this.SubtitlesPosY = 500;
  5. this.SubtitlesWidth = Game.Width - 100;
  6. this.SubtitlesPosXCenter = center.

Quote
2. How do I play the voice file at the same time with the text being on screen?

You should use Talk method. See what does documentation say:

Talk(Text, SoundFilename, Duration, TalkStances, TextAlignment)
TalkAsync(Text, SoundFilename, Duration, TalkStances, TextAlignment)

Makes the object talk.
Parameters :

Text

A text to be used as a talk subtitle

SoundFilename
A filename of a sound file to be used (oprtional, default is no sound)


Duration
A subtitle duration in milliseconds (optional, default is 0)

TalkStances
A comma separated list of talk "stances" to be used for the talking (optional, default is random stances)

TextAlignment

A text alignment for the subtitle (0-left, 1-right, 2-center) (optional, default=2) 

Remarks
Talk method blocks the script execution until the animation is over, while the TalkAsync method returns immediately. If the duration is set to zero, it's calculated automatically either from the sound file or from the length of the subtitle.
« Last Edit: December 02, 2017, 12:52:10 AM by NAItReIN »
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #6 on: December 02, 2017, 07:18:38 AM »

Hey NAItReIN,

You should use Talk method. See what does documentation say:

Talk(Text, SoundFilename, Duration, TalkStances, TextAlignment)
TalkAsync(Text, SoundFilename, Duration, TalkStances, TextAlignment)

Makes the object talk.
Parameters :

Text

A text to be used as a talk subtitle

SoundFilename
A filename of a sound file to be used (oprtional, default is no sound)


The good news is once I added a comma and the name of a sound file to this line:

Code: WME Script
  1. entSpeaker.Talk("Hi Indra Anagram, how are you today?", "1.3.ogg");

the sound file started playing while the text is on screen. THANK YOU!

As for this:

Code: WME Script
  1. #include "scripts\base.inc"
  2. this.SubtitlesPosRelative = false;
  3. this.SubtitlesPosX = 250;
  4. this.SubtitlesPosY = 500;
  5. this.SubtitlesWidth = Game.Width - 100;
  6. this.SubtitlesPosXCenter = center.

there were some issues.

First, I got the following error in Debugging console:

Quote
11:56:33:  Compiling script 'entities\speaker\speaker.script'...
11:56:33:    Error@line 7: syntax error

I thought maybe the problem was in the period, changed '.' to ';' and the error@line7 disappeared, but a new one showed up:

Quote
11:57:28:  Compiling script 'entities\speaker\speaker.script'...
11:57:28:    Error@line 6: Variable 'center' is referenced but not defined

And this code does not change anything - the text has default position at the top of screen  :) I played with it commenting out line by line and changing 'false' to 'true', but it didn't cause the text move to the positions we wanted.

Any ideas what could be the reason? And how to eliminate error@line 6?

THANKS!
Logged
Owls are not what they seem...

NAItReIN

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 69
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #7 on: December 02, 2017, 12:16:44 PM »

Hi Indra Anagram  :)

I'm sorry I made a mistake. There is a problem with this line:
Code: WME Script
  1. this.SubtitlesPosXCenter = center
has to be
Code: WME Script

Now it should works fine  :)
« Last Edit: December 02, 2017, 12:20:13 PM by NAItReIN »
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #8 on: December 02, 2017, 02:11:06 PM »

Now it should works fine  :)

Hey NAItReIN, the error's gone! However, the text is still glued to the top of screen. Sorry, I don't know what's the reason.

THANK YOU for your help!
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #9 on: December 02, 2017, 03:20:53 PM »

Hi anarchist!

Sorry, there was some issue with the .window file on my side - once I opened it in the Notepad after WindowEdit, WindowEdit refused to re-open it ('unsupported file format').

It seems everything works fine now.

First, the sound file was playing over and over again, till I found Looping parameter in the Documentation and set it to "false". So, now it plays once, just like it should.

I've got a question, though... What if I have a long text that is better to show sentence by sentence on screen (in this window?). What do I change in the code or files? Do I create a new window for each sentence and sound file? Or is there a way to "erase" first sentence within the same window and play another sound file at the same time? What was your background in that regard? Please, share your thoughts.

I tried your and NAItReIN's advice - both worked. NAItReIN's decision seems more flexible and logical in function (changing text sentence by sentence, for instance), but yours succeeded in terms of design. Plus I had some new experience with creating windows))

THANK YOU, anarchist!
« Last Edit: December 02, 2017, 03:23:16 PM by Indra Anagram »
Logged
Owls are not what they seem...

NAItReIN

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 69
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #10 on: December 02, 2017, 07:36:00 PM »

Quote
Hey NAItReIN, the error's gone! However, the text is still glued to the top of screen. Sorry, I don't know what's the reason.

Indra Anagram, please, see image bellow:
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #11 on: December 02, 2017, 07:59:11 PM »

Indra Anagram, please, see image bellow

Hey NAItReIN!

You never give up, I see!  ;)

BIG THANKS for your enthusiasm in helping beginners like me on this forum.

I have looked at your screenshot. As I far as I can tell, it contains
Quote
on "LeftClick"
, so in order to see that subtitle a player must use a mouse. See, my initial point was a scene with voice and text that sound and appear while the game is not interactive. Automatically you might say)

Have made some changes to the code of speaker.script according to your lines in the screenshot, however it changed nothing. The thing is just stuck up there at the top!

And... what do we do with this?

Code: WME Script
  1. var entSpeaker = Scene.LoadEntity("entities\speaker\speaker.entity");
  2. entSpeaker.Talk("THANK YOU, NAItReIN!", "1.3.ogg");


I mean LeftClick thing and invisible speaker.

You and anarchist are my heroes whatever  ::thumbup
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #12 on: December 02, 2017, 08:11:13 PM »

Indra Anagram, please, see image bellow

NAItReIN, I've just changed X and Y values in speaker.entity file and guess what? The subtitle text left its initial position at the top of screen and moved closer to its center! Which means in this method subtitles are completely dependent on the position of entity sprite)))

Without your screen I probably wouldn't have guessed.

 ::rock

Yay! THANKS!!!
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: Text and voice scene. Lock movement in the x-axis or keyboard control?
« Reply #13 on: December 03, 2017, 02:09:39 PM »


2. Is there a way to kinda lock actors' movement in the x-axis, so that they moved in a straight horizontal line, without swaying up and down in the y-axis? The point is there won't be any depth in my game, everything's pretty flat. Previously I asked this in one of the previous topics and anarchist shared a brilliant idea of making two blocked regions with a narrow walking path between them for actors. Still, sometimes I notice actor sprites do sway up and down a bit within that walking stripe. Is there a code to ban actors from moving in the y-axis at all or is keyboard control with LEFT and RIGHT keys the only way to provide movement in a perfect horizontal line?

Guys, any ideas about the second question?

Thank you for your thoughts and practical experience!
Logged
Owls are not what they seem...
 

Page created in 0.065 seconds with 20 queries.