background animation bug?

Started by goodohman, Wed 10/11/2010 04:24:44

Previous topic - Next topic

goodohman


Hi,

I have a strange problem.
I have a room with 2 backgrounds, the main and the extra one.
When animating them, the extra one become all corrupted, as if the background is reduced to 4-bit color or something like that.
Then, in the editor it still looks ok,
BUT,
if in the editor I switch it to the main background, then save the room, then close the room editor, then reopen it and switch to the extra background, I can see the same corrupt background there.

The strange thing is that I have another room with extra background animating, and no problem there!

Does anyone has an idea??

All the backgrounds are 16-bit color. The problem happens regardless of the game being set as 16 or 32 bit.

a side question - is there a way to turn off the auto cycling of backgrounds without explicit SetBackground lockings?

TIA

Gilbert

Have you tried re-importing the backgrounds from the original image files?

Just a wild guess. It is possible that at one point some of the backgrounds were imported as 8-bit and then the game was changed to 16 or 32 bit in the editor, which may cause things like this.

Khris

Quote from: goodohman on Wed 10/11/2010 04:24:44
a side question - is there a way to turn off the auto cycling of backgrounds without explicit SetBackground lockings?

Try this:
  SetBackgroundFrame(GetBackgroundFrame());
This should stop the animation at the current background.

goodohman

Khris: that's a clever general purpose line of code :) though [in my case] since it's reset every room enter, it's actually equivalent to SBg(0) no? correct me if I'm wrong.

Gilbet V7000a: kinda what you said! I have originally had the game at 16 bits. The backgrounds never changed, BUT, after changing to 32 bit, if importing an EXTRA (not main) background, it will be corrupt. So the solution (read: workaround) is to revert to 16, import the background, then switch back to 32. I guess it's something to do with the main background saving all kinds of (palette?) information, sharing it with the extra backgrounds, but not updating properly.

Thank you for your help!


Khris

I see, in this case I'd store the current background in an array and restore it in room_Load.

Global.ash:
Code: ags
import int room_bg[];
import void StopRoomAnimation();
import void StartRoomAnimation();


Global.asc
Code: ags
int room_bg[];
export room_bg;

// in game_start
  room_bg = new int[Game.RoomCount];

// add to/create on_event
void on_event(EventType event, int data) {
  if (event == eEventEnterRoomBeforeFadein) Room.SetBackground(room_bg[player.Room]);
}

void StopRoomAnimation() {
  int bgf = GetBackgroundFrame();
  SetBackgroundFrame(bgf);
  room_bg[player.Room] = bgf;
}

void StartRoomAnimation() {
  SetBackgroundFrame(-1);
  room_bg[player.Room] = -1;
}

monkey0506

Yes, but there's no such thing as Game.RoomCount (though it would be nice). The current workaround is to use a static value such as:

Code: ags
#define AGS_MAX_ROOMS 300 // if you want to store the state only for state-saving rooms

// ..OR..

#define AGS_MAX_ROOMS 1000 // custom value here


IIRC there is a limit on the actual number of rooms, right?

goodohman


Thanks Khris. This is what I finally did, some variant of HandleCurrentRoomBackground()

btw, on another issue: is there a way to know whether the View is currently locked?
(currently I just use my own wrapper function for that purpose, setting a global boolean)

SMF spam blocked by CleanTalk