object ahead or behind!

Started by Flyman, Wed 25/01/2012 18:29:14

Previous topic - Next topic

Flyman

mmmm how set an object visible on other object!
Ahead or behind how to set? Please help

Khris

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:

Code: ags
  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.

Flyman

#2
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!!

Ali

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.)

Khris

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:
Code: ags
  object[2].Baseline = object[1].Y + 1;


You can also set the baseline in the editor.

Flyman

Thanks all!!
Very nice Khris!

SMF spam blocked by CleanTalk