hover light click area
This commit is contained in:
parent
97e7f080ba
commit
80ad0b18db
@ -4,9 +4,9 @@
|
||||
[ext_resource type="Texture2D" uid="uid://botg6n14al2eu" path="res://asset/art/gif/c03_特写与游戏动画/绞肉机特写动画/1.png" id="2_up5wq"]
|
||||
[ext_resource type="Texture2D" uid="uid://cvhquuvipetio" path="res://asset/art/gif/c03_特写与游戏动画/绞肉机特写动画/2.png" id="3_oilu3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bn3x37ya65ixm" path="res://asset/art/gif/c03_特写与游戏动画/绞肉机特写动画/3.png" id="4_uidoe"]
|
||||
[ext_resource type="Texture2D" path="res://asset/art/gif/c03_特写与游戏动画/鬼母子神/0.png" id="5_uidoe"]
|
||||
[ext_resource type="Texture2D" path="res://asset/art/gif/c03_特写与游戏动画/鬼母子神/1.png" id="6_yp83y"]
|
||||
[ext_resource type="Texture2D" path="res://asset/art/gif/c03_特写与游戏动画/鬼母子神/2.png" id="7_axfhb"]
|
||||
[ext_resource type="Texture2D" uid="uid://c5sc5ctss08qc" path="res://asset/art/gif/c03_特写与游戏动画/鬼母子神/0.png" id="5_uidoe"]
|
||||
[ext_resource type="Texture2D" uid="uid://dx2v7bicpg7b4" path="res://asset/art/gif/c03_特写与游戏动画/鬼母子神/1.png" id="6_yp83y"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkh3cc2fg486c" path="res://asset/art/gif/c03_特写与游戏动画/鬼母子神/2.png" id="7_axfhb"]
|
||||
|
||||
[resource]
|
||||
animations = [{
|
||||
@ -23,7 +23,7 @@ animations = [{
|
||||
"duration": 6.0,
|
||||
"texture": ExtResource("4_uidoe")
|
||||
}],
|
||||
"loop": true,
|
||||
"loop": false,
|
||||
"name": &"绞肉机特写动画",
|
||||
"speed": 30.0
|
||||
}, {
|
||||
@ -37,7 +37,7 @@ animations = [{
|
||||
"duration": 12.0,
|
||||
"texture": ExtResource("7_axfhb")
|
||||
}],
|
||||
"loop": true,
|
||||
"loop": false,
|
||||
"name": &"鬼母子神",
|
||||
"speed": 30.0
|
||||
}]
|
||||
|
BIN
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_剪刀.png
Normal file
BIN
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_剪刀.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 697 B |
34
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_剪刀.png.import
Normal file
34
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_剪刀.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://boc0hof5p6sjs"
|
||||
path="res://.godot/imported/l_剪刀.png-a33ee9fc0cf8669410dc8f75f04290ce.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_剪刀.png"
|
||||
dest_files=["res://.godot/imported/l_剪刀.png-a33ee9fc0cf8669410dc8f75f04290ce.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
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_舌头.png
Normal file
BIN
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_舌头.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 229 B |
34
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_舌头.png.import
Normal file
34
asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_舌头.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cstd74y5811u3"
|
||||
path="res://.godot/imported/l_舌头.png-0de17a1a5d0452f7777f9fc1cad4be8f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://asset/art/scene/c03/s03_瞎子理发店/鬼母子神/l_舌头.png"
|
||||
dest_files=["res://.godot/imported/l_舌头.png-0de17a1a5d0452f7777f9fc1cad4be8f.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
|
69
scene/entity/ux/hover_light_click_area.gd
Normal file
69
scene/entity/ux/hover_light_click_area.gd
Normal file
@ -0,0 +1,69 @@
|
||||
class_name HoverLightClickArea extends Area2D
|
||||
|
||||
signal clicked
|
||||
|
||||
@export var freezing := false:
|
||||
set(val):
|
||||
freezing = val
|
||||
if freezing and touching:
|
||||
_on_mouse_exited()
|
||||
|
||||
var touching = false
|
||||
static var current_focusing_item = "":
|
||||
set(val):
|
||||
current_focusing_item = val
|
||||
if GlobalConfig.DEBUG:
|
||||
print("HoverLightClickArea current_focusing_item=", current_focusing_item)
|
||||
static var pending_enter_callables := [] as Array[Callable]
|
||||
|
||||
# to pointlight2d
|
||||
var lights: Array[NodePath] = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
for c in get_children():
|
||||
if c is PointLight2D:
|
||||
lights.append(c)
|
||||
if lights.is_empty():
|
||||
printerr("HoverLightButton has no PointLight2D children")
|
||||
mouse_entered.connect(_on_mouse_entered)
|
||||
mouse_exited.connect(_on_mouse_exited)
|
||||
|
||||
|
||||
func is_focused() -> bool:
|
||||
return current_focusing_item == name
|
||||
|
||||
|
||||
func _on_mouse_entered() -> bool:
|
||||
touching = true
|
||||
if freezing or not is_visible_in_tree():
|
||||
return false
|
||||
if is_focused():
|
||||
return true
|
||||
# 尝试获得 current_focusing_item
|
||||
if current_focusing_item != "":
|
||||
if not pending_enter_callables.has(_on_mouse_entered):
|
||||
pending_enter_callables.append(_on_mouse_entered)
|
||||
return false
|
||||
current_focusing_item = name
|
||||
_toggle_light(true)
|
||||
return true
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
touching = false
|
||||
pending_enter_callables.erase(_on_mouse_entered)
|
||||
# frezzing 不影响 mouse exited
|
||||
if is_focused():
|
||||
current_focusing_item = ""
|
||||
for c in pending_enter_callables:
|
||||
if c.call():
|
||||
break
|
||||
_toggle_light(false)
|
||||
|
||||
|
||||
func _toggle_light(on: bool) -> void:
|
||||
for l in lights:
|
||||
var light = get_node(l) as PointLight2D
|
||||
if light:
|
||||
light.enabled = on
|
1
scene/entity/ux/hover_light_click_area.gd.uid
Normal file
1
scene/entity/ux/hover_light_click_area.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://ubn3pgywffro
|
9
scene/entity/ux/hover_light_click_area.tscn
Normal file
9
scene/entity/ux/hover_light_click_area.tscn
Normal file
@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bkk1rxx36ghrl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ubn3pgywffro" path="res://scene/entity/ux/hover_light_click_area.gd" id="1_qoyst"]
|
||||
|
||||
[node name="HoverLightClickArea" type="Area2D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
monitorable = false
|
||||
script = ExtResource("1_qoyst")
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user