Animating Backgrounds

Started by kaputtnik, Sun 08/05/2005 11:02:52

Previous topic - Next topic

kaputtnik

Hey there.
I'm expecting a "no", but I'll ask anyway.

Is there any way of animating backgrounds with more than just the four additional sprites? Or: Is there any way to set the delay between the different sprites separately?
I, object.

RyRayer

#1
I don't know about that, but you can add characters, which animate repeatedly and set their Idling delay 0 like THAT:

Code: ags
character[*your character's name*].SetIdleView(3,0);


3 is view. Change it to your own view.
0 means that it animates repeatedly.

Put this code to your room's "Player enters screen(before fadein)" -  run script.

You can change sprite changing delay in views section.

I hope this helps.

I made a template just in case. here


Ubel

The answer is no (for version 2.62 anyway). But of course you can use animated objects. That would probably be easier than using characters.

RyRayer

I use character my self because i have problems using objects. They keep blocking my game and if I set Eblocking no, object stops animating.

strazer

Quote from: egalotron on Sun 08/05/2005 11:02:52Or: Is there any way to set the delay between the different sprites separately?

If you really need the whole background to be animated, you could do it like this:

In a room with 3 background frames, to let the frames stay for 8, 10 and 7 game loops respectively:

Code: ags

// room script file

#define NUM_BACKGROUNDFRAMES 3 // including normal background (maximum 5)

int BackgroundFrameDelay[NUM_BACKGROUNDFRAMES]; // stores the delays of each background frame (in game loops)
int CurrentBackgroundFrame = 0; // stores currently displaying background frame (start with first one)
int CurrentDelay; // stores current delay before displaying next frame


function repeatedly_execute_always() {
  //...

  if (IsGamePaused() == 0) { // if game is not paused

    if (CurrentDelay) CurrentDelay--; // if delay has not expired yet, decrease it
    else { // if delay until next frame has expired
      SetBackgroundFrame(CurrentBackgroundFrame); // display selected background frame
      CurrentDelay = BackgroundFrameDelay[CurrentBackgroundFrame]; // set delay until next frame
      CurrentBackgroundFrame++; // select next background frame
      if (CurrentBackgroundFrame >= NUM_BACKGROUNDFRAMES) CurrentBackgroundFrame = 0; // if reached last background frame, select first one (loop)
    }

  }

  //...
}


function room_x() {
  // script for room: Player enters screen (before fadein)

  //...

  BackgroundFrameDelay[0] = 8;
  BackgroundFrameDelay[1] = 10;
  BackgroundFrameDelay[2] = 7;


  //...
}

kaputtnik

Thanks a lot strazer, that was just what I was looking for.
I, object.

SMF spam blocked by CleanTalk