# Link and Switch

**URL:** <https://forum.defold.com/t/link-and-switch/2220>\
**Category:** Showcases\
**Created:** [June 22, 2016, 7:20am UTC](https://forum.defold.com/t/link-and-switch/2220 "2016-06-22T07:20:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 22, 2016, 7:20am UTC](https://forum.defold.com/t/link-and-switch/2220/1 "2016-06-22T07:20:03Z")

</div>

There was [a question a while back on the forum](https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144) about how to deal with the data structure of a linker or match 3 game (switcher) and it got me thinking how I would go about creating such a game myself. In my previous attempts I have always gone with a grid like data structure to hold the blocks on the game board, but this time I thought I would try to do something else. The example I’m sharing here keeps a single list of spawned blocks and then relies on the physics system to detect when a block should fall or which neighbours it has. This system proves to be a lot simpler to work with than trying to keep a grid-like data structure up-to-date when blocks are removed, spawned and falling.

The example is available here: [GitHub - britzl/linkandswitch: Defold linker and switcher game example · GitHub](https://github.com/britzl/linkandswitch) and a playable version here: [Link and Switch 0.1](https://britzl.github.io/linkandswitch/)

Enjoy!

---

<div class="post-metadata">

**Author:** ![Fuscy](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/fuscy/32/1281_2.png) [@Fuscy](https://forum.defold.com/u/Fuscy)\
**Post date:** [June 22, 2016, 3:57pm UTC](https://forum.defold.com/t/link-and-switch/2220/2 "2016-06-22T15:57:16Z")

</div>

Sweet implementation 🙂

Discovered a bug with the linker. Sometimes when removing 2 sets of links and the elements are still falling down, the game spawns another table full of elements right over the existing ones. Switching from linker to switcher keeps those elements in the background.

The pause state where you can’t take any action in the switcher might be preventing this bug from happening in that case.

Anyway, this is awesome.

_Fuscy_

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 23, 2016, 3:18pm UTC](https://forum.defold.com/t/link-and-switch/2220/3 "2016-06-23T15:18:51Z")

</div>

Hmm, I’m unable to reproduce this. Are you able to remove another set of links before the ones removed from the first link has stopped falling?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 23, 2016, 3:28pm UTC](https://forum.defold.com/t/link-and-switch/2220/4 "2016-06-23T15:28:30Z")

</div>

Ah silly me. The Linker and Switcher buttons from the menu were still active underneath so you probably managed to switch game mode. I’ve fixed this. Thanks for reporting it!
