# How can i make sprite in canvas to draggable only in x axis?

**URL:** <https://community.thunkable.com/t/how-can-i-make-sprite-in-canvas-to-draggable-only-in-x-axis/543895>\
**Category:** Questions about Thunkable X\
**Tags:** canvas, tcanvas\
**Created:** [March 30, 2020, 3:19am UTC](https://community.thunkable.com/t/how-can-i-make-sprite-in-canvas-to-draggable-only-in-x-axis/543895 "2020-03-30T03:19:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shemanta.bhattarai18](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/shemanta.bhattarai18/32/60638_2.png) [@shemanta.bhattarai18](https://community.thunkable.com/u/shemanta.bhattarai18)\
**Post date:** [March 30, 2020, 3:19am UTC](https://community.thunkable.com/t/how-can-i-make-sprite-in-canvas-to-draggable-only-in-x-axis/543895/1 "2020-03-30T03:19:42Z")

</div>

I want my sprite to be dragged only in x axis where it is set. When i set it to draggable, i can drag it any where in a screen. But i want to drag it only from left to right and right to left but not up and down.

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [July 14, 2020, 10:39am UTC](https://community.thunkable.com/t/how-can-i-make-sprite-in-canvas-to-draggable-only-in-x-axis/543895/2 "2020-07-14T10:39:39Z")

</div>

Hey @shemanta.bhattarai18 ,

When you touch the sprite, save the y value in a variable and use this as a constant to keep the vertical position the same.

Let me know whether or not that helps.

---

<div class="post-metadata">

**Author:** ![scrivnerj](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@scrivnerj](https://community.thunkable.com/u/scrivnerj)\
**Post date:** [December 22, 2020, 2:46pm UTC](https://community.thunkable.com/t/how-can-i-make-sprite-in-canvas-to-draggable-only-in-x-axis/543895/3 "2020-12-22T14:46:04Z")

</div>

@domhnallohanlon This logic makes sense but I don’t see the blocks available to reference the y value while dragging it. I am another App Inventor convert…so, I’m sure my eyes are just looking for the wrong blocks. But I’m at a loss. I want to be able to drag a sprite horizontally only…as in a Pong like game.

---

<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, 11:30am UTC](https://community.thunkable.com/t/how-can-i-make-sprite-in-canvas-to-draggable-only-in-x-axis/543895/4 "2024-11-08T11:30:01Z")

</div>


