- git init
This commit is contained in:
commit
78d62d0173
394 changed files with 8494 additions and 0 deletions
38
Scenen/stick/Knob.gd
Normal file
38
Scenen/stick/Knob.gd
Normal file
|
@ -0,0 +1,38 @@
|
|||
extends Sprite2D
|
||||
|
||||
@onready var parent = $".."
|
||||
|
||||
var pressing = false
|
||||
|
||||
@export var maxLength = 50
|
||||
var deadzone = 15
|
||||
|
||||
func _ready():
|
||||
deadzone = parent.deadzone
|
||||
maxLength *= parent.scale.x
|
||||
|
||||
func _process(delta):
|
||||
if pressing:
|
||||
if get_global_mouse_position().distance_to(parent.global_position) <= maxLength:
|
||||
global_position = get_global_mouse_position()
|
||||
else:
|
||||
var angle = parent.global_position.angle_to_point(get_global_mouse_position())
|
||||
global_position.x = parent.global_position.x + cos(angle)*maxLength
|
||||
global_position.y = parent.global_position.y + sin(angle)*maxLength
|
||||
calculateVector()
|
||||
else:
|
||||
global_position = lerp(global_position, parent.global_position, delta*50)
|
||||
parent.posVector = Vector2(0,0)
|
||||
|
||||
func calculateVector():
|
||||
if abs((global_position.x - parent.global_position.x)) >= deadzone:
|
||||
parent.posVector.x = (global_position.x - parent.global_position.x)/maxLength
|
||||
if abs((global_position.y - parent.global_position.y)) >= deadzone:
|
||||
parent.posVector.y = (global_position.y - parent.global_position.y)/maxLength
|
||||
|
||||
func _on_button_button_down():
|
||||
pressing = true
|
||||
|
||||
|
||||
func _on_button_button_up():
|
||||
pressing = false
|
BIN
Scenen/stick/joyknobpng.png
Normal file
BIN
Scenen/stick/joyknobpng.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
34
Scenen/stick/joyknobpng.png.import
Normal file
34
Scenen/stick/joyknobpng.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://hg42snfhm6ei"
|
||||
path="res://.godot/imported/joyknobpng.png-64c62ab708d1de033ab6f6d261cbeca6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Scenen/stick/joyknobpng.png"
|
||||
dest_files=["res://.godot/imported/joyknobpng.png-64c62ab708d1de033ab6f6d261cbeca6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
BIN
Scenen/stick/joyring.png
Normal file
BIN
Scenen/stick/joyring.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
34
Scenen/stick/joyring.png.import
Normal file
34
Scenen/stick/joyring.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bidhxucp2kd66"
|
||||
path="res://.godot/imported/joyring.png-25c2137935002abe1d7560c543f467cb.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Scenen/stick/joyring.png"
|
||||
dest_files=["res://.godot/imported/joyring.png-25c2137935002abe1d7560c543f467cb.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
8
Scenen/stick/joystick.gd
Normal file
8
Scenen/stick/joystick.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends Node2D
|
||||
|
||||
var posVector: Vector2
|
||||
@export var deadzone = 15
|
||||
|
||||
func _ready() -> void:
|
||||
if not DisplayServer.is_touchscreen_available():
|
||||
set_process(false)
|
27
Scenen/stick/joystick.tscn
Normal file
27
Scenen/stick/joystick.tscn
Normal file
|
@ -0,0 +1,27 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dm6q0abakck7u"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenen/stick/joystick.gd" id="1_ii2vn"]
|
||||
[ext_resource type="Texture2D" uid="uid://bidhxucp2kd66" path="res://Scenen/stick/joyring.png" id="2_w2jn3"]
|
||||
[ext_resource type="Texture2D" uid="uid://hg42snfhm6ei" path="res://Scenen/stick/joyknobpng.png" id="3_voruw"]
|
||||
[ext_resource type="Script" path="res://Scenen/stick/Knob.gd" id="4_g4kk1"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wuxim"]
|
||||
size = Vector2(100, 100)
|
||||
|
||||
[node name="Joystick" type="Node2D"]
|
||||
script = ExtResource("1_ii2vn")
|
||||
|
||||
[node name="Ring" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.055, 0.055)
|
||||
texture = ExtResource("2_w2jn3")
|
||||
|
||||
[node name="Knob" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.02, 0.02)
|
||||
texture = ExtResource("3_voruw")
|
||||
script = ExtResource("4_g4kk1")
|
||||
|
||||
[node name="Button" type="TouchScreenButton" parent="."]
|
||||
shape = SubResource("RectangleShape2D_wuxim")
|
||||
|
||||
[connection signal="pressed" from="Button" to="Knob" method="_on_button_button_down"]
|
||||
[connection signal="released" from="Button" to="Knob" method="_on_button_button_up"]
|
Loading…
Add table
Add a link
Reference in a new issue