1
\$\begingroup\$

I am creating a typical strategic game that gamer can select, deploy and move the game characters (Human mostly) and move or create buildings on its isometric map.

These all are going to be done by gamers gestures obviously, So each time I am handling a tap, pan, swipe or pinch, it is important to know what was the gamer at the middle of or was doing so the new gesture can be handled.

Doing this, I created a global enumerated type including Idle,Select,PanMap and Place and defined a variable with name gameMode to control what the gamer is about to do. for example when the game starts it is valued "Idle" and when gamer touches a building or a character it will be selected only if the gameMode is Idle and if so gameMode will be changed to Select so the handlePan() method can manage the new gesture and sees if the user is moving the map or a selected building for instant.

When the gamer selects a building and does a pan afterward, the game logic should update the gameMode. When the first touch point of the pan gesture is recieved by handlePan() function, the function will check it against the selected building(currentSelection) to see if the gamer is tended to move the building or it is just a simple map panning, by changing the gameMode to "Place" or "PanMap" and check which gameMode is the case while processing the rest of the touches so they can be handled correctly.

As I have mentioned above, I have four game modes including idle, select, panmap(while something is selected), place (when gamer is moving something on the map)

Can anyone with strategic experience tell me is this kind of handling user interaction is the best way?

if yes do you think these modes are enough?

Can you tell me what was your modes in case you used this method?

I am using SpriteKit with xcode.

\$\endgroup\$
1
\$\begingroup\$

I can't tell you if this method is good, but I have a similar system in my game Blight of the Immortals.

It's even called gameMode.

Basicly a global state that I use to interpret what a gesture means and even what kinds of things should be rendered in the map.

I have a gameMode for when the player is plotting a movement path for units, one for when they are selecting a targets for powers, even one for when the editor is open and I am designing maps.

\$\endgroup\$
  • \$\begingroup\$ Thanks, So, there is not a better way than using a state variable. and evey interactive game use it, do I got you right? \$\endgroup\$ – Iman Oct 4 '15 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.