Select and Deselect Actors
Hello, I am currently making a real time strategy game like age of empires/the settlers/age of mythology.
Now I have a worker on my screen. When I tap on the worker it 'activates' and I can tap anywhere on the Screen to move him to. Now on my interface I have a button called 'Deselect'. If this button is hit I would like to deselect my worker so he cant move anymore.
I created an Attribute called 'Select'. It's a boolean
In my Actor Deselect I put the Rule
If Touch is activated, change attribute Select to Select +2
In my Worker I put Rule
If Attribute Select equals 2 then destroy this actor, and spawn actor Worker on the exact same position.
(This way the worker will respawn and will need to be selected again to move)
The value +2 is because when u tap on the worker the value goes to +1 and u will need value 1 to select the worker.
But it doesnt work, I can select the worker then move it to anywhere I want, but as soon as I hit the deselect button The actor just stays wherever it was and destroys itself after about 10 sec and never respawns.
Is there any other solution to deselect / select an actor?
Comments
@Titch, I'm not sure how your behaviors are set up exactly, but there is an option to check for 'when touch is outside' an actor so maybe you could use that and when touch IS outside the actor, do your deselect stuff.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Thats a very good idea thank you!! I'll try it later.
I had a similar challenge when making my drawing template. I needed to be able to select and deselect shapes, then allow the user to move/rotate/resize the selected shapes (one or many), and deselect them all at once, or individually. It turned out to be a lot less simple than I expected. If I don't forget, I'll refresh my memory on how I did it when I'm home and follow this up.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Here you go. Assuming I've understood what you want, this is a fairly easy way to select and deselect actors, and have them move to touch location - but not move if the touch was on an actor.
This is also a good example of a situation in GameSalad where order of operations really does matter.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Neat!