Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Flyman on Wed 25/01/2012 18:29:14

Title: object ahead or behind!
Post by: Flyman on Wed 25/01/2012 18:29:14
mmmm how set an object visible on other object!
Ahead or behind how to set? Please help
Title: Re: object ahead or behind!
Post by: Khris on Wed 25/01/2012 19:02:13
Which object is drawn on top is determined by the object's baseline.
By default, the value is 0 which means AGS uses the object's y coordinate/bottom edge.
You can override this by setting the baseline to something else:

  oForeground.Baseline = 239;  // draw foreground on top of everything else

An object with a lower baseline value appears behind objects with a higher baseline value because it is further up the screen and thus farther away.
Title: Re: object ahead or behind!
Post by: Flyman on Wed 25/01/2012 19:31:38
Work fine! Thanks, but there is another problem!!
I've used Baseline on the second object, " object[2].Baseline = 239;" and now, it appear ahead the first object, OK. But when my character is near the second object, he appear behind in walk mode, how resolve!!
Title: Re: object ahead or behind!
Post by: Ali on Wed 25/01/2012 20:29:16
Characters also have a baseline property. If the character's y coordinate is less than 239, AGS will draw him behind the object.

So you could choose a baseline value for Object 2 which is greater than the baseline value of Object 1, but lower than the y position the player will have when he walks in front of it.

Or, you could leave Object 2's baseline at 0, and give Object 1 a baseline higher up the screen (say 10 or 20).

Hope that makes sense!

(By the way, I think questions like this should probably go in the Beginners Technical Questions forum.)
Title: Re: object ahead or behind!
Post by: Khris on Wed 25/01/2012 20:30:21
Like I said in the comment, setting an object's baseline to 239 will move it on top of everything with a baseline below 239.

If I understand you correctly, you want object[2] appear on top of object[1] but at the same depth in relation to other objects and characters.

Try this:
  object[2].Baseline = object[1].Y + 1;

You can also set the baseline in the editor.
Title: Re: object ahead or behind!
Post by: Flyman on Wed 25/01/2012 20:39:26
Thanks all!!
Very nice Khris!