Here's a little bit of code:
function room_RepExec()
{
if (integerthatgoesupeverytenseconds >= 1 && cEgo.Moving == true && oWheetWhoot.Visible == false) {
oWheetWhoot.Visible = true;
oWheetWhoot.Y = 169; // cEgo walks on Y 199
oWheetWhoot.X = cEgo.x - 13; // Makes oWheetwhoot float over cEgo sprite
} else {
oWheetWhoot.Visible = false;
}
}
// oWheetWhoot is animated all the time (eRepeat)
I tried removing the checks for cEgo.Moving and oWheetWhoot visibility, and when cEgo remains in place, oWheetWhoot is shown correctly. BUT: when cEgo walks left or right, the object seems to flicker.
Any ideas on the cause? Ways this could be improved?
The object flickers when cEgo is walking -> cEgo.Moving == true
Thus, assuming that the integer that goes up is >= 1 most of the time, what's left is:
if (object is visible) make it invisible
else make it visible
In other words, all the code does is make the object flicker.
What should the WheetWoot exactly do and when?
I agree with Khris that script would make the object flicker, but is hard to propose a fix without knowing what and when it's supposed to do... :S
I tested this script in the following form:
function room_RepExec()
{
if (integerthatgoesupeverytenseconds >= 1) {
oWheetWhoot.Visible = true;
oWheetWhoot.Y = 169; // cEgo walks on Y 199
oWheetWhoot.X = cEgo.x - 13; // Makes oWheetwhoot float over cEgo sprite
} else {
oWheetWhoot.Visible = false;
}
}[code]
The flickering still takes place when cEgo is walking around. The only variable being checked receives a
[code]
integerthatgoesupeverytenseconds++;
every ten seconds or so.
Also, doesn't the cEgo.Moving return "true" when cEgo is walking? Or am I misunderstanding its purpose?
@Unai: oWheetwhoot is a small object that floats on the main character at roughly knee-level and loops a simple animation. It is supposeed to be visible only when cEgo moves, otherwise it is not visible. Think of an object being used as an overlay to simulate a character's feet kicking up dust as he/she walks.[/code][/code]
i'm confused.
shouldnt this be simply
if (player.Moving) oWheetWhoot.Visible = true;
else oWheetWhoot.Visible = false;
Quote from: Calin Elephantsittingonface on Thu 10/02/2011 08:11:12
i'm confused.
shouldnt this be simply
if (player.Moving) oWheetWhoot.Visible = true;
else oWheetWhoot.Visible = false;
In all intents and purposes, isn't that basically the same thing I'm trying to do, but written without the "{" and "}":s? How does that function differently than my:
if (cEgo.Moving == true) {
oWheetWhoot.Visible = true;
oWheetWhoot.Y = 169; // cEgo walks on Y 199
oWheetWhoot.X = cEgo.x - 13; // Makes oWheetwhoot float over cEgo sprite
} else {
oWheetWhoot.Visible = false;
}
It's those
oWheetWhoot.Y = 169; // cEgo walks on Y 199
oWheetWhoot.X = cEgo.x - 13; // Makes oWheetwhoot float over cEgo sprite
lines that I'm worrying about now. To me it feels like they are causing the flickering for some reason. I'll just have to get back to testing to see if I can get it to work once I get back home.
Quote from: WHAM on Thu 10/02/2011 08:33:31In all intents and purposes, isn't that basically the same thing I'm trying to do
No it's not.
As I explained, provided that we leave out the counter for now and the player is currently moving, what's left is
pseudo
if (object is invisible) make it visible
else make it invisible
Look:
if (integerthatgoesupeverytenseconds >= 1 && cEgo.Moving == true && oWheetWhoot.Visible == false)
That's the test you're doing, and it'll successfully turn on oWheetWhoot. But immediately afterwards, in the subsequent game loop, this condition is no longer true, since oWheetWhoot.Visible is no longer false.
Thus, due to your else, oWheetWhoot is turned invisible. Rinse, repeat.
If you're actually using the code in your last post, there shouldn't be any flickering.
And of course, changing the coordinates doesn't cause flickering "for some reason". We've told you what does it.
Aaaaah! Now I see! I was just being a dunce about this!
I misunderstood your first post and was, apparently, too blind to realize what you were trying to say.
I'll fix this as soon as I get back home, thanks again!
Ummm, couldn't you use a "WheetWhoot" character and FollowCharacter?
If the WheetWhoot has a walkin animation that shows it hovering when walking you should get that effect... Right?
It's all theory though, I never tried that...
As fas as I know and have used the followcharacter, that command tends to lag behind, so it would not work quite as intended.