June 2018
Beginner to intermediate
298 pages
7h 38m
English
The player needs three controls—left, right, and jump. The combination of the current state plus which keys are pressed will trigger a state change if the transition is allowed by the state rules. Add the get_input() function to process the inputs and determine the result:
extends KinematicBody2Dexport (int) var run_speedexport (int) var jump_speedexport (int) var gravityenum {IDLE, RUN, JUMP, HURT, DEAD}var statevar animvar new_animvar velocity = Vector2()func get_input(): if state == HURT: return # don't allow movement during hurt state var right = Input.is_action_pressed('right') var left = Input.is_action_pressed('left') var jump = Input.is_action_just_pressed('jump') # movement occurs in all states velocity.x = 0 if ...Read now
Unlock full access