๋‚ด ์ธ์ƒ์—์„œ ๋ฏฟ์„ ๊ฑด ์˜ค์ง ๋‚˜ ์ž์‹ ๋ฟ!

The only one you can truly trust is yourself.

๊ฒŒ์ž„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ/๊ณ ๋„ ์—”์ง„(Godot)

๊ณ ๋„ ์—”์ง„, BGM ์ถ”๊ฐ€ํ•˜๊ธฐ

๐ŸŽฎinspirer9 2024. 11. 9. 12:47
728x90
๋ฐ˜์‘ํ˜•

๊ฐ„๋‹จํ•œ ํผ์ฆ ๊ฒŒ์ž„ ๋งŒ๋“œ๋Š” ์ค‘์ธ๋ฐ ์ž๊พธ ์•ž๋ถ€๋ถ„์— ํ–ˆ๋˜ ๊ฑธ ๊นŒ๋จน๋Š”๋‹ค.

 

์˜ค๋””์˜ค ๊ด€๋ จ ์ฝ”๋“œ๋ฅผ ํ•˜๋‚˜ ์ƒ์„ฑํ•˜๊ณ , ๋งจ ์œ„์— ์˜ค๋””์˜ค ์ŠคํŠธ๋ฆผ ํ”Œ๋ ˆ์ด์–ด 2D ์ถ”๊ฐ€ (์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ง)

extends AudioStreamPlayer2D

๋ฆฌ์†Œ์Šค์™€ ์—ฐ๊ฒฐ๋  ์™ธ๋ถ€ ๋ณ€์ˆ˜ ์ƒ์„ฑ

# BGM ์‚ฌ์šด๋“œ ํŒŒ์ผ ๋กœ๋“œ
@export var title_music:AudioStream = preload("res://music/title_music.wav")
@export var stage_music:AudioStream = preload("res://music/stage_music.wav")
@export var game_over_music:AudioStream = preload("res://music/game_over_music.wav")
@export var game_clear_music:AudioStream = preload("res://music/game_clear_music.wav")

์Œ์•…์˜ ํƒ€์ž… ์ถ”๊ฐ€

enum MusicType {
	TITLE,
	STAGE,
	GAME_OVER,
	GAME_CLEAR
}

ํ”Œ๋ ˆ์ด ์ฝ”๋“œ

func play_music(music_type:MusicType):
	match music_type:
		MusicType.TITLE:
			stream = title_music
		MusicType.STAGE:
			stream = stage_music
		MusicType.GAME_OVER:
			stream = game_over_music
		MusicType.GAME_CLEAR:
			stream = game_clear_music
	play()

 

๊ฒŒ์ž„ ๋ฃจํ”„์—์„œ ๊ฒŒ์ž„ ์ƒํƒœ ๋ณ€๊ฒฝ ๋  ๋•Œ๋งˆ๋‹ค ํ˜ธ์ถœ

audio_player.play_music(audio_player.MusicType.TITLE)

 

์ถ”๊ฐ€#1.

ํšจ๊ณผ์Œ๊ณผ ์‚ฌ์šด๋“œ๋Š” ๋…ธ๋“œ๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด์„œ ๊ด€๋ฆฌ.

์‚ฌ์šด๋“œ๊ณผ ๊ฒŒ์ž„์„ ์‹ฑํฌ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Œ. ๋ฆฌ๋“ฌ ๊ฒŒ์ž„์—์„œ๋Š” ์ค‘์š”.

์‚ฌ์šด๋“œ ํšจ๊ณผ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Œ. ์ƒ๊ฐ๋ณด๋‹ค ๋‹ค์–‘ํ•จ.

์ด ์ •๋„๋งŒ ์•Œ๋ฉด 2D ๊ฒŒ์ž„ ๋งŒ๋“œ๋Š”๋ฐ ํ•„์š”ํ•œ ๊ฑด ๋‹ค ํ–ˆ๋‹ค๊ณ  ๋ณด๋ฉด ๋จ.

728x90
๋ฐ˜์‘ํ˜•