Topic was automatically imported from the old Question2Answer platform.
Asked By
JungleJoker
Old Version
Published before Godot 3 was released.
Hi, I’m a web developer with experience in JavaScript (angular, react and node), Java and C#, so not a complete noob programming wise, however, I am a complete noob when it comes to game development. But I’m very eager to learn more. As my very first game I decided to make a little card game.
One of the first things I wanted to try was to make hand of cards, something like this:
I can drag and snap images in place, no problem there. However my problem arises when 2 images overlap eachother. From then on, whenever I drag one around, both get moved around. My issue is pretty similar as the one posted here. where they say to “use the space2d to query” but I can’t seem to find any further documentation on it, so I don’t really know how to go on from here.
This is what my input+event code looks like:
func _input_event(viewport, event, shape_idx):
if event.type == InputEvent.MOUSE_MOTION or event.type == InputEvent.SCREEN_DRAG :
event = make_input_local(event)
set_pos(get_global_mouse_pos())
get_tree().set_input_as_handled()
I think you’re better off using UI based nodes and wiring up its input_event, mouse_enter and mouse_exit
signals than what you’re currently using.
Node2D
|_Control
|_ TextureFrame
Wire up these signals on the Control node
Signals
input_event
mouse_enter
mouse_exit
Check out the example on git
Thank you very much for the example! This works much better indeed, also, the tracking on a touch screen feels smoother than with the area/collisionShape combo.
One more question though: When 2 cards overlap eachother, it’s possible that the bottom card get’s selected on a click. Do you know of a way to always get the top (visible) card in that situation?
Can’t believe it. Was looking for a card game to include in my project, posted a question for that, and I just stumbled on yours…
My project is Onyris (first time I read about your project), an rpg/adventure game of survival/race/socials set in dream world, and I need a card game as a chalenge to win a special card, of the world game. It happens in the library, against the librarian.
Here is the project, at its begining, in progress: DL.FREE.FR
Would you be willing to be a part of it, just leting me using your scripts and mechanics, or more as it seems to fit perfectly in my universe?