EDIT 3:
Just in case somebody comes here looking for a solution, here's the code I'm using now which seem to work nicely:
#define Cloud01MoveSpeed 2.0
#define Cloud01FadeSpeed (Cloud01MoveSpeed/2.0)
#define CloudStartPosition (Random(40)+70), (Random(40) +90)
#define CloudEndPosition Random(20) + 190
void MoveFrontCloud01()
{
oCloud01.StopAllTweens();
oCloud01.Transparency=100;
oCloud01.SetPosition(CloudStartPosition);
oCloud01.TweenX(Cloud01MoveSpeed, CloudEndPosition, eEaseLinearTween, eNoBlockTween);
oCloud01.TweenTransparency(Cloud01FadeSpeed, 0, eEaseInOutSineTween, eReverseRepeatTween);
}
function room_Load()
{
MoveFrontCloud01();
}
function room_RepExec()
{
if ((oCloud01.Transparency==100)&&(oCloud01.X>189)){
MoveFrontCloud01();
}
}
EDIT 2:
Well ok, it kinda works but it's a bit glitchy. If anybody has an idea how to solve this in a better way I'd really appreciate it.
EDIT:
Sorry, I think I just figured it out. I moved the transparency tween into the room_Load() function instead and that seems to do the trick.
Hey guys,
so I've got those clouds that move along X, and at the same time tween from 100 transparency to 0 and then back to 100, before being reset and doing it all over again.
I've basically got it working but for some reason it only works -exactly- 3 times and then the transparency tween seems to go crazy, flickering seemingly randomly.(?)
Does anybody have an idea what's going on?
Here's my code:
void MoveFrontCloud()
{
oCloud01.SetPosition((Random(20)+100), (Random(20) +80));
oCloud01.Transparency=100;
oCloud01.TweenTransparency(1.5, 0, eEaseInOutSineTween, eReverseRepeatTween);
oCloud01.TweenX(3.0, (Random(20) + 190), eEaseLinearTween, eNoBlockTween);
}
function room_Load()
{
MoveFrontCloud();
}
function room_RepExec()
{
if ((oCloud01.X>=190)&&(oCloud01.Transparency==100)){
MoveFrontCloud();
}
}
cheers!
I'm not entirely sure what's going on but room_RepExec() is called 40 times per second.
MoveFrontCloud() does not strike me as a function that's supposed to be called that often? Because that's what happens as soon as the cloud reaches X coordinate 190.
Quote from: Khris on Tue 31/07/2018 11:16:32
I'm not entirely sure what's going on but room_RepExec() is called 40 times per second.
MoveFrontCloud() does not strike me as a function that's supposed to be called that often? Because that's what happens as soon as the cloud reaches X coordinate 190.
But it's inside an "if (x >= 190)" and the MoveFrontCloud function sets x to be between 100-120, so MoveFrontCloud doesn't get called 40 times per second.
One problem that I can see here is that you tween x to 190-210 but you set x to 100-120 when you've reached 190 without stopping the previous tween. So if you tween to 210 and then reach to 190, x can move like this, for example: 190, 100, 191, 101, etc...
Try adding "oCloud1.StopTweenPosition()" at the beginning of the MoveFrontCloud function to see if it makes any difference.
Quote from: tzachs on Tue 31/07/2018 13:37:07
One problem that I can see here is that you tween x to 190-210 but you set x to 100-120 when you've reached 190 without stopping the previous tween. So if you tween to 210 and then reach to 190, x can move like this, for example: 190, 100, 191, 101, etc...
Try adding "oCloud1.StopTweenPosition()" at the beginning of the MoveFrontCloud function to see if it makes any difference.
Thanks tzachs,
seems that's exactly what the problem was...in fact I put a StopAllTweens() at the beginning and it seems to be running perfectly now.
Fingers crossed:)