Hi, I'm trying to make my character run with double click.
- AGS Editor .NET (Build 3.5.1.11)
- Bass Template
- Module: DoubleClick_1.0.0
I use this command line, but does not work correctly.
Any suggestions as to what I am doing wrong? Thanks.
In Global Script:
function on_mouse_click(MouseButton button)
{
if (DoubleClick.Event[eMouseLeft]) {
// double-click code
player.SetWalkSpeed(50, 50);
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
else
{
player.SetWalkSpeed(50, 50);
}
if (eMouseLeft) {
// single-click code
player.SetWalkSpeed(15, 15);
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
else
{
player.SetWalkSpeed(15, 15);
}
}
I've had similar problems with this and also using the "Bass Template", though I'm not using the Module: DoubleClick_1.0.0
My issue has been, (player can not change speed whilst moving.)
I wonder if that's linked to your issue.
The tumbleweed template, seems to handle this issue correctly, though I've only used it once.
Try this:
function on_mouse_click(MouseButton button) {
if (button != eMouseLeft) return;
ClaimEvent();
int speed = 15;
if (DoubleClick.Event[eMouseLeft]) speed = 50;
player.StopMoving();
player.SetWalkSpeed(speed, speed);
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
}
Thanks Khris, but it does not work "ClaimEvent:No event to claim"
Edited:
I've removed "ClaimEvent"
I've added another "player.StopMoving();"
Inside the room works correctly, but when changing the room the character doesn't stop, it continues walking.
I solved it by adding "player.StopMoving();" in "room_AfterFadeIn", it works, but I don't know if it's the right way to do it.
if (button != eMouseLeft) return;
int speed = 15;
player.StopMoving();
if (DoubleClick.Event[eMouseLeft]) speed = 50;
player.StopMoving();
player.SetWalkSpeed(speed, speed);
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
Where did you put this?
Anyway, you're using the BASS template so the following should work:
1. open the TwoClickHandler Script
2. find line 154, it says Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
3. directly above that line, insert this:
if (button != eMouseLeft) return;
int speed = 4;
if (DoubleClick.Event[eMouseLeft]) speed = 2;
player.StopMoving();
player.AnimationSpeed = speed;
Note that changing the animation speed (actually a delay, hence: lower value -> faster walking) is the proper way to speed up walking; this will prevent the player from gliding / moon-walking (provided that the movement speed properly corresponds to the walk cycle frames)
QuoteWhere did you put this?
In Global Script
The new code, works correctly.
Thank you very much, Khris.
Solved.