Strangest Problem With "SetBackgroundFrame"... [SOLVED]

Started by DoorKnobHandle, Tue 01/03/2005 21:05:46

Previous topic - Next topic

DoorKnobHandle

Hey,

I have a room with animating frames. Now, when I add those frames, the small preview pictures in the "Add Animating Frame" Dialog Box are black, not how they are supposed to be (My room is 1600x1200, does that have to do anything? My pictures are in the proper colour depth etc...)

When I use SetBackgroundFrame in my script nothing happens. I know I use the command right and everything...

Can anybody help me? What does it mean when those preview things just turn black???

Gilbert

What about don't use SetBackgroundFrame() in your script and test the room to see if it actually animates using the imported frames?

DoorKnobHandle

It works then! It also works with the preview room feature!

It's still puzzling me...

strazer

QuoteWhen I use SetBackgroundFrame in my script nothing happens.

What's the exact code you're using and where have you put it?

DoorKnobHandle

I have one room, which is usually a main menu background.

Then when the user starts the game, it changes the background using this piece of code:

Code: ags

SetBackgroundFrame ( 2 );


I tried it with different values.
I have three animated frames plus the one we're starting with ( main menu )...

That's everything. I really can't see anything wrong at all... Well, that's why I posted :) :( ...

strazer

Is the main menu also the first room? I don't quite understand.

Is the start game button a hotspot, object or gui button? Is its interaction triggered at all? Check with a Display command.

DoorKnobHandle

Ok, again... :)

So, the standard sprite of my room 1 is the main menu background. We have a gui there and it has a button - the "new game"-button. If we click this button, we start a new game (woo, I know) and the gui is turned off and a function called "init_game ( )" is called. In this function I call "SetBackgroundFrame ( int frame )" to change the background to one of my animated extra frames, since those contain game backgrounds...

Everything gets called correctly. I double-checked it!

strazer

Hm, the only thing I can think of is maybe the GUI is popup modal, thus pausing the game while it's displayed and not allowing the background frame to be set.

Do you turn off the gui before or after calling init_game?

Also, try setting the GUI to normal.

Gilbert

Quote from: mamarulez on Wed 02/03/2005 19:42:59
Then when the user starts the game, it changes the background using this piece of code:

By "when the user starts the game" did you mean you put the change in game_start() or the "player enters room script?
If it's in game_start() it should never work (even if the game didn't crash with an error), as during game_start(), not even room data is loaded into memory, that function is supposed to do some pre-game-data-loading initializations only.

DoorKnobHandle

I wrote the function "init_game" myself. The room script is 2000 lines big in total. But the function is getting called correctly, since other commands get executed in this "init_game" function.

I call it after the GUI is turned off and the GUI is non-modal anyways...

Must be something else...

Gilbert

Quote from: mamarulez on Thu 03/03/2005 19:07:06
I call it after the GUI is turned off and the GUI is non-modal anyways...
The question is, did you call init_game() in game_start()? If you did, like what I mentioned, it shouldn't work, you should put the call in the player enters room type of events of the first loaded room.

DoorKnobHandle

My init_game ( ) function gets called in the middle of the game ( to be exact, it gets called when a gui interaction is called...)

strazer

Hm, you're working with RawSaveScreen/RawRestoreScreen in your strategy game, right?
Maybe the frame is set but overwritten with the previously saved raw copy of the old frame?

If that's not it, without the game in front of me I'm out of ideas.

DoorKnobHandle

Woohoo, that was it. Thank you very much to everybody who helped me with this!

Actually I thought of that before myself, so I put a second RawSaveScreen ( ) after the SetBackgroundFrame ( ) command, but it didn't do anything.
Now I got rid of that second sucker and it works...

Gilbert

RawSaveScreen(), RawRestoreScreen(), etc. currently operates on the displayed background frame only.
So for example you saved the screen of frame 1 then change to frame 2 and restore frame 2 would be overwritten by the content of frame 1 (until you leave and re-enter the room again, raw changes are reset when you leave the room), so you need to be careful with it if you use multiple frames.

SMF spam blocked by CleanTalk