Skip to content

Commit

Permalink
Merge pull request #34 from ligen131/change-cursor
Browse files Browse the repository at this point in the history
改变鼠标指针效果
  • Loading branch information
cutekibry authored Feb 6, 2024
2 parents a0b4f04 + edad156 commit 30be766
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 8 deletions.
Binary file added bg/cursor/cursor_arrow.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 bg/cursor/cursor_arrow.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://co4a7u0pxeuu2"
path="res://.godot/imported/cursor_arrow.png-016e6bb68d2c04d904ff82ec5ee50aba.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://bg/cursor/cursor_arrow.png"
dest_files=["res://.godot/imported/cursor_arrow.png-016e6bb68d2c04d904ff82ec5ee50aba.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
Binary file added bg/cursor/cursor_drag.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 bg/cursor/cursor_drag.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dxajv5y5s8q28"
path="res://.godot/imported/cursor_drag.png-829f8f6b9f9953dc61691149f4688a11.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://bg/cursor/cursor_drag.png"
dest_files=["res://.godot/imported/cursor_drag.png-829f8f6b9f9953dc61691149f4688a11.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
Binary file added bg/cursor/cursor_pointing_hand.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 bg/cursor/cursor_pointing_hand.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bha0hd2b7y73m"
path="res://.godot/imported/cursor_pointing_hand.png-12dd2a74777853d26a51801a2b407a4b.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://bg/cursor/cursor_pointing_hand.png"
dest_files=["res://.godot/imported/cursor_pointing_hand.png-12dd2a74777853d26a51801a2b407a4b.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
14 changes: 8 additions & 6 deletions main.gd
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
extends Node


# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
const CURSOR_ARROW := preload("res://bg/cursor/cursor_arrow.png")
const CURSOR_POINTING_HAND := preload("res://bg/cursor/cursor_pointing_hand.png")
const CURSOR_DRAG := preload("res://bg/cursor/cursor_drag.png")


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _ready():
Input.set_custom_mouse_cursor(CURSOR_ARROW)
Input.set_custom_mouse_cursor(CURSOR_POINTING_HAND, Input.CURSOR_POINTING_HAND)
Input.set_custom_mouse_cursor(CURSOR_DRAG, Input.CURSOR_DRAG)


func _on_main_menu_enter_level():
$BGMPlayer.play()
Expand Down
6 changes: 5 additions & 1 deletion objects/card/card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func _on_mouse_release():
last_occupied_area = entered_area
entered_area.set_card(self)
emit_signal("put")
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
$SFXPutDown.play()
# prints("card", $Word.get_word(), "put at", entered_area.name, "at global_position", global_position, "when origin global_position at", origin_global_position)
else:
Expand Down Expand Up @@ -85,7 +86,8 @@ func _process(delta: float) -> void:
_on_mouse_release()
if is_dragging:
have_deal_on_mouse_release = false
global_position = get_global_mouse_position()
global_position = get_global_mouse_position().round()
Input.set_default_cursor_shape(Input.CURSOR_DRAG)

func on_card_entered(area: Block) -> void:
is_card_entered += 1
Expand Down Expand Up @@ -115,9 +117,11 @@ func get_word() -> String:

func _on_mouse_entered():
$CardBackSprite.animation = "highlighted"
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)

func _on_mouse_exited():
$CardBackSprite.animation = "default"
Input.set_default_cursor_shape(Input.CURSOR_ARROW)

func set_victory(v: bool):
$Word.set_victory(v)
5 changes: 4 additions & 1 deletion objects/card_base/card_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func draw_card():
return
set_card_count(card_count - 1)
$SFXPickUp.play()
Input.set_default_cursor_shape(Input.CURSOR_DRAG)
new_card_node = Card.instantiate()
new_card_node.set_word($Word.get_word())
new_card_node.set_position(position)
Expand Down Expand Up @@ -101,9 +102,11 @@ func _process(delta) -> void:
func _on_mouse_entered():
mouse_on = true
if $AnimatedSprite2D.animation == "default":
$AnimatedSprite2D.animation = "highlighted"
$AnimatedSprite2D.animation = "highlighted"
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)

func _on_mouse_exited():
mouse_on = false
if $AnimatedSprite2D.animation == "highlighted":
$AnimatedSprite2D.animation = "default"
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ window/size/resizable=false
window/stretch/mode="viewport"
window/stretch/scale=4.0
window/stretch/scale_mode="integer"
mouse_cursor/custom_image="res://bg/cursor/cursor_arrow.png"

[rendering]

Expand Down

0 comments on commit 30be766

Please sign in to comment.