Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Peegee on Thu 27/04/2023 08:04:20

Title: Changing sprites in different languages
Post by: Peegee on Thu 27/04/2023 08:04:20
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?
Title: Re: Changing sprites in different languages
Post by: Khris on Thu 27/04/2023 12:00:42
It should work like this:

  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.
Title: Re: Changing sprites in different languages
Post by: Peegee on Thu 27/04/2023 16:07:29
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?
Title: Re: Changing sprites in different languages
Post by: Peegee on Thu 27/04/2023 20:34:17
Hello Khris, Actually, I don't understand your proposal...

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

??
Title: Re: Changing sprites in different languages
Post by: Khris on Fri 28/04/2023 15:57:44
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:

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);
}
Title: Re: Changing sprites in different languages
Post by: Peegee on Sat 29/04/2023 17:16:21
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
Title: Re: Changing sprites in different languages
Post by: Peegee on Sat 29/04/2023 17:17:39
PS: I could never put the code in black! I can't find the info.
Title: Re: Changing sprites in different languages
Post by: Snarky on Sat 29/04/2023 20:17:24
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.