Skip to content

Commit

Permalink
added music button
Browse files Browse the repository at this point in the history
  • Loading branch information
hasashi2 committed Jul 22, 2021
1 parent 3d77b27 commit 84c94bc
Show file tree
Hide file tree
Showing 20 changed files with 208 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .import/Mukke_an.png-49a918eeb3106924466178cb08b788b8.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="d172177b0357f9e96f143a10da3c2090"
dest_md5="9f6f05158beec854d69e3dff277902ec"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/Mukke_aus.png-e15cc56cdbf95aba81545ce31e54e1bf.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="48c192cd8b47f09e9f3b6bc97d60afee"
dest_md5="001551fba679253b5fd4f889e21d08f7"

Binary file not shown.
1 change: 1 addition & 0 deletions Scripts/GamePlay_Data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,5 @@ var medal_goal_12 = medal_goal_1 + medal_add * 11
const FILE_NAME = "user://savegame.save"

# settings
var sound = true
var music = true
20 changes: 19 additions & 1 deletion Scripts/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var levelRestart = false
# Called when the node enters the scene tree for the first time.
func _ready():
load_game()
set_audio()

# warning-ignore:return_value_discarded
# here change to test screen
get_tree().change_scene(startscreen_path)
Expand Down Expand Up @@ -205,7 +207,8 @@ func save_game():
"locked_redis" : GamePlayData.locked_redis,
"locked_peace" : GamePlayData.locked_peace,
"locked_caring" : GamePlayData.locked_caring,
"music": GamePlayData.music
"music": GamePlayData.music,
"sound": GamePlayData.sound
}
# Store the save dictionary as a new line in the save file.
save_game.store_line(to_json(save_data))
Expand Down Expand Up @@ -237,6 +240,7 @@ func load_game():
GamePlayData.locked_peace = data["locked_peace"]
GamePlayData.locked_caring = data["locked_caring"]
GamePlayData.music = data["music"]
GamePlayData.sound = data["sound"]
else:
printerr("Corrupted data!")
else:
Expand All @@ -263,3 +267,17 @@ func setMedalStartValue(score_goal):
GamePlayData.medal_goal_10 = GamePlayData.medal_goal_1 + GamePlayData.medal_add * 9
GamePlayData.medal_goal_11 = GamePlayData.medal_goal_1 + GamePlayData.medal_add * 10
GamePlayData.medal_goal_12 = GamePlayData.medal_goal_1 + GamePlayData.medal_add * 11


func set_audio():
var master_sound = AudioServer.get_bus_index("Master")
var music_sound = AudioServer.get_bus_index("Music")
if GamePlayData.sound:
AudioServer.set_bus_mute(master_sound, false)
else:
AudioServer.set_bus_mute(master_sound, true)

if GamePlayData.music:
AudioServer.set_bus_mute(music_sound, false)
else:
AudioServer.set_bus_mute(music_sound, true)
Binary file added Sprites/JumpForLeft_Grafiken/Buttons/Mukke_an.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Sprites/JumpForLeft_Grafiken/Buttons/Mukke_an.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/Mukke_an.png-49a918eeb3106924466178cb08b788b8.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Sprites/JumpForLeft_Grafiken/Buttons/Mukke_an.png"
dest_files=[ "res://.import/Mukke_an.png-49a918eeb3106924466178cb08b788b8.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Sprites/JumpForLeft_Grafiken/Buttons/Mukke_aus.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/Mukke_aus.png-e15cc56cdbf95aba81545ce31e54e1bf.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Sprites/JumpForLeft_Grafiken/Buttons/Mukke_aus.png"
dest_files=[ "res://.import/Mukke_aus.png-e15cc56cdbf95aba81545ce31e54e1bf.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
9 changes: 9 additions & 0 deletions default_bus_layout.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_resource type="AudioBusLayout" format=2]

[resource]
bus/1/name = "Music"
bus/1/solo = false
bus/1/mute = false
bus/1/bypass_fx = false
bus/1/volume_db = 0.0
bus/1/send = "Master"
2 changes: 1 addition & 1 deletion export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../Blobby's Rising.apk"
export_path="../Blobby's Rising_small.apk"
script_export_mode=1
script_encryption_key=""

Expand Down
1 change: 1 addition & 0 deletions levels/CaringLevel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ stream = ExtResource( 9 )

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 8 )
bus = "Music"

