-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CardUI
Signal don't emit when put into custom dropzone
#6
Comments
Your question is pretty hard to follow, could you share the code for your custom dropzone? My guess is you need to add a class_name MyDropzone extends CardDropzone
func card_ui_dropped(card_ui: CardUI):
super(card_ui)
# your code goes here
do_something()
do_something_else() |
Also note that you might not want to call In case you're not familiar with |
My custom CardDropzone extends CardDropzone
@onready var game = get_parent()
func _ready():
pass # Replace with function body.
func card_ui_dropped(card_ui: CardUI):
super(card_ui)
# card_pile_ui.set_card_dropzone(card_ui, self)
game.play_card(card_ui.card_data) Thanks for the reply. I checked Though replace it with Also I checked the code inside I take some screenshots and my codes. Custom Card Classclass_name Card extends CardUI
@export var gold: int
@export var power: int
@export var cost: int
@export var description: String
@export var mode: String = ''
@export var highlighted: bool = false
@onready var name_label = $Frontface/Name
@onready var desc_label = $Frontface/Description
func set_store():
print_debug('set store')
set_mode('store')
func set_mode(_mode: String):
mode = _mode
func highlight():
if (highlighted):
return
position.y += size[1] * 0.1
scale = Vector2(1.1, 1.1)
highlighted = true
func unhighlight():
if (not highlighted):
return
scale = Vector2(1, 1)
position.y -= size[1] * 0.1
highlighted = false
func _ready():
super()
card_data.connect("card_data_updated", _update_display)
_update_display()
func _card_can_be_interacted_with():
print_debug('test mode: ', mode)
if mode == 'store':
return true
return super()
func _update_display():
name_label.text = card_data.nice_name
desc_label.text = card_data.description
|
@Arcadia822: ah, I see. Just to confirm, since you say "custom dropzone", does it work with stock |
Actually, I looked at your tree again, and I'm 90% sure I know what the issue is. Try dragging your |
Instant fix. I even don't notice node order matters 😂 . Maybe I should read the docs again. Thanks a lot again. |
I checked the Node / Signal section of godot docs and didn't find an explain. |
It doesn't! Signals are received just fine regardless of where the node sits in the tree, it's just that for display and input purposes, the nodes are drawn from the top of the tree down, meaning the ones further down will be drawn in front of the ones up the tree. And the ones that are in front are also the ones that receive input from the engine (unless you change their z-index). Here are the docs describing some of that, and the little pictorial description of how input processing is ordered: |
That's pretty clear, Thanks. Now i'm trying to add some features to this project. Hope I could make some pr soon. |
I'm trying to make some custom
Dropzone
. Problem is any card dropped into custom dropzones lose ability to trigger_on_mouse_enter
or_on_gui_input
.card_ui_dropped
._create_card_ui
and put into custom dropzone cannot trigger too. (Put into internal piles is OK)What I figured out:
_card_can_be_interacted_with
function. The hook doesn't triggered at all.CardUI
norCardPileUI
work.PS: I'm new to Godot and feel like this is a noob question. Please help. Thanks.
The text was updated successfully, but these errors were encountered: