├── .gitignore ├── SwipeMenu ├── icon.png ├── Textures │ ├── CardLevel1.png │ ├── CardLevel2.png │ ├── CardLevel3.png │ ├── CardLevel4.png │ ├── background.png │ ├── CardLevel1.png.import │ ├── CardLevel2.png.import │ ├── CardLevel3.png.import │ ├── CardLevel4.png.import │ └── background.png.import ├── default_env.tres ├── icon.png.import ├── Menu.tscn ├── project.godot ├── ScrollContainer.tscn └── ScrollContainer.gd ├── CoinCollectingAnimation ├── icon.png ├── assets │ ├── textures │ │ ├── Coin.png │ │ ├── Background.png │ │ ├── Coin.png.import │ │ └── Background.png.import │ └── fonts │ │ └── KenneyFuture.ttf ├── .nativelib ├── default_env.tres ├── Coin.tscn ├── MainCamera.gd ├── icon.png.import ├── project.godot ├── Main.gd ├── Main.tscn └── MainCamera.tscn ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .import/ -------------------------------------------------------------------------------- /SwipeMenu/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/SwipeMenu/icon.png -------------------------------------------------------------------------------- /CoinCollectingAnimation/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/CoinCollectingAnimation/icon.png -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/SwipeMenu/Textures/CardLevel1.png -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/SwipeMenu/Textures/CardLevel2.png -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/SwipeMenu/Textures/CardLevel3.png -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/SwipeMenu/Textures/CardLevel4.png -------------------------------------------------------------------------------- /SwipeMenu/Textures/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/SwipeMenu/Textures/background.png -------------------------------------------------------------------------------- /CoinCollectingAnimation/assets/textures/Coin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/CoinCollectingAnimation/assets/textures/Coin.png -------------------------------------------------------------------------------- /CoinCollectingAnimation/assets/fonts/KenneyFuture.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/CoinCollectingAnimation/assets/fonts/KenneyFuture.ttf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # godot-simple-tutorial 2 | Kode dan contoh untuk Godot Simple Tutorial 3 | 4 | Tutorial Video: 5 | https://www.youtube.com/channel/UCZyutgO8JDEiNhCntRjY-9Q 6 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/assets/textures/Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidas13/godot-simple-tutorial/HEAD/CoinCollectingAnimation/assets/textures/Background.png -------------------------------------------------------------------------------- /CoinCollectingAnimation/.nativelib: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a342fa94-9bb6-43f1-87ab-824e5628257d", 3 | "platforms": [ 4 | "all", 5 | "android" 6 | ], 7 | "packages": {} 8 | } -------------------------------------------------------------------------------- /SwipeMenu/default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/Coin.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [ext_resource path="res://assets/textures/Coin.png" type="Texture" id=1] 4 | 5 | [sub_resource type="AtlasTexture" id=1] 6 | flags = 4 7 | atlas = ExtResource( 1 ) 8 | region = Rect2( 32, 32, 64, 64 ) 9 | 10 | [node name="Coin" type="Sprite"] 11 | texture = SubResource( 1 ) 12 | 13 | [node name="Tween" type="Tween" parent="."] 14 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/MainCamera.gd: -------------------------------------------------------------------------------- 1 | extends Camera2D 2 | 3 | export var max_slider_pos: float = 500 4 | export var max_zoom: float = 2.0 5 | onready var initial_pos: Vector2 = global_position 6 | 7 | 8 | func _on_ZoomSlider_value_changed(value: float) -> void: 9 | var zoom_amount := range_lerp(value, 0.0, 100.0, 0.1, max_zoom) 10 | zoom = Vector2(zoom_amount, zoom_amount) 11 | 12 | 13 | func _on_HPosSlider_value_changed(value: float) -> void: 14 | var x_pos := range_lerp(value, 0.0, 100.0, initial_pos.x - max_slider_pos, initial_pos.x + max_slider_pos) 15 | global_position.x = x_pos 16 | -------------------------------------------------------------------------------- /SwipeMenu/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel1.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/CardLevel1.png-2e115c743cc056652fa7af0cee31f8e0.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://Textures/CardLevel1.png" 13 | dest_files=[ "res://.import/CardLevel1.png-2e115c743cc056652fa7af0cee31f8e0.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel2.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/CardLevel2.png-ae61ad166c4bca260113ce74afb96ffd.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://Textures/CardLevel2.png" 13 | dest_files=[ "res://.import/CardLevel2.png-ae61ad166c4bca260113ce74afb96ffd.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel3.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/CardLevel3.png-42d3c16f5691fd3e836015b9cc6e5fec.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://Textures/CardLevel3.png" 13 | dest_files=[ "res://.import/CardLevel3.png-42d3c16f5691fd3e836015b9cc6e5fec.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /SwipeMenu/Textures/CardLevel4.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/CardLevel4.png-0d8ed3f285a5fbc07d828e195d5d4b37.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://Textures/CardLevel4.png" 13 | dest_files=[ "res://.import/CardLevel4.png-0d8ed3f285a5fbc07d828e195d5d4b37.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /SwipeMenu/Textures/background.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/background.png-80ce42bb8b3b7d506d65426f02cf456d.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://Textures/background.png" 13 | dest_files=[ "res://.import/background.png-80ce42bb8b3b7d506d65426f02cf456d.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /SwipeMenu/Menu.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=4 format=2] 2 | 3 | [ext_resource path="res://Textures/background.png" type="Texture" id=1] 4 | [ext_resource path="res://ScrollContainer.tscn" type="PackedScene" id=2] 5 | 6 | [sub_resource type="StyleBoxFlat" id=1] 7 | bg_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 ) 8 | border_width_top = 10 9 | border_width_bottom = 10 10 | border_color = Color( 1, 1, 1, 1 ) 11 | 12 | [node name="Node" type="Node"] 13 | 14 | [node name="BG" type="TextureRect" parent="."] 15 | anchor_right = 1.0 16 | anchor_bottom = 1.0 17 | mouse_filter = 2 18 | texture = ExtResource( 1 ) 19 | stretch_mode = 2 20 | __meta__ = { 21 | "_edit_lock_": true, 22 | "_edit_use_anchors_": false 23 | } 24 | 25 | [node name="ScrollContainer" parent="." instance=ExtResource( 2 )] 26 | margin_top = 158.0 27 | margin_bottom = -159.0 28 | custom_styles/bg = SubResource( 1 ) 29 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/assets/textures/Coin.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/Coin.png-92ed16662ca44189cba516778b071ebe.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://assets/textures/Coin.png" 13 | dest_files=[ "res://.import/Coin.png-92ed16662ca44189cba516778b071ebe.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/assets/textures/Background.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/Background.png-f8c1914e7b48f80280519f9410cfeb17.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://assets/textures/Background.png" 13 | dest_files=[ "res://.import/Background.png-f8c1914e7b48f80280519f9410cfeb17.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /SwipeMenu/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | [application] 12 | 13 | config/name="Swipe Menu Tutorial" 14 | run/main_scene="res://Menu.tscn" 15 | config/icon="res://icon.png" 16 | 17 | [display] 18 | 19 | window/size/width=1920 20 | window/size/height=1080 21 | window/size/test_width=960 22 | window/size/test_height=540 23 | window/stretch/mode="2d" 24 | window/stretch/aspect="expand" 25 | 26 | [input_devices] 27 | 28 | pointing/emulate_touch_from_mouse=true 29 | 30 | [physics] 31 | 32 | common/enable_pause_aware_picking=true 33 | 34 | [rendering] 35 | 36 | quality/driver/driver_name="GLES2" 37 | vram_compression/import_etc=true 38 | vram_compression/import_etc2=false 39 | environment/default_environment="res://default_env.tres" 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 David Wong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | [NativeLib] 12 | 13 | Python="C:/Users/david/miniconda3/python.exe" 14 | 15 | [application] 16 | 17 | config/name="Coin Collecting Animation" 18 | run/main_scene="res://Main.tscn" 19 | config/icon="res://icon.png" 20 | 21 | [display] 22 | 23 | window/stretch/mode="2d" 24 | window/stretch/aspect="expand" 25 | 26 | [editor_plugins] 27 | 28 | enabled=PoolStringArray( ) 29 | 30 | [input] 31 | 32 | ui_left_click={ 33 | "deadzone": 0.5, 34 | "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) 35 | ] 36 | } 37 | 38 | [physics] 39 | 40 | common/enable_pause_aware_picking=true 41 | 42 | [rendering] 43 | 44 | quality/driver/driver_name="GLES2" 45 | vram_compression/import_etc=true 46 | vram_compression/import_etc2=false 47 | environment/default_clear_color=Color( 0.121569, 0.121569, 0.121569, 1 ) 48 | environment/default_environment="res://default_env.tres" 49 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/Main.gd: -------------------------------------------------------------------------------- 1 | extends Node2D 2 | 3 | var Coin = preload("res://Coin.tscn") 4 | var coin_amount := 0 5 | 6 | 7 | onready var score_ui := $GUI/ScoreUI 8 | onready var score_icon := score_ui.get_node("Icon") 9 | onready var score_value := score_ui.get_node("Value") 10 | onready var main_camera := $MainCamera 11 | 12 | 13 | func _unhandled_input(event: InputEvent) -> void: 14 | if event is InputEventMouseButton: 15 | if event.is_action_pressed("ui_left_click"): 16 | var _coin: Sprite = Coin.instance(PackedScene.GEN_EDIT_STATE_INSTANCE) 17 | var _coin_tween: Tween = _coin.get_node("Tween") 18 | 19 | add_child(_coin) 20 | 21 | _coin_tween.follow_method( 22 | _coin, 23 | "set_global_position", 24 | get_global_mouse_position(), 25 | self, 26 | "_get_coin_target_position", 27 | 4.0, 28 | Tween.TRANS_BACK, 29 | Tween.EASE_IN_OUT 30 | ) 31 | _coin_tween.interpolate_property( 32 | _coin, 33 | "modulate:a", 34 | 1.0, 35 | 0.0, 36 | 0.5, 37 | Tween.TRANS_LINEAR, 38 | Tween.EASE_IN, 39 | 3.5 40 | ) 41 | _coin_tween.connect("tween_all_completed", self, "_on_Coin_update_score", [_coin]) 42 | 43 | _coin_tween.start() 44 | 45 | func _get_coin_target_position() -> Vector2: 46 | var _coin_pos: Vector2 = (score_icon.get_global_transform_with_canvas().origin + (score_icon.rect_size / 2)) * main_camera.zoom 47 | var _camera_pos: Vector2 = main_camera.global_position - (get_viewport_rect().size / 2 * main_camera.zoom) 48 | var _coin_target_position := _coin_pos + _camera_pos 49 | return _coin_target_position 50 | 51 | 52 | func _on_Coin_update_score(coin: Sprite) -> void: 53 | coin_amount += 1 54 | score_value.text = str(coin_amount) 55 | coin.queue_free() 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /SwipeMenu/ScrollContainer.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=6 format=2] 2 | 3 | [ext_resource path="res://Textures/CardLevel2.png" type="Texture" id=1] 4 | [ext_resource path="res://Textures/CardLevel3.png" type="Texture" id=2] 5 | [ext_resource path="res://Textures/CardLevel4.png" type="Texture" id=3] 6 | [ext_resource path="res://Textures/CardLevel1.png" type="Texture" id=4] 7 | [ext_resource path="res://ScrollContainer.gd" type="Script" id=5] 8 | 9 | [node name="ScrollContainer" type="ScrollContainer"] 10 | anchor_right = 1.0 11 | anchor_bottom = 1.0 12 | rect_clip_content = false 13 | mouse_filter = 1 14 | script = ExtResource( 5 ) 15 | __meta__ = { 16 | "_edit_use_anchors_": false 17 | } 18 | scroll_duration = 0.3 19 | 20 | [node name="CenterContainer" type="CenterContainer" parent="."] 21 | margin_right = 5172.0 22 | margin_bottom = 1068.0 23 | mouse_filter = 2 24 | size_flags_horizontal = 3 25 | size_flags_vertical = 3 26 | 27 | [node name="MarginContainer" type="MarginContainer" parent="CenterContainer"] 28 | margin_top = 329.0 29 | margin_right = 5172.0 30 | margin_bottom = 739.0 31 | mouse_filter = 2 32 | custom_constants/margin_right = 1920 33 | custom_constants/margin_left = 1920 34 | 35 | [node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/MarginContainer"] 36 | margin_left = 1920.0 37 | margin_right = 3252.0 38 | margin_bottom = 410.0 39 | mouse_filter = 2 40 | custom_constants/separation = 100 41 | 42 | [node name="CardMenu1" type="TextureRect" parent="CenterContainer/MarginContainer/HBoxContainer"] 43 | margin_right = 258.0 44 | margin_bottom = 410.0 45 | texture = ExtResource( 4 ) 46 | 47 | [node name="CardMenu2" type="TextureRect" parent="CenterContainer/MarginContainer/HBoxContainer"] 48 | margin_left = 358.0 49 | margin_right = 616.0 50 | margin_bottom = 410.0 51 | texture = ExtResource( 1 ) 52 | 53 | [node name="CardMenu3" type="TextureRect" parent="CenterContainer/MarginContainer/HBoxContainer"] 54 | margin_left = 716.0 55 | margin_right = 974.0 56 | margin_bottom = 410.0 57 | texture = ExtResource( 2 ) 58 | 59 | [node name="CardMenu4" type="TextureRect" parent="CenterContainer/MarginContainer/HBoxContainer"] 60 | margin_left = 1074.0 61 | margin_right = 1332.0 62 | margin_bottom = 410.0 63 | texture = ExtResource( 3 ) 64 | 65 | [connection signal="gui_input" from="." to="." method="_on_ScrollContainer_gui_input"] 66 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/Main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=8 format=2] 2 | 3 | [ext_resource path="res://assets/textures/Coin.png" type="Texture" id=1] 4 | [ext_resource path="res://assets/fonts/KenneyFuture.ttf" type="DynamicFontData" id=2] 5 | [ext_resource path="res://Main.gd" type="Script" id=3] 6 | [ext_resource path="res://MainCamera.tscn" type="PackedScene" id=4] 7 | [ext_resource path="res://assets/textures/Background.png" type="Texture" id=5] 8 | 9 | [sub_resource type="AtlasTexture" id=1] 10 | flags = 4 11 | atlas = ExtResource( 1 ) 12 | region = Rect2( 32, 32, 64, 64 ) 13 | 14 | [sub_resource type="DynamicFont" id=2] 15 | size = 28 16 | outline_size = 3 17 | extra_spacing_char = 2 18 | font_data = ExtResource( 2 ) 19 | 20 | [node name="Main" type="Node2D"] 21 | script = ExtResource( 3 ) 22 | 23 | [node name="GUI" type="CanvasLayer" parent="."] 24 | 25 | [node name="ScoreUI" type="HBoxContainer" parent="GUI"] 26 | margin_left = 421.0 27 | margin_top = 86.0 28 | margin_right = 599.0 29 | margin_bottom = 126.0 30 | custom_constants/separation = 9 31 | 32 | [node name="Icon" type="TextureRect" parent="GUI/ScoreUI"] 33 | margin_right = 32.0 34 | margin_bottom = 40.0 35 | rect_min_size = Vector2( 32, 32 ) 36 | texture = SubResource( 1 ) 37 | expand = true 38 | stretch_mode = 6 39 | 40 | [node name="Text" type="Label" parent="GUI/ScoreUI"] 41 | margin_left = 41.0 42 | margin_top = 4.0 43 | margin_right = 175.0 44 | margin_bottom = 36.0 45 | custom_colors/font_color = Color( 1, 1, 1, 1 ) 46 | custom_colors/font_outline_modulate = Color( 1, 0.8, 0, 1 ) 47 | custom_colors/font_color_shadow = Color( 0.890196, 0.713726, 0.00784314, 1 ) 48 | custom_constants/shadow_offset_x = 0 49 | custom_constants/shadow_offset_y = -1 50 | custom_fonts/font = SubResource( 2 ) 51 | text = "Score:" 52 | 53 | [node name="Value" type="Label" parent="GUI/ScoreUI"] 54 | margin_left = 184.0 55 | margin_top = 4.0 56 | margin_right = 207.0 57 | margin_bottom = 36.0 58 | custom_colors/font_color = Color( 1, 1, 1, 1 ) 59 | custom_colors/font_outline_modulate = Color( 1, 0.8, 0, 1 ) 60 | custom_colors/font_color_shadow = Color( 0.890196, 0.713726, 0.00784314, 1 ) 61 | custom_constants/shadow_offset_x = 0 62 | custom_constants/shadow_offset_y = -1 63 | custom_fonts/font = SubResource( 2 ) 64 | text = "0" 65 | 66 | [node name="MainCamera" parent="." instance=ExtResource( 4 )] 67 | position = Vector2( 512, 300 ) 68 | 69 | [node name="Background" type="Sprite" parent="."] 70 | position = Vector2( 515, 277 ) 71 | texture = ExtResource( 5 ) 72 | -------------------------------------------------------------------------------- /SwipeMenu/ScrollContainer.gd: -------------------------------------------------------------------------------- 1 | extends ScrollContainer 2 | 3 | 4 | export(float, 0.5, 1, 0.1) var card_scale = 1 5 | export(float, 1, 1.5, 0.1) var card_current_scale = 1.3 6 | export(float, 0.1, 1, 0.1) var scroll_duration = 1.3 7 | 8 | var card_current_index: int = 0 9 | var card_x_positions: Array = [] 10 | 11 | onready var scroll_tween: Tween = Tween.new() 12 | onready var margin_r: int = $CenterContainer/MarginContainer.get("custom_constants/margin_right") 13 | onready var card_space: int = $CenterContainer/MarginContainer/HBoxContainer.get("custom_constants/separation") 14 | onready var card_nodes: Array = $CenterContainer/MarginContainer/HBoxContainer.get_children() 15 | 16 | 17 | func _ready() -> void: 18 | add_child(scroll_tween) 19 | yield(get_tree(), "idle_frame") 20 | 21 | get_h_scrollbar().modulate.a = 0 22 | 23 | for _card in card_nodes: 24 | var _card_pos_x: float = (margin_r + _card.rect_position.x) - ((rect_size.x - _card.rect_size.x) / 2) 25 | _card.rect_pivot_offset = (_card.rect_size / 2) 26 | card_x_positions.append(_card_pos_x) 27 | 28 | scroll_horizontal = card_x_positions[card_current_index] 29 | scroll() 30 | 31 | 32 | func _process(delta: float) -> void: 33 | for _index in range(card_x_positions.size()): 34 | var _card_pos_x: float = card_x_positions[_index] 35 | var _swipe_length: float = (card_nodes[_index].rect_size.x / 2) + (card_space / 2) 36 | var _swipe_current_length: float = abs(_card_pos_x - scroll_horizontal) 37 | var _card_scale: float = range_lerp(_swipe_current_length, _swipe_length, 0, card_scale, card_current_scale) 38 | var _card_opacity: float = range_lerp(_swipe_current_length, _swipe_length, 0, 0.3, 1) 39 | 40 | _card_scale = clamp(_card_scale, card_scale, card_current_scale) 41 | _card_opacity = clamp(_card_opacity, 0.3, 1) 42 | 43 | card_nodes[_index].rect_scale = Vector2(_card_scale, _card_scale) 44 | card_nodes[_index].modulate.a = _card_opacity 45 | 46 | if _swipe_current_length < _swipe_length: 47 | card_current_index = _index 48 | 49 | 50 | func scroll() -> void: 51 | scroll_tween.interpolate_property( 52 | self, 53 | "scroll_horizontal", 54 | scroll_horizontal, 55 | card_x_positions[card_current_index], 56 | scroll_duration, 57 | Tween.TRANS_BACK, 58 | Tween.EASE_OUT) 59 | 60 | for _index in range(card_nodes.size()): 61 | var _card_scale: float = card_current_scale if _index == card_current_index else card_scale 62 | scroll_tween.interpolate_property( 63 | card_nodes[_index], 64 | "rect_scale", 65 | card_nodes[_index].rect_scale, 66 | Vector2(_card_scale,_card_scale), 67 | scroll_duration, 68 | Tween.TRANS_QUAD, 69 | Tween.EASE_OUT) 70 | 71 | scroll_tween.start() 72 | 73 | 74 | func _on_ScrollContainer_gui_input(event: InputEvent) -> void: 75 | if event is InputEventMouseButton: 76 | if event.pressed: 77 | scroll_tween.stop_all() 78 | else: 79 | scroll() 80 | -------------------------------------------------------------------------------- /CoinCollectingAnimation/MainCamera.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=5 format=2] 2 | 3 | [ext_resource path="res://MainCamera.gd" type="Script" id=1] 4 | [ext_resource path="res://assets/fonts/KenneyFuture.ttf" type="DynamicFontData" id=2] 5 | 6 | [sub_resource type="DynamicFont" id=2] 7 | size = 24 8 | font_data = ExtResource( 2 ) 9 | 10 | [sub_resource type="StyleBoxFlat" id=3] 11 | bg_color = Color( 0.6, 0.6, 0.6, 0 ) 12 | border_width_left = 5 13 | border_width_top = 5 14 | border_width_right = 5 15 | border_width_bottom = 5 16 | border_color = Color( 0, 0.6, 1, 1 ) 17 | 18 | [node name="MainCamera" type="Camera2D"] 19 | current = true 20 | zoom = Vector2( 2, 2 ) 21 | script = ExtResource( 1 ) 22 | 23 | [node name="CanvasLayer" type="CanvasLayer" parent="."] 24 | 25 | [node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer"] 26 | anchor_top = 1.0 27 | anchor_right = 1.0 28 | anchor_bottom = 1.0 29 | margin_top = -61.0 30 | margin_bottom = -14.0 31 | mouse_filter = 2 32 | custom_constants/separation = 64 33 | alignment = 1 34 | 35 | [node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/HBoxContainer"] 36 | margin_left = 330.0 37 | margin_right = 480.0 38 | margin_bottom = 47.0 39 | rect_min_size = Vector2( 150, 0 ) 40 | mouse_filter = 2 41 | size_flags_vertical = 3 42 | 43 | [node name="ZoomSlider" type="HSlider" parent="CanvasLayer/HBoxContainer/VBoxContainer"] 44 | margin_right = 150.0 45 | margin_bottom = 16.0 46 | size_flags_horizontal = 7 47 | size_flags_vertical = 3 48 | value = 100.0 49 | 50 | [node name="Label" type="Label" parent="CanvasLayer/HBoxContainer/VBoxContainer"] 51 | margin_top = 20.0 52 | margin_right = 150.0 53 | margin_bottom = 47.0 54 | custom_fonts/font = SubResource( 2 ) 55 | text = "Zoom" 56 | align = 1 57 | 58 | [node name="VBoxContainer2" type="VBoxContainer" parent="CanvasLayer/HBoxContainer"] 59 | margin_left = 544.0 60 | margin_right = 694.0 61 | margin_bottom = 47.0 62 | rect_min_size = Vector2( 150, 0 ) 63 | mouse_filter = 2 64 | size_flags_vertical = 3 65 | 66 | [node name="HPosSlider" type="HSlider" parent="CanvasLayer/HBoxContainer/VBoxContainer2"] 67 | margin_right = 150.0 68 | margin_bottom = 16.0 69 | size_flags_horizontal = 7 70 | size_flags_vertical = 3 71 | value = 50.0 72 | 73 | [node name="Label" type="Label" parent="CanvasLayer/HBoxContainer/VBoxContainer2"] 74 | margin_top = 20.0 75 | margin_right = 150.0 76 | margin_bottom = 47.0 77 | custom_fonts/font = SubResource( 2 ) 78 | text = "H Pos" 79 | align = 1 80 | 81 | [node name="PanelContainer" type="PanelContainer" parent="CanvasLayer"] 82 | anchor_right = 1.0 83 | anchor_bottom = 1.0 84 | mouse_filter = 2 85 | custom_styles/panel = SubResource( 3 ) 86 | 87 | [connection signal="value_changed" from="CanvasLayer/HBoxContainer/VBoxContainer/ZoomSlider" to="." method="_on_ZoomSlider_value_changed"] 88 | [connection signal="value_changed" from="CanvasLayer/HBoxContainer/VBoxContainer2/HPosSlider" to="." method="_on_HPosSlider_value_changed"] 89 | --------------------------------------------------------------------------------