mirror of
https://github.com/Dariasteam/Cows-Revenge.git
synced 2026-01-23 02:15:17 +00:00
Improve cowbells sound system
This commit is contained in:
parent
3bb9bf1440
commit
c6ae244f47
7 changed files with 106 additions and 58 deletions
|
|
@ -2,23 +2,11 @@ extends Area2D
|
|||
|
||||
export(int) var amount = 100
|
||||
|
||||
onready var sound = get_node("Sound")
|
||||
onready var sprite = get_node("Sprite")
|
||||
onready var timer = get_node("Timer")
|
||||
|
||||
func _ready():
|
||||
timer.connect("timeout",self,"queue_free")
|
||||
pass
|
||||
|
||||
func _on_Area2D_body_enter( body ):
|
||||
if(body.is_in_group("player")):
|
||||
var pitch = body.add_cowbells(1)
|
||||
|
||||
sound.set_default_pitch_scale(pitch)
|
||||
sound.play("cowbell_sound", 0)
|
||||
|
||||
sprite.set_opacity(0)
|
||||
disconnect("body_enter",self,"_on_Area2D_body_enter")
|
||||
timer.start()
|
||||
|
||||
|
||||
|
||||
body.add_cowbells(1)
|
||||
queue_free()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,14 @@
|
|||
[gd_scene load_steps=7 format=1]
|
||||
[gd_scene load_steps=5 format=1]
|
||||
|
||||
[ext_resource path="res://Scenes/Events/cowbell.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Sprites/Charasets/cowbell.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Scenes/Events/cowbell_animations.tres" type="Animation" id=3]
|
||||
[ext_resource path="res://Sound/cowbell_sound.wav" type="Sample" id=4]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
extents = Vector2( 13, 13 )
|
||||
|
||||
[sub_resource type="SampleLibrary" id=2]
|
||||
|
||||
samples/cowbell_sound = {
|
||||
"db": 0.0,
|
||||
"pitch": 1.0,
|
||||
"priority": 0,
|
||||
"sample": ExtResource( 4 )
|
||||
}
|
||||
|
||||
[node name="Cowbell" type="Area2D"]
|
||||
|
||||
z/relative = false
|
||||
|
|
@ -61,30 +51,6 @@ shape = SubResource( 1 )
|
|||
trigger = false
|
||||
_update_shape_index = 0
|
||||
|
||||
[node name="Sound" type="SamplePlayer" parent="."]
|
||||
|
||||
config/polyphony = 1
|
||||
config/samples = SubResource( 2 )
|
||||
default/volume_db = 7.0
|
||||
default/pitch_scale = 1.0
|
||||
default/pan = 0.0
|
||||
default/depth = 0.0
|
||||
default/height = 0.0
|
||||
default/filter/type = 0
|
||||
default/filter/cutoff = 5000.0
|
||||
default/filter/resonance = 1.0
|
||||
default/filter/gain = 1.0
|
||||
default/reverb_room = 2
|
||||
default/reverb_send = 0.0
|
||||
default/chorus_send = 0.0
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
||||
process_mode = 1
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
autostart = false
|
||||
|
||||
[connection signal="body_enter" from="." to="." method="_on_Area2D_body_enter"]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ extends Node2D
|
|||
# var b = "textvar"
|
||||
|
||||
onready var timer = get_node("next_cowbell_time")
|
||||
const SAMPLE_LIBRARY = preload("res://Scenes/Events/cowbell_sample_library.tres")
|
||||
|
||||
export(float) var pitch_increment = 0.05
|
||||
export(float) var base_pitch = 1.5
|
||||
|
|
@ -16,8 +17,25 @@ func timer_timeout():
|
|||
|
||||
func play_sound():
|
||||
pitch += pitch_increment
|
||||
|
||||
var sample_player = SamplePlayer.new()
|
||||
sample_player.set_sample_library(SAMPLE_LIBRARY)
|
||||
sample_player.set_default_pitch_scale(pitch)
|
||||
sample_player.set_default_volume(40)
|
||||
|
||||
var aux_timer = Timer.new()
|
||||
aux_timer.set_one_shot(true)
|
||||
aux_timer.set_wait_time(0.5)
|
||||
|
||||
aux_timer.connect("timeout",sample_player,"queue_free")
|
||||
|
||||
add_child(sample_player)
|
||||
sample_player.add_child(aux_timer)
|
||||
|
||||
sample_player.play("cowbell_sound")
|
||||
aux_timer.start()
|
||||
|
||||
timer.start()
|
||||
return pitch
|
||||
|
||||
func _ready():
|
||||
timer.connect("timeout",self,"timer_timeout")
|
||||
|
|
|
|||
13
Scenes/Events/cowbell_sample_library.tres
Normal file
13
Scenes/Events/cowbell_sample_library.tres
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_resource type="SampleLibrary" load_steps=2 format=1]
|
||||
|
||||
[ext_resource path="res://Sound/cowbell_sound.wav" type="Sample" id=1]
|
||||
|
||||
[resource]
|
||||
|
||||
samples/cowbell_sound = {
|
||||
"db": 0.0,
|
||||
"pitch": 1.0,
|
||||
"priority": 0,
|
||||
"sample": ExtResource( 1 )
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=17 format=1]
|
||||
[gd_scene load_steps=18 format=1]
|
||||
|
||||
[ext_resource path="res://Scenes/Maps/map_1.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Scenes/Menu/life_hud.gd" type="Script" id=2]
|
||||
|
|
@ -63,6 +63,10 @@ srgb/enabled = false
|
|||
|
||||
environment = SubResource( 1 )
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id=3]
|
||||
|
||||
shader/shading_mode = 0
|
||||
|
||||
[node name="Node2D" type="Node2D" groups=[
|
||||
"control",
|
||||
]]
|
||||
|
|
@ -80,7 +84,6 @@ margin/bottom = 768.0
|
|||
|
||||
[node name="Viewport" type="Viewport" parent="Control"]
|
||||
|
||||
editor/display_folded = true
|
||||
rect = Rect2( 0, 0, 1280, 768 )
|
||||
own_world = false
|
||||
world = SubResource( 2 )
|
||||
|
|
@ -292,6 +295,7 @@ percent_visible = 1.0
|
|||
|
||||
[node name="Sprite" type="Sprite" parent="Control/Cowbells"]
|
||||
|
||||
material/material = SubResource( 3 )
|
||||
transform/pos = Vector2( 586, 45 )
|
||||
transform/scale = Vector2( 3, 3 )
|
||||
texture = ExtResource( 14 )
|
||||
|
|
|
|||
61
d.tscn
Normal file
61
d.tscn
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue