Game Development Reference
In-Depth Information
We need to hijack the RotateLeft and RotateRight inputs when
leanFree is set to true . The character shouldn't turn then, but it should lean
instead. This is easily done with an if statement. We apply the lean value in-
stantly in this case. The code we added previously in the update method will
take care of returning the leaning to zero when the button is released:
if(leanFree){
if (name.equals("RotateLeft")) {
leanValue += value * tpf;
} else if (name.equals("RotateRight")) {
leanValue -= value * tpf;
}
lean(leanValue);
}
10. We already have InputAppState , which handles our input, so let's add a few
more buttons to it. Three more values to our InputMapping enum are
LeanLeft , LeanRight , and LeanFree .
11. Then, we assign those to Q and E keys to lean left and right, and V for free, or
analog leaning.
Search WWH ::




Custom Search