Page 1 of 1

Mouse events in RTS games

PostPosted: Thu Jul 12, 2007 8:41 am
by Tytan McAnguns-PL
It is used such system in strategic games that when it will be pressed on actor and on field next, it moves in this direction .
I have it problem. Anybody knows as make when it will be clicked on actor goes it on field to this part next but?
But when it will not be clicked on actor, will not be moved it in this direction .

PostPosted: Thu Jul 12, 2007 9:37 am
by metal_pt
Try this (4 clones only):

Create a global integer variable named for instance "selected".
The default value should be -1.

On the player actor use this:
on mouse click left
Code: Select all
selected=cloneindex;


Create a "filled region" actor that extends for all the world. (z depth lower than player actors and higher than everything else)
on mouse click left

Code: Select all
char plname[255];
if(selected>-1)
{
    sprintf(plname,"playeractorname.%d",selected);
    MoveTo(getclone(plname), view.x+xmouse,view.y+ymouse, 2.000000, "Game Center", "");
}


Don't forget to restore the "selected" variable to -1.

Hope it works!

PostPosted: Thu Jul 12, 2007 11:29 am
by Tytan McAnguns-PL
Warning line :
Image

PostPosted: Thu Jul 12, 2007 12:19 pm
by metal_pt
oops...
try it this way

Code: Select all
MoveTo(plname, view.x+xmouse,view.y+ymouse, 2.000000, "Game Center", "");