AGS Support > Beginners' Technical Questions

Set all character baselines. Solved


Pax Animo:

So i'd like to simply change all the baselines of characters in game via character array size, i've tried this:

--- Code: Adventure Game Studio ---function game_start(){  int test = Game.CharacterCount-1;  //gets the number of characters in game. (Without the -1 on the end i get an out of bounds error.)  character[test].Baseline = 723; //my attempt to change all character baselines via the "test" variable.} 
Game loads without issues but the baselines don't change.

Edit: um ok, i see now what that code is doing, its getting the last character in the array and setting that character's only baseline.

Cheers in advance for any advice.

Pax Animo:

--- Code: Adventure Game Studio --- for (int i = 0; i < Game.CharacterCount; i++){  character[i].Baseline = 723;}
Oh this seems to work but not for all characters.

Crimson Wizard:

--- Quote from: Pax Animo on 25 Jun 2022, 12:30 ---Oh this seems to work but not for all characters.

--- End quote ---

The code looks correct though. What happens instead? Are you absolutely sure you dont change Baselines somewhere else in script?

Pax Animo:
Thanks, all sorted now, I was setting the baseline of a character which fills the hole screen before running the for loop, it obviously needs to be after the for loop.

Edit: i see my mistake was not posted in the original code or this would have been solved much sooner, my bad. :-|


[0] Message Index

Go to full version