Set all character baselines. Solved

Started by Pax Animo, Sat 25/06/2022 12:18:06

Previous topic - Next topic

Pax Animo

Hello,

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

Code: ags
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.

Misunderstood

Pax Animo

#1
Code: ags
 for (int i = 0; i < Game.CharacterCount; i++)
{
  character[i].Baseline = 723;
}


Oh this seems to work but not for all characters.

Misunderstood

Crimson Wizard

Quote from: Pax Animo on Sat 25/06/2022 12:30:33
Oh this seems to work but not for all characters.

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

Pax Animo

#3
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. :-|
Misunderstood

SMF spam blocked by CleanTalk