Room doesn't load if I try to move characters before fadein

Started by doctorhibert, Wed 08/03/2017 23:10:30

Previous topic - Next topic

doctorhibert

So my code is like this

Code: ags

function room_Load()
{
player.ChangeRoom(14, 250, 113);
cfortbot.ChangeRoom(14, 215, 187);
cfortbot.Transparency=100;
obackground.SetView(AUTOVIEW);
 obackground.Animate(0,  1, eRepeat,  eNoBlock);
}

I'm using an object the size of the background instead of a background because the animation has too many frames. If I delete the change rooms and the transparency the room loads just fine, the animation plays and the dialogue starts, but if I add them, all I get is a black screen. What's going on?

NickyNyce

What room number is this code in?
Is room 14 blank at the moment?

It appears the second you enter this room, you're asking your character to change to room 14.

Khris

If you want to move the player to specific coordinates, just set them manually:
Code: ags
  player.x = 250;
  player.y = 113;


If you're using ChangeRoom like that, and 14 is the current room, AGS will basically enter an infinite loop. The ChangeRoom command is queued, AGS runs the other commands, then reloads the room. Which means the function starts from the beginning, then again, and again, etc, and all the while the screen stays black.

(IIRC, I fully expected AGS to just move the player when I first tried to use ChangeRoom like this and was surprised by the result, but it does make sense to do that if you do want to reset the room.)

SMF spam blocked by CleanTalk