[node name="ParallaxBackground" parent="." instance=ExtResource( 6 )]

Expand Down
1 change: 1 addition & 0 deletions levels/LaneMovement.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ stream = ExtResource( 9 )

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 8 )
bus = "Music"

[connection signal="timeout" from="EnemySpawnTimer" to="." method="_on_EnemySpawnTimer_timeout"]
[connection signal="timeout" from="FriendSpawnTimer" to="." method="_on_FriendSpawnTimer_timeout"]
1 change: 1 addition & 0 deletions levels/PeaceLevel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ position = Vector2( -300, 0 )

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 10 )
bus = "Music"

[node name="Player" parent="." instance=ExtResource( 2 )]

Expand Down
1 change: 1 addition & 0 deletions levels/RedistributionLevel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ autostart = true

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 9 )
bus = "Music"

[connection signal="timeout" from="EnemySpawnTimer" to="." method="_on_EnemySpawnTimer_timeout"]
[connection signal="timeout" from="FriendSpawnTimer" to="." method="_on_FriendSpawnTimer_timeout"]
1 change: 1 addition & 0 deletions levels/SubwayLevel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ wait_time = 0.8

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 9 )
bus = "Music"

[connection signal="timeout" from="EnemySpawnTimer" to="." method="_on_EnemySpawnTimer_timeout"]
[connection signal="timeout" from="FriendSpawnTimer" to="." method="_on_FriendSpawnTimer_timeout"]
1 change: 1 addition & 0 deletions levels/UpDownMovement.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ stream = ExtResource( 10 )

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 9 )
bus = "Music"

[node name="MobDestructionBorder2" parent="." instance=ExtResource( 11 )]

Expand Down
76 changes: 65 additions & 11 deletions start_screen/LevelSelection.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=22 format=2]

[ext_resource path="res://start_screen/level_selection.gd" type="Script" id=1]
[ext_resource path="res://MenuButton.tscn" type="PackedScene" id=2]
Expand All @@ -14,11 +14,41 @@
[ext_resource path="res://Scripts/ScrollingBackground.gd" type="Script" id=13]
[ext_resource path="res://start_screen/buttons/PeaceButton.tscn" type="PackedScene" id=14]
[ext_resource path="res://Audio/ui_click_rollover_misc_01.mp3" type="AudioStream" id=15]
[ext_resource path="res://Sprites/JumpForLeft_Grafiken/Buttons/Laut_aus.png" type="Texture" id=16]
[ext_resource path="res://Sprites/JumpForLeft_Grafiken/Buttons/Laut_an.png" type="Texture" id=17]
[ext_resource path="res://Sprites/JumpForLeft_Grafiken/Hintergruende/LevelStart/Umverteilung_start.png" type="Texture" id=19]
[ext_resource path="res://start_screen/buttons/CaringButton.tscn" type="PackedScene" id=20]

[sub_resource type="StreamTexture" id=1]
flags = 4
load_path = "res://.import/Laut_aus.png-7fcbf39e6fc514b8eddd2c55396b5a7f.stex"

[sub_resource type="StreamTexture" id=2]
flags = 4
load_path = "res://.import/Laut_an.png-7d8a248977b5f8c7311cc19f31b8a963.stex"

[sub_resource type="Animation" id=5]
resource_name = "Alert"
length = 0.25
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ) ]
}

[sub_resource type="StreamTexture" id=3]
flags = 4
load_path = "res://.import/Mukke_aus.png-e15cc56cdbf95aba81545ce31e54e1bf.stex"

[sub_resource type="StreamTexture" id=4]
flags = 4
load_path = "res://.import/Mukke_an.png-49a918eeb3106924466178cb08b788b8.stex"

