User Tools

Site Tools


scratch

This is an old revision of the document!


One of the unique features available within Orx is the ability to switch languages in game using locale. While many game engines allow a user to program with locale features to some degree, Orx lets you switch languages back and forth in real-time.

An example of this could be a graphical adventure game that features characters, onscreen text, digital speech, and music. Locale switching would allow you to completely switch out all graphics, text, speech and music with a single function call without altering the game-play.

All data is defined by you, and so your regions or nations could be aliens/humans, orcs/elves. You could even think of it as a kind of themeing.

Its a pretty amazing feature that comes out of the box.

This tutorial will be done in two steps:

1. Create a simple game with characters with their own look, speech and music. 2. Add in a second locale, and be able to switch between them.

Begin with a blank project created using init.

Name your project something like the-conversation (or whatever you wish).

Our game will be about two polite gentlemen having a conversation. They continually greet each other all day.

Eventually, we want to be able to switch their nationality, as the player may prefer to play the game in their own country and language.

Assets

Let's begin with the French assets, and build the French version first.

Object

Speech

Music

Delete the default config object and FX sections. We wont need those.

Create the default Person object in the config with:

[]

Create a second person from the first, but one that stands on the other side and faces the other way:

[]

Next, create a Scene object that will be the root to hold all the other objects. Then place both Person objects in it's Childlist.

[]

Create the scene in the game in code. This will create all the child objects onscreen. You can just change the existing Object creation with Scene, from:

[]

to:

[]

Create all the text objects to go onscreen. You will need text objects for:

- The speech - The player instructions - The current language indicator

Create these as:

[]

And now place them into the scene by adding them to the Childlist:

Next is the music. Define it with:

[]

And add it to the scene with:

[]

Next is the actual conversation. Define the speech with:

[]

Them using a timeline track switch on and off the alpha of the speech text object to make it appear/disappear, move its position and play the sounds.

Compile and run. Our two French gentlemen will start having a lovely conversation.

That is the basic game. Now to make the game switchable to Australia mode.

Begin by defining the two languages or locales for the game: French and Australian.

Next, define.those locales and create keys for the various assets that are required to switch out: graphics, sound and text

Finally go to each config and replace the absolute pathsnto assets and text with the named keys in the locale sections. These locale keys are.called using the $ symbol

scratch.1545622027.txt.gz ยท Last modified: 2021/02/02 01:24 (external edit)