Using Defold-Input and web sockets for multiplayer card game(s)

Hi friends,

I’m a tabletop game dev and hobbyist programmer; I spend some of my coding free time making prototypes and tutorials for how to digitize card and board games.

I’ve been looking into Defold for a long time now (coming from Phaser/JS and Unity/C#), and curious about a few things as I get my feet wet:

  • Would Defold-Input be the optimal library for handling simple drag-and-drop operations of cards and board tokens? And if so, is there a way to import the Git examples into my project in addition to the scripts? I’m currently only able to import the “in” folder as a dependency.

  • Is there an example of a “dropzone” that one could use to detect whether a card or board token is over a particular set of coordinates, and therefore droppable? I found this thread but am unsure whether something like this has already been created.

  • Is using Nakama the preferred workflow for implementing multiplayer in Defold? I’ve been using Socket.IO in tandem with Phaser, and Mirror in Unity, and it would be nice to use something that has a similar feature set.

Thanks very much!

Defold-input can definitely be used as a starting point for card games with picking of cards, dragging and dropping etc.

If you want to add the examples as well you need to manually copy those files to your project. If you add it as a dependency you only get the exported “in” folder.

I would create the drop zone using a collision objects of the type “trigger” and use it while dragging a card to detect when a dragged card is over the drop zone.

I can create an example of this is you like. Please create a ticket on GitHub in the Defold-input repository.

Nakama is great for quickly setting up match making and launching a game. Once a match is established you can either use client authoritative multiplayer or use for instance Lua server code for server authoritative multiplayer.


Hi @britzl,

Thank you so much for your helpful and prompt replies! I will dig into what you’ve suggested and create a ticket for the drop zone example request.

Cheers, again!

Thanks. I’ll create an example soon!

1 Like

Thank you again so much!

1 Like

Hi @britzl and all,

Thank you again for the dropzone example! I’ve used it to make a little shell for a card game:

Two quick questions for you:

  • I’m getting blurry textures on cards as their resized upon creation, and followed the steps in this thread: Blurry sprites depending on scale - #7 by Pkeod. This seems to work, but I’m not able to save the texture profile for some reason (the default.texture_profiles tab name has an asterisk in front of it no matter how I save). What might I be doing wrong?

  • Is there a way, while using the cursor to drag, to keep the dragged game object on top of all others? I’ve tried changing the z position within the cursor.DRAG block:
elseif message_id == cursor.DRAG then
		print("Drag",,, message.x, message.y, message.dx, message.dy)
		local p = go.get_position(
		go.set_position(vmath.vector3(p.x, p.y, 1),

but this doesn’t seem to work.

Thank you!

That file is read only. Make a copy of it and reference it in game.project.

Not sure. Your solution should work. Create a ticket on GitHub with a minimal example and I can take a look.

1 Like

Check out this resource

1 Like

Will do, thank you so much!

EDIT: nevermind, I was able to solve by changing the z value of the objects as they are spawned by the factory. Thanks again!


This is awesome! Thanks for the flag!

1 Like