[node name="LevelSelection" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
Expand Down Expand Up @@ -197,19 +227,40 @@ margin_bottom = -307.404
[node name="Sound" type="AudioStreamPlayer" parent="Camera/MenuButton"]
stream = ExtResource( 15 )

[node name="CheckButton" type="TextureButton" parent="Camera"]
[node name="SoundButton" type="TextureButton" parent="Camera"]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = -919.599
margin_top = 337.036
margin_right = -688.599
margin_bottom = 568.036
margin_left = -900.0
margin_top = 340.0
margin_right = -669.0
margin_bottom = 571.0
rect_scale = Vector2( 0.75, 0.75 )
focus_mode = 0
toggle_mode = true
pressed = true
enabled_focus_mode = 0
texture_normal = SubResource( 1 )
texture_pressed = SubResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="AnimationPlayer" type="AnimationPlayer" parent="Camera/SoundButton"]
anims/Alert = SubResource( 5 )

[node name="MusicButton" type="TextureButton" parent="Camera"]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = -650.0
margin_top = 340.0
margin_right = -419.0
margin_bottom = 571.0
focus_mode = 0
toggle_mode = true
pressed = true
enabled_focus_mode = 0
texture_normal = ExtResource( 16 )
texture_pressed = ExtResource( 17 )
texture_normal = SubResource( 3 )
texture_pressed = SubResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
Expand All @@ -225,9 +276,12 @@ margin_bottom = 1027.0

[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 11 )
bus = "Music"

[connection signal="pressed" from="Camera/NextLevelButton" to="." method="_on_NextLevelButton_pressed"]
[connection signal="pressed" from="Camera/PrevLevelButton" to="." method="_on_PrevLevelButton_pressed"]
[connection signal="finished" from="Camera/MenuButton/Sound" to="Camera/MenuButton" method="_on_Sound_finished"]
[connection signal="toggled" from="Camera/CheckButton" to="." method="_on_CheckButton_toggled"]
[connection signal="toggled" from="Camera/SoundButton" to="." method="_on_SoundButton_toggled"]
[connection signal="pressed" from="Camera/MusicButton" to="." method="_on_MusicButton_pressed"]
[connection signal="toggled" from="Camera/MusicButton" to="." method="_on_MusicButton_toggled"]
[connection signal="fade_finished" from="Camera/FadeIn" to="." method="_on_FadeIn_fade_finished"]
37 changes: 33 additions & 4 deletions start_screen/level_selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ extends Control
var scene_path_to_load

func _ready():
get_node("Camera/CheckButton").pressed = GamePlayData.music
get_node("Camera/SoundButton").pressed = GamePlayData.sound
get_node("Camera/MusicButton").pressed = GamePlayData.music

if GamePlayData.music:
get_node("Music").play()
Expand Down Expand Up @@ -381,12 +382,40 @@ func _on_PrevLevelButton_pressed():
$Camera/PrevLevelButton/Sound.play()
showPrevLevel()

func _on_CheckButton_toggled(button_pressed):
func _on_SoundButton_toggled(button_pressed):
var master_sound = AudioServer.get_bus_index("Master")
var music_sound = AudioServer.get_bus_index("Music")
if button_pressed:
AudioServer.set_bus_mute(master_sound, false)
# if get_node("Camera/MusicButton").pressed:
AudioServer.set_bus_mute(music_sound, false)
get_node("Music").play()
# if get_node("Camera/MusicButton").pressed:
GamePlayData.music = true
MainScript.save_game()
GamePlayData.sound = true
else:
AudioServer.set_bus_mute(master_sound, true)
AudioServer.set_bus_mute(music_sound, true)
GamePlayData.music = false
GamePlayData.sound = false

MainScript.save_game()
get_node("Camera/MusicButton").pressed = GamePlayData.music

func _on_MusicButton_toggled(button_pressed):
var music_sound = AudioServer.get_bus_index("Music")
if button_pressed:
AudioServer.set_bus_mute(music_sound, false)
get_node("Music").play()
GamePlayData.music = true
else:
AudioServer.set_bus_mute(music_sound, true)
get_node("Music").stop()
GamePlayData.music = false
MainScript.save_game()

MainScript.save_game()

func _on_MusicButton_pressed():
if !get_node("Camera/SoundButton").pressed:
get_node("Camera/SoundButton/AnimationPlayer").play("Alert")
get_node("Camera/MusicButton").pressed = false

0 comments on commit 84c94bc

Please sign in to comment.