2024-11-14 19:55:13 +02:00
|
|
|
#+title: Section 03 - Lesson 09, 10 | Export annotation, Moving the Paddle
|
2024-11-29 06:41:22 +02:00
|
|
|
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../../_share/media/css/godot.css" />
|
2024-11-14 19:55:13 +02:00
|
|
|
|
|
|
|
|
* Links
|
|
|
|
|
- [[../../toc.org][TOC - Godot Notes]]
|
|
|
|
|
- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45070473?start=15#announcements][S03:L18.09 - Export annotation]]
|
|
|
|
|
- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45070475#announcements][S03:L20:10 - Moving the Paddle]]
|
|
|
|
|
|
|
|
|
|
* Notes
|
|
|
|
|
|
|
|
|
|
** Export Annotation
|
|
|
|
|
|
|
|
|
|
annotation allows you to add property to the inspector on a node
|
|
|
|
|
|
|
|
|
|
*** format
|
|
|
|
|
#+BEGIN_SRC godot
|
|
|
|
|
@export var VARIABLE_NAME: TYPE = VALUE
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
this allows you to reference the property directly within the script attached to the node
|
|
|
|
|
|
|
|
|
|
** Setting up an Input System
|
|
|
|
|
*** add inputs
|
|
|
|
|
- Menu->Project->Project Settings-> [Input Map]
|
|
|
|
|
- click on "show built-in actions"
|
|
|
|
|
#+ATTR_HTML: :width 600px
|
|
|
|
|
[[file:../../../_share/media/albert/img/S03_L10_EX01.png]]
|
|
|
|
|
|
|
|
|
|
- create an action
|
|
|
|
|
- type in the name of the action in Add New Action
|
|
|
|
|
- click +Add
|
|
|
|
|
|
|
|
|
|
#+ATTR_HTML: :width 600px
|
|
|
|
|
[[file:../../../_share/media/albert/img/S03_L10_EX02.png]]
|
|
|
|
|
|
|
|
|
|
- assign a key
|
|
|
|
|
- select the action
|
|
|
|
|
- click the '+' button to the right
|
|
|
|
|
- type or select the appropriate key
|
|
|
|
|
|
|
|
|
|
#+ATTR_HTML: :width 300px
|
|
|
|
|
[[file:../../../_share/media/albert/img/S03_L10_EX03.png]]
|
|
|
|
|
|
|
|
|
|
*** detecting the input
|
|
|
|
|
- we use these:
|
|
|
|
|
- Input.is_action_just_pressed
|
|
|
|
|
- Input.is_action_just_released
|
|
|
|
|
- Input.is_action_pressed
|
|
|
|
|
|
|
|
|
|
- just_pressed detects only the initial press of the button. a lot of times you hit the button and the computer will detect it multiple times.
|
|
|
|
|
- so make sure you DO NOT use just_pressed, use action_pressed!
|
|
|
|
|
|
|
|
|
|
** get axis
|
|
|
|
|
instead of using if statements, you can use Input.get_axis
|
|
|
|
|
|
|
|
|
|
this takes two actions, and determines if they are both pressed at the same time, or if only 1 is pressed
|
|
|
|
|
|
|
|
|
|
Input.get_axis("left", "right") will return a value of -1, 0, 1
|