# Drag sprite between fixed locations

**URL:** https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327
**Category:** Questions about Thunkable X
**Created:** [June 26, 2021, 12:33pm UTC](https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327 "2021-06-26T12:33:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![taylor.rc90sfj](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@taylor.rc90sfj](https://community.thunkable.com/u/taylor.rc90sfj)
#### Post date: [June 26, 2021, 12:33pm UTC](https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327/1 "2021-06-26T12:33:03Z")

</div>

Is there a way to drag the sprite between fixed locations on a canvas.

As on a chessboard how you might want to drag a pawn from c4 to c6 or if you have a bunch of stepping stones you want to move the sprite between through dragging?

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [June 26, 2021, 12:50pm UTC](https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327/2 "2021-06-26T12:50:23Z")

</div>

So first you might want to have an list of the x and y coordinates of all your cells. Then when the user clicks on a cell, get its coordinates from the list and move it there. Otherwise, when you click on any part of a canvas, you get its x and y coordinates, which you can use to shift the sprite.

---

<div class="post-metadata">

### Author: ![taylor.rc90sfj](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@taylor.rc90sfj](https://community.thunkable.com/u/taylor.rc90sfj)
#### Post date: [June 26, 2021, 1:45pm UTC](https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327/3 "2021-06-26T13:45:58Z")

</div>

This makes sense in the context of a click style action, no?

As in, sprite is in point A I click it and then click point B it can grab the coordinates of point B and move to point B.

What if I wanted to use the drag feature e.g. I have a square with the corners A, B, C, D my sprite is at A. I can drag it towards B or C or D. Is there a way of having it realize the way you’re dragging it and then centre it on one of these corner points based on the drag?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 28, 2021, 3:37am UTC](https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327/4 "2021-06-28T03:37:57Z")

</div>

This demo I made should get you started:

> [@Sprite positioning when canvas loads](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/9):
>
> I’m working on a snap-to-grid demo and it works well but if I give the sprite any momentum when dropping it, it glides to a new position that is no longer snapped to the grid. Does anyone know how to prevent that? I basically want to disable movement for the sprites. They should be draggable but not moveable if that makes sense. [https://x.thunkable.com/projects/60bcf3db90b63a00128256d1/5bfb81a8-0cff-4cf3-9558-01010c4cdfd6/designer](https://x.thunkable.com/projects/60bcf3db90b63a00128256d1/5bfb81a8-0cff-4cf3-9558-01010c4cdfd6/designer) [drag demo]

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:20pm UTC](https://community.thunkable.com/t/drag-sprite-between-fixed-locations/1365327/5 "2024-11-08T13:20:06Z")

</div>


