latest
This commit is contained in:
parent
7e2d616ec0
commit
73f35bf917
1 changed files with 77 additions and 0 deletions
|
|
@ -17,3 +17,80 @@
|
|||
2. set all node children process to false
|
||||
- Node function =get_children= will get them all3
|
||||
- iterate through them and =set_process(false)=
|
||||
|
||||
** sound
|
||||
*** import pane
|
||||
- the scene panel on the upper left has an Import pane
|
||||
#+ATTR_HTML: :width 600px
|
||||
file:../../../_share/media/albert/img/section03/S03_L16_E01.png
|
||||
|
||||
- this allows you to see details of items in the filesystem
|
||||
#+ATTR_HTML: :width 400px
|
||||
file:../../../_share/media/albert/img/section03/S03_L16_E03.png
|
||||
|
||||
*** changing details of imported items
|
||||
1. make whatever changes you want, e.g. turn on "Loop"
|
||||
2. then click the Reimport button
|
||||
|
||||
#+ATTR_HTML: :width 400px
|
||||
file:../../../_share/media/albert/img/section03/S03_L16_E04.png
|
||||
|
||||
*** audio nodes
|
||||
- Node->Node2D->AudioListener2D
|
||||
- overrides location sounds are heard from
|
||||
|
||||
- Node->Node2D->AudioStreamPlayer2D
|
||||
- plays positionnal sound in 2D space
|
||||
|
||||
- Node->AudioStreamPlayer
|
||||
- simple audio player
|
||||
- Playing: plays in the *GAME EDITOR*
|
||||
- Autoplay: plays as soon as it is loaded into the scene tree
|
||||
|
||||
*** create background music
|
||||
- add new Audio node to the scene panel on the Game scene
|
||||
- use AudioStreamPlayer bc we don't care about position
|
||||
|
||||
- drag the audio file into Audio node->Inspector->AudioStreamPLayer->Stream
|
||||
|
||||
#+ATTR_HTML: :width 600px
|
||||
file:../../../_share/media/albert/img/section03/S03_L16_E05.png
|
||||
|
||||
- you'll be able to see it when it's loaded
|
||||
#+ATTR_HTML: :width 600px
|
||||
file:../../../_share/media/albert/img/section03/S03_L16_E06.png
|
||||
|
||||
- set Autoplay to "ON"
|
||||
|
||||
*** add effects
|
||||
- use AudioStreamPlayer2D bc it has positioning
|
||||
- CMD+drag the AudioStreamPlayer2D node to the game.gd script so we can play it
|
||||
- call the effect when something happens (e.g. a gem hits the panel)
|
||||
- find the position of where the even happens "area.position"
|
||||
#+BEGIN_SRC gdscript
|
||||
audio_stream_player_2d.position = area.position
|
||||
audio_stream_player_2d.play()
|
||||
#+END_SRC
|
||||
|
||||
*** add game over sound
|
||||
- first make sure no other sound such as effects sounds are playing.
|
||||
- call "stop()" on all such nodes
|
||||
#+BEGIN_SRC gdscript
|
||||
audio_stream_player_2d.stop()
|
||||
#+END_SRC
|
||||
|
||||
- load the game over sounds using "preload"
|
||||
- CMD+drag the sound file from the filesystem to the game.gd script
|
||||
- godot will automatically create a constant with the file name
|
||||
- godot will also set that file to "preload" with the appropriate file path
|
||||
|
||||
- set the =stream= property of =audio_stream_player_2d= to the preloaded sound and play it
|
||||
|
||||
#+BEGIN_SRC gdscript
|
||||
audio_stream_player_2d.stream = EXPLODE
|
||||
audio_stream_player_2d.play()
|
||||
#+END_SRC
|
||||
|
||||
- put all this into a function and add it to the game_over function
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue