Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: suicidal pencil on Thu 04/03/2010 06:12:17

Title: Object display order? (SOLVED)
Post by: suicidal pencil on Thu 04/03/2010 06:12:17
This problem kept popping up, but I could ignore it until I did the background with an object. Basically, it seems that object[a], when it is clipping of object[c], and when object[a] has a higher y value than object[c], with object[a]'s y value being higher by approx. 2/3 to 1/2 of object[a]'s y value, object[a] will clip behind object[c], no matter what object numbers they are.

It's also constant for all objects.

Here's a few examples:

(http://i182.photobucket.com/albums/x313/suicidal_pencil/ObjectFuckup.png)

This object is serving as an animated background with 78 frames. No matter what speed I put it to, it cuts the animation, and displays the first frame and doesn't change. Look where the red arrow is pointing to see it better :P

(http://i182.photobucket.com/albums/x313/suicidal_pencil/objectfuckup2.jpg)

Here's one shot of one object above another.

(http://i182.photobucket.com/albums/x313/suicidal_pencil/ObjectFuckup3.jpg)

Now here it switched up

I've looked everywhere in the help and forums, and there doesn't seem to be anything regarding this.
Title: Re: Object display order?
Post by: SSH on Thu 04/03/2010 06:33:02
Objects are always drawn in their Y order, unless you deliberately change the baseline to a different value. Or you can use the "z" parameter for height: it draws the object at y+z but the baseline remains at y.

If you have something that will ALWAYS be on top, you can use a GUI for it instead.
Title: Re: Object display order?
Post by: suicidal pencil on Thu 04/03/2010 08:33:00
Quote from: SSH on Thu 04/03/2010 06:33:02
...change the baseline to a different value....

Tried that already, it didn't solve it..

...objects do not have a z parameter, or if it is, it's not listed.
Title: Re: Object display order?
Post by: Gilbert on Thu 04/03/2010 10:39:10
If you put the baseline of the plane sprite low (i.e. higher in value) enough it will be drawn in front of the coin(?).

About the animating "background" object, where do you put the code for animating it? You may have put in in say, repeatedly_execute[_always](), so that the animation is reset every frame and have only the first frame displayed. Instead, start the animation in the "enter room" event and set it to loop endlessly.
Title: Re: Object display order?
Post by: suicidal pencil on Thu 04/03/2010 17:06:49
Quote from: Gilbet V7000a on Thu 04/03/2010 10:39:10

About the animating "background" object, where do you put the code for animating it?

The code is in the room_Load() function, and is set to loop without blocking

And, no matter where the baseline is put, it's always the same thing, no change in behavior
Title: Re: Object display order?
Post by: Matti on Fri 05/03/2010 12:41:58
Have you set BaselineOverridden to true? Then you can set the baselines of the objects who will always be in the back to 1, the objects in front of it to 2 etc. That should definitely work.
Title: Re: Object display order?
Post by: suicidal pencil on Sat 06/03/2010 20:38:15
I've scrapped the animating object as a background. It was really eating at the FPS.

QuoteHave you set BaselineOverridden to true?

I've looked everywhere for that, and can not find it. v3.1.2 SP1, by the way
Title: Re: Object display order?
Post by: Pumaman on Sun 07/03/2010 18:48:03
I'm not really clear exactly what each object is set to and what the problem is.

Objects are drawn from top to bottom in Baseline order; if an object has no explicit baseline defined, its Y co-ordinate is used instead.

BaselineOverriden is a property in the editor that sets whether you are overriding an object's Y co-ordinate with an explicit baseline. At runtime this is represented by the object's Baseline property being 0.
Title: Re: Object display order?
Post by: suicidal pencil on Sun 07/03/2010 20:26:10
The baselines for the objects are never set. The problem comes when the player controlled object (the black MiG-28) is "flying" over the other objects. All objects are supposed to be drawn underneath the player object, but when an object passes a certain point relative to the player object (it looks like when the bottom edge of the non-player object passes the bottom edge of the player object), the non player object will be displayed on top of the player object.

It does not hurt game play in any way, but it looks very sloppy and breaks the immersion.
Title: Re: Object display order?
Post by: aedwards00 on Sun 07/03/2010 20:41:37
Select the player controlled object, then in the properties window in the bottom right of AGS set "baseline overridden" to true. Then in the baseline box choose a baseline which is for example the bottom pixel of the game window (599 in an 800x600 game as an example). This should ensure that the player controlled object is drawn over the top of any other object in the game window. That is, if i understand the problem correctly.
Title: Re: Object display order?
Post by: Dualnames on Sun 07/03/2010 21:28:50
Objects can be placed in Z order by using their baseline property. The bigger the baseline is, the object will appear in front of everything.
Title: Re: Object display order?
Post by: suicidal pencil on Sun 07/03/2010 21:36:02
ahh, so that's why I couldn't find it; it's in the properties window (which I never use...). I thought it was accessed through the script  ::). Works like it's supposed to know, thanks.

now to figure out how to make that background animate without loss of FPS...reduced to 14 frames, but almost every pixel not covered by an object is being updated

edit: I fixed the background animation being clipped. The animating background is actually a 800x600 object being animated, but the room background is the same image as the first frame in the animation, and the object Y was off