Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:tutorials:input:8way_joystick_control [2020/08/20 04:54 (5 years ago)] – ↷ Page moved from en:tutorials:8way_joystick_control to en:tutorials:input:8way_joystick_control sausage | en:tutorials:input:8way_joystick_control [2020/08/31 05:37 (5 years ago)] (current) – ↷ Links adapted because of a move operation sausage |
---|
{{section>en:orx:config:settings_main:input_joystick#[joystick_half-axes]&noheader&nofooter&noeditbutton}} | {{section>en:orx:config:settings_main:input_joystick#[joystick_half-axes]&noheader&nofooter&noeditbutton}} |
| |
When pushing the stick in a direction, after getting past the [[en:tutorials:analog_stick_threshold|threshold]], the push will be "ON". Before the threshold, it will be off, emulating a digital joystick or gamepad direction inputs (d-pad). | When pushing the stick in a direction, after getting past the [[en:tutorials:input:analog_stick_threshold|threshold]], the push will be "ON". Before the threshold, it will be off, emulating a digital joystick or gamepad direction inputs (d-pad). |
| |
Let's work through setting this up. Firstly, ''init'' up a new project using [[en:tutorials:creating_your_own_project|these instructions]]. | Let's work through setting this up. Firstly, ''init'' up a new project using [[en:tutorials:projects:creating_your_own_project|these instructions]]. |
| |
Once you have a working project, add in the following graphic into your project's data to act as the object that will be controlled by the joystick: | Once you have a working project, add in the following graphic into your project's data to act as the object that will be controlled by the joystick: |
</code> | </code> |
| |
The ''+JOY_LX_1'' above means, if the left analog stick is pushed along the X axis, in the positive direction, and after it has crossed the [[en:tutorials:analog_stick_threshold|threshold]], which is half the entire distance the stick can move (0.5), register a ''GoRight'' button press. | The ''+JOY_LX_1'' above means, if the left analog stick is pushed along the X axis, in the positive direction, and after it has crossed the [[en:tutorials:input:analog_stick_threshold|threshold]], which is half the entire distance the stick can move (0.5), register a ''GoRight'' button press. |
| |
In the same way, the ''-JOY_LY_1'' means the if the Y axis has been pulled down with the left stick, and has passed the halfway (0.5) threshold, register a ''GoDown'' press. | In the same way, the ''-JOY_LY_1'' means the if the Y axis has been pulled down with the left stick, and has passed the halfway (0.5) threshold, register a ''GoDown'' press. |
| |
Visit [[en:tutorials:analog_stick_threshold|Analog Stick Threshold]] for more details on thresholds. | Visit [[en:tutorials:input:analog_stick_threshold|Analog Stick Threshold]] for more details on thresholds. |
| |
Finally in the ''Run()'' function, we can add the code to respond to these "presses". ''Run()'' is not normally the recommended place to put this code, but for demonstration purposes, it is fine: | Finally in the ''Run()'' function, we can add the code to respond to these "presses". ''Run()'' is not normally the recommended place to put this code, but for demonstration purposes, it is fine: |