Drawing an overlay behind an object?

Started by LeChuck, Thu 01/02/2007 21:47:18

Previous topic - Next topic

LeChuck

Alright, I've got two overlays in my room:
Code: ags
//script for Room: Player enters room (before fadein)
id1=CreateGraphicOverlay(0,250,984,0);
id2=CreateGraphicOverlay(150, 2, 1172, 1);


The first overlay, id1, is a bunch of plants that scrolls by near the bottom of the screen, giving the game a 3d look.

The second, id2, I want to be drawn BEHIND an object, in my case, a window frame.


Code: ags
// script for Room: Repeatedly execute
vpx=GetViewportX();Ã,  
MoveOverlay(id1,0-((vpx*width1)/swidth),100);
MoveOverlay(id2,50+((vpx*width1)/(swidth*20)),15);


This part moves the overlays around according to the movement of the player. Now, is there a way to put overlays behind objects and characters? I also tried to move around objects using nearly the same code, but failed miserably. The MoveObject command wants a speed variable which doesn't really go over well with the AGS engine, I guess.

Any tips?

PS: Yeah, I'm using the old scripting commands, I know, I know...

Ashen

#1
No, AFAIK there's no way to place overlays behind Characters, Objects, etc. To achieve this parallax effect you'd need to use Objects or Characters instead. (You might be able to use the parallax plugin, in fact. If it does background layers.)

In what way does the speed variable 'not go over well'? It's always worked OK for me. If you're using Objects here for parallax, perhaps SetObjectPosition would be a better option? (Also doesn't require walkable areas, unlike MoveObject).

I know what you're thinking ... Don't think that.

Scorpiorus

Yeah, and actually MoveOverlay is a bit confusing name, since it instantly repositions the overlay (should have been called SetOverlayPosition() or something like this, I think).

So do use SetObjectPosition() as Ashen pointed out. And just for information, that function internally calls MoveObject but with speed at -1, which is a special value to make it do instant moves :)

LeChuck

Quote from: Ashen on Thu 01/02/2007 22:09:24In what way does the speed variable 'not go over well'?

It doesn't move at all when being called in rep execute, but SetObjectPosition was exactly the command I was looking for, thanks! It looks and works great, I can't believe I missed that command! :)

Ashen

Possibly because it's being called in rep_ex, the object never actually gets a chance to start moving.
SetObjectPostion is the way to go in this case, but if you ever actually need to use MoveObject in rep_ex, you might want to add an IsObjectMoving check (Object.Moving in oo script) and see if that helps. (And, of course, UPDATE to new scripting ASAP  :P)
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk