RTS game development

Hi,
How can I scroll through the scene by mouse scrolling at the border of the screen?
How can I save my last klicked object to move it by right click?

Thanks :slight_smile:

You could check if the mouse position is near one of the borders (0 ↔ screen width/height) plus lets say 10 pixels extra.
Or you add some sprites to the borders of the screen on your gui layer and check if the mouse collides with them. If so move the camera in that direction.

I asked something similar some time ago. There is an example file attached at the end of the thread:
http://compilgames.net/forum/viewtopic.php?p=53027#p53027

You could either give your units a property “selected” that is set to true when the unit is klicked with the mouse and filter by that in your condition or use the “linked objects extension” (I would recommend the latter) to “bind” them to some invisible “master” object that acts as a temporary storage for selected units.
You can then cycle through all selected units in a loop and move them with the path finding behaviour. (there is an example project included with GD for path finding)

Thanks, I will try it out :slight_smile:

How does that with the variable work?
I change the variable of a object after releasing the left mouse button while hovering over it.
Then I check if variables are changed to 1 for a group of objects.
But how can I make now an action for these special objects I have checked?

Here is an example:
RTS.zip (38 KB)

Thank you that helped me a lot :slight_smile:
Do you know how I can determine which sprite is in front of an other sprite in the same layer?

You could assign different z-values for the sprites.

:slight_smile: And how to set the Z order for in-game created sprites?

“Z order” action in All objects > Z order