Game 2048 godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By uraken

Hi , I’m having problems with game 2048. I want to save direction when I swipe(up/down/left/right). So how can I do?

:bust_in_silhouette: Reply From: yanb

To save a direction in a variable, you can:

  • create a variable and store a number in it, define some constants like const UP = 0, const RIGHT = 1 e.t.c. and save them in the variable to set the direction;

or

  • create a variable, use in a enum; for example, define a Directions enum and save Directions.UP in your variable for the directions;

or

  • use Vector2 direction vector (like Vector2(1, 0) means up) and store it in a variable.

Additional information: how to define enums