[Solved] Keep the same object frame when changing rooms

Started by Rhye, Sat 28/03/2015 19:14:02

Previous topic - Next topic

Rhye

I have a clock which consists of an animated object with 840 frames.

What I want to do: move from Room 1 to Room 2, keeping the same clock time (frame).

What I have tried:

Room 1: (at Room Leave)
Code: ags

 int c;
 for(c = 1; c < 840; c++){
    if(object[12].Frame==c){
    clockpos[c]=object[12].Frame;
    }
  }


Room 2: (at Room Load / After Fade In)
Code: ags

    int c;
    for(c = 1; c < 840; c++){
      if(clockpos[c]!=0){
      object[12].SetView(3, 0, clockpos[c]);
      object[12].Animate(0, 0, eRepeat, eNoBlock, eForwards);
      }
    }


What I get: the clock loop starts from the first frame after changing the room.
I appreciate any suggestions.

monkey0506

I could be wrong about this, but I don't think that Object.Animate starts from the current frame. I believe it always starts from frame 0 of the specified loop.

In any case, you do not need to use loops to track the state of a single variable.

You also should not use the object array in room scripts, because referring to the objects by ID makes your code less readable and thereby more error-prone.

What would probably be the simplest thing to do is to use a character instead of an object, as characters already persist across rooms. If you insist on using an object, you'll probably have to handle animating it (at least to the end of its loop) manually.

Rhye

#2
Never underestimate dummies... ;)
I'm sure I can reach the same effect with them, thank you monkey_05_06.
As for the object array, they have been used to reference objects by a script module.

SMF spam blocked by CleanTalk