Hello, I am creating an arrow shooting game and I want let the player to adjust the angle and power of shooting by pressing spacebar.
The workflow is:
- Adjust the angle of shooting by upward and downward key
- Press Spacebar, the angle will be locked and now the upward and downward key are used to adjust the power
- Press Spacebar again and the arrow will be shot
My idea is, create a variable called “stage”, everytime the spacebar is pressed, stage += 1 and the behavior of upward and downward key depend on the variable stage.
I have tried to put something like if (spacebar_key.isDown) {stage += 1;} in update(), but it didn’t work. (It seems that the stage variable goes beyond 1 when I pressed spacebar).
I have also tried put this kind of checking on “stage” in create(), but didn’t work too. (This time it seems that “stage” doesn’t change, or, the game just checked it once only, so it is not going to the next stage)
Could anyone give me some hint/reference? Thanks.