how to set different walk behind areas for one rooms different backgrounds?

Started by marbar, Sat 12/12/2009 03:22:38

Previous topic - Next topic

marbar

Hello!

I've just started to work with ags and have a problem! i've read through the tutorials and couldn't find help regarding this problem so i hope someone here can help me. i've used multiple backgrounds in one room to get some animations there. now i'd have to set specific walk behind areas for each background because of these animations because my main character  hast to walk behind an animated object, and when i just set a general walk behind area, he only partially walks behind it, 'cause it moves up and down....

is there a possibility to solve this problem?

thx,
marina

Ryan Timothy B

From what you just said here:
Quotenow i'd have to set specific walk behind areas for each background because of these animations because my main character  hast to walk behind an animated object

Makes it sound like you're using animated backgrounds to animate only a small object.  Is that correct?
If the only thing in the room that needs to animate is this object, or a few objects (and not room lighting that glows and whatnot), you're better off using a room object and animating that instead.  Which is the route I take to animate anything.

The only time I would use an animating background would be if nearly the entire background is changing.  Either lighting effects, like a night scene and a day scene, or a fire in the middle of the room that casts ambient light all over the background, or a flickering light.  etc
Otherwise, I use a room object.

Also, with a room object the walkbehind is set by the base of the object (the bottom of the sprite).

marbar

Thx, I'll try that instead. I have five objects, that are animated. I just thought game speed would suffer. but it's probably far easier for a beginner :).

Bye!

Ryan Timothy B

I wouldn't worry about having a few objects animate.  I imagine 5 frames of the background animating is just about as processor heavy--which wouldn't be much either way unless it's a large background.

Anyway, if you ever did want to animate the background and have certain walkbehinds change, this is what you'd do (untested):

In the Room repeatedly_execute_always
Code: ags
if (GetBackgroundFrame()==0)
{
  SetWalkBehindBase (3,0); //disables walkbehind 3
  SetWalkBehindBase (1,100); //enables walkbehind 1
}
else if (GetBackgroundFrame()==1)
{
  SetWalkBehindBase (1,0); //disables walkbehind 1
  SetWalkBehindBase (2,100); //enables walkbehind 2
}
else if (GetBackgroundFrame()==2)
{
  SetWalkBehindBase (2,0); //disables walkbehind 2
  SetWalkBehindBase (3,100); //enables walkbehind 3
}


This is of course assuming you have 3 background frames (0,1,2).  And assuming you're animating the background in this order. 0, to 1, to 2, back to 0.
It also only changes one walkbehind, you'd have to add the other walkbehinds for each background area.

Which could become a pain in the arse rather quickly. :P

marbar

Okay, i've tried that animation command. maybe i'm too silly (because there apparently isn't so much to write..) but it just doesn't work. when i start the game there are no error messages linked to the script, but my object still doesn't move. here is what i wrote:

function room1 () {
oLupa.SetView (VLUPA, 0);
oLupa.Animate(0, eRepeat,  eNoBlock);
}

i've placed the command above all other commands in the room script file.
i've really looked x-times if i defined the variable names properly, the loop numbers etc. but it still doesn't work and doesn't work an doesn't work. i hate this, and it's only the first command i've written manually in this script language. aaargh. if this will continue that way i'll never finish even my first room. :-(

perhaps you have some hints?

Ryan Timothy B

As long as your views are correct the only thing I can see preventing the animate command from working would be because it's not being called.

You should open the room with the room editor.  Click on the Events icon (the lightning bolt) which is on the editing pane on the bottom of the side bar.  Click on the Enters Room Before Fade-in and click the [...] button that is to the right of it.

It will add this to your script:

Code: ags

function room_Load()
{

}


This is where you should place your code if the objects are supposed to animate when the game starts.

Code: ags

function room_Load()
{
  oLupa.SetView (VLUPA, 0);
  oLupa.Animate(0, eRepeat,  eNoBlock);
}


Also, doing this programming stuff will get super easy once you've done it once or twice.  Especially if you have your previous scripts to fall back to if you can't remember how you did it before.

marbar

// room script file

function room_Load() {
 
oLupa.SetView (VSTART, 0);
oLupa.Animate (0, eNoBlock);

Okay, I didn't this the first time, so I added the command as you said. Unfortunately, now the game doesn't run at all any more.
I get this error message:

"A text script run in the Player Enters Screen event caused the screen to be updated. If you need to use Wait(), do so in After FadeIn."

And this is the cause of this tragedy (my script so long...):


function room_Load() {
 
oLupa.SetView (VSTART, 0);
oLupa.Animate (0, eNoBlock);

}

Also, I had to remove the RepeatStyle (eRepeat) because I got an error saying it wasn't a valid integer. And once more: AAARGH! :/

What did I wrong?



marbar

Ok, I Think I did it, I know what went wrong. Thx for your help....I'll try it with the other animations and post a message if anything went wrong again! Thx so far, very much!

Marina

SMF spam blocked by CleanTalk