I solved my problem, thank you all for your suggestions.
I did as following and it works fine, and I'm sure code
can be semplified:
Code: ags
Sorry I forgot that my variable names are in italian,
so oCielo is for sky, oPianoIntermedio is for middle ground.
In this way the objects scrolls in different speeds while also camera moves.
I did as following and it works fine, and I'm sure code
can be semplified:
bool goRight = true;
bool goLeft = false;
function region1_WalksOnto()
{
if (goRight == true){
int i=0;
player.Walk(360, 260);
while ( i <40){
i++;
Game.Camera.SetAt(Game.Camera.X + 8, Game.Camera.Y); //Same speed as sky
oPianoIntermedio.X = oPianoIntermedio.X+4; //Half speed
//foreground auto scrolls
oCielo.X = oCielo.X+8;
Wait(2);
}
goRight = false;
goLeft = true;
}
else if (goLeft == true){
int i=0;
player.Walk(260, 260);
while ( i <40){
i++;
Game.Camera.SetAt(Game.Camera.X - 8, Game.Camera.Y);
oPianoIntermedio.X = oPianoIntermedio.X-4;
oCielo.X = oCielo.X-8;
Wait(2);
}
goRight = true;
goLeft = false;
}
}
Sorry I forgot that my variable names are in italian,
so oCielo is for sky, oPianoIntermedio is for middle ground.
In this way the objects scrolls in different speeds while also camera moves.