Hi,
I'm stumped here. The animation plays 3 times and then stops.Since the x-coordinate for the dog is set back it's supposed to play one time only.
function room_RepExec()
{
if (cDog.x<=195) {
player.Walk(100, 262, eBlock, eAnywhere);
player.FaceLocation(player.x+1, player.y);
player.x+=10;
cDog.Transparency=100;
cDog.x = 288;
cDog.y = 280;
player.Animate(36, 3, eOnce, eBlock);
}
}
Any ideas?
thanks
When you want to animate a character, it's best to use a separate view and call player.LockView(PLAYER_ANIMATIONS); first, otherwise you may get unexpected results.
(PLAYER_ANIMATIONS is an example name for the view here)
Ai, this is a big game and I'm just helping out. Many animations have been placed in the normal view (it has 43 loops) and they all play out well. It's just this one (so far) that behaves weird. Placing them elsewhere will have quite some impact.
https://en.wikipedia.org/wiki/Technical_debt ;)
Just kidding, but I'd definitely try copying the animation to a new view and testing it. If the issue doesn't go away, the problem is indeed elsewhere.
If I do this
function room_RepExec()
{
if (cDog.x<=195) {
player.Walk(100, 262, eBlock, eAnywhere);
player.FaceLocation(player.x+1, player.y);
player.x+=10;
cDog.Transparency=100;
cDog.x = 288;
cDog.y = 280;
player.LockView(DOG_ATTACK);
player.Animate(0, 3, eOnce, eBlock);
player.UnlockView();
}
}
I see the animation unlocking and restarting three times.
If I do this:
function room_RepExec()
{
if (cDog.x<=195) {
player.Walk(100, 262, eBlock, eAnywhere);
player.FaceLocation(player.x+1, player.y);
player.x+=10;
cDog.Transparency=100;
cDog.x = 288;
cDog.y = 280;
player.LockView(DOG_ATTACK);
player.Animate(0, 3, eOnce, eBlock);
player.UnlockView();
ShowDeathGui(eDeathDogAttack);
}
}
The death gui coms up after one animation. But when I click it away it gives an error at player.Walk(100, 262, eBlock, eAnywhere); because there's no loop one.
Apparently it is still in the dog_attack view, and the condition if (cDog.x<=195) appears ither not checked or still true.
edit: oops, I made a typing error in unlockview. Now that error doesn't happen, but the game locks up when the gui is displayed, I'm assuming because it wants to play the animation 2 more times.
Can you display dog coordinates before "if"?
The whole thing is rather strange.
Quote
player.FaceLocation(player.x+1, player.y);
By the way, there's Character.FaceDirection function which can be used to face explicit direction.
In room_Load() there's
cDog.ChangeRoom(49, 288, 280);
And in room_AfterFadeIn() there's
if (dog_bone==false) {
EnableRegions();
RemoveWalkableArea(5);
Display("Watch out! A VERY unfriendly dog rushes toward you!");
mouse.SetPosition(300, 15);
cDog.Walk(120, 275, eNoBlock, eAnywhere);
}
So the death GUI blocks the game until you close it, correct?
Is it possible that closing the GUI reloads the room? And thereby resets the dog's position?
What I'd do at this point is put a debug label on a permanently visible GUI and update its text with the dog's position in repeatedly_execute_always(), then set the game speed to 5 or so.
Try to determine why the coordinate check doesn't prevent a second animation. Also, why does it happen exactly three times? Really weird.
Sounds more and more like some global code is interfering.
No, the death gui blocks the game permanently. Clicking it should make it close, but that doesn't happen in this situation.
I'll try the debug label later.
Can you try and change cDog.Transparency=100; to some other value? Or just // it.
Well, I still don't understand how this plays out exactly, but indeed disabling the transparency and lowering the gamespeed shows that the dog was not sent back to x=288.
What appears to be the problem is the statement in room_AfterFadeIn(): cDog.Walk(120, 275, eNoBlock, eAnywhere);
In repexec the dog should be sent back when it's at x=195, but it looks like the instruction to walk to x=120 takes precedence. Is that possible?
It seems to be fixed if I set the statement in afterfadein to cDog.Walk(192, 275, eNoBlock, eAnywhere);
So it looks like my problem is solved, but if anyone understands what was really happening here I'd love to know. ;)
Thanks
Looks like manually changing the dog's x position doesn't interfere with the non-blocking walk, AGS just keeps on trucking.
You can also call cDog.StopWalking() instead.