Is there a way to just have an object frozen in the background (for example a distant mountain)? Basically, I want the object to never move in the player's screen, even when the rest of the room scrolls left and right. I saw the parallax module but I was wondering if there was some simpler way to keep an object frozen in place.
Thanks
Easy:
function repeatedly_execute_always()
{
oObj.X = GetViewportX();
oObj.Y = GetViewportY();
}
Thanks!
One thing though: it seems when the view scrolls, the unmoving object is always one frame behind everything else? So when the player starts / stops, the background lags a little bit, then jerks into place. Is there a way to smooth the transition out so you don't get the jerking? Right now I have "repeatedly_execute_always" in the room's script.
If I recall correctly, that jerkiness is inevitable unless you use DX9.
Quote from: SilverSpook on Wed 29/04/2015 22:28:19
One thing though: it seems when the view scrolls, the unmoving object is always one frame behind everything else?
I'm not expert enough to tell the reason for sure, but I know that what you say is
plausible, because when you update obj.X (resp. Y) you do it during your game cycle, whereas Viewport's X (resp. Y) was given to you from the previous game cycle.
I can't think of a solution from the top of my head, so I'll just say that you should use the
SmoothScrolling module, which also allows parallax.
BOOM: just when I mention smoothscrolling, Ali pops in.
EDIT: if the jerkiness is inevitable, then another workaround would be not to do a perfectly still background, but instead a background that has a very slight scrolling/parallax effect. This way, nobody will notice.
Which version of AGS are you using?
I made this experimental engine version for Snarky, it's based on AGS 3.3.3 and supports "late_repeatedly_execute_always()" function that is run after new game state is calculated.
http://www.mediafire.com/download/jd86vdw6jxr6n5y/acwin_3.3.3--laterepexec.zip
Quote from: Crimson Wizard on Thu 30/04/2015 09:21:37
late_repeatedly_execute_always()
Oh boy oh boy oh boy. I didn't know the existence of this. I'm excited.
I'm using AGS 3.4 unfortunately. I need the free aspect ratio feature cause I'm working in 1366 x 768
Thanks for the support though!
If you script the room scrolling yourself instead of relying on the built-in one, it will all happen in user-script and should sync up correctly.
Hm, how would you disable the scrolling so to script it yourself?
The function is called setviewport or lockviewport or something like that. Search the manual for "viewport" and you should find it.