Changing sprites in different languages

Started by Peegee, Thu 27/04/2023 08:04:20

Previous topic - Next topic

Peegee

Hello,

 I made buttons in the basic menu of the game, New game, Load, Quit, Credits, in French. I made them with objects, animated. I can use, in the English version the change of object sprite... but how to change the sprites that constitute the button animation?

Khris

#1
It should work like this:

Code: ags
  int new_game_view = BTNNEWGAME;
  int load_view = BTNLOAD;
  // ...
  if (Game.TranslationFilename == "English") {
    new_game_view = BTNNEWGAMEENG;
    load_view = BTNLOADENG;
    // ...
  }
  btnNewGame.Animate(new_game_view, ...);
  btnLoad.Animate(load_view, ...);

Wait, you're using Room Objects? The basic idea is the same though. You don't change the sprites of the view but create a 2nd view containing the translated sprites and use that for the animation.

Peegee

Code: ags
Okay, it must be simple, I put this:


code[ags]

function oJouer_AnyClick()
{
  if (Game.TranslationFilename == "Game Default")  
{
oJouer.SetView(95);
oJouer.Animate(0, 3, eOnce);

}
  if (Game.TranslationFilename == "English") 
{
oJouer.SetView(95);
oJouer.Animate(5, 3, eOnce);

}  
  
player.ChangeRoom(102, 129, 171, eDirectionDown);

aZik01.Stop();

}

But he no longer plays the animation in "Game Defaut", I don't understand why?

Peegee

Hello Khris, Actually, I don't understand your proposal...

code:ags
  int new_game_view = BTNNEWGAME;
  int load_view = BTNLOAD;
/ags

??

Khris

Those are view names so you don't have to use the numbers in your script. When you create a new view in the project tree, you're asked to rename the view. You can also change the name at any time in the properties.

You're correct though, you only need a different loop to switch the sprites.

Given your code it should probably be:

Code: ags
function oJouer_AnyClick()
{
  int loop = 0; // default
  if (Game.TranslationFilename == "English") loop = 5;
  oJouer.SetView(95); // you can use the view's name instead of 95 here
  oJouer.Animate(loop, 3, eOnce);
  aZik01.Stop();
  player.ChangeRoom(102, 129, 171, eDirectionDown);
}

Peegee

Hello Khris, sorry, I didn't see your answer in time... I still found a solution, it was enough to remove "game default" in my code so that he can play the animation in French:

Code:ags
  if (Game.TranslationFilename == "")
/ags

Thank you. For your information, my Gobliiins5 game is almost finished!

Pierre Gilhodes

Peegee

PS: I could never put the code in black! I can't find the info.

Snarky

Quote from: Peegee on Sat 29/04/2023 17:17:39PS: I could never put the code in black! I can't find the info.

Try quoting one of Khris's posts with embedded code. That way you can see how he does it.

SMF spam blocked by CleanTalk