# Sprite positioning when canvas loads

**URL:** https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554
**Category:** Questions about Thunkable X
**Created:** [June 5, 2021, 8:03pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554 "2021-06-05T20:03:55Z")
**Posts on this page:** 16
**Page:** 1

<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 5, 2021, 8:03pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/1 "2021-06-05T20:03:55Z")

</div>

I’m having a hard time making heads or tails of this.

I know that sprite x/y positions are relative to the sprite’s top-left corner (I’ve suggested that they be changed to the sprite’s center but that’s another conversation…).

What I don’t understand is that when I position a canvas so that it’s top-left corner (0,0) touches a button’s bottom-right corner and then – with only the blocks below added to the sprite – I preview the project, the sprite re-sizes itself and moves and ends up in a place that definitely isn’t x=0, y=0.

This video shows what happens when I press the preview button:

_Ignore the three game pieces above the button & canvas area._

![canvas bug](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0fae4cfdd61d9d55aec0a463b23f4a19ca3a834f.gif)

**Canvas:**

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/1/01df33e00d3e5603d97c85158f5bb4d591a08ab3.png)

**Blocks:**

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/f/1fc0cc63430639667edb039f0fd4097bae3956d3.png)

**Completed Preview:**

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/f/5fcba2f676aa75b798638270336086fb3442a0b4.png)

---

<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 5, 2021, 8:09pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/2 "2021-06-05T20:09:54Z")

</div>

Or how about this one… both sprites are 50 width & height.

**Blocks:**

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/e/4eaa6eedfeab4c898bfbfc87c1633a7b7ab5dc2b.png)

**Preview #1:**

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/e/2e00e4f5d869d404daf70e2560421cb6ddcb24c8.png)

**Preview #2:**

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/2/e2ad5dc4e902f56acbb5c8c1836058387c7eacb7.png)

???

---

<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 5, 2021, 8:14pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/3 "2021-06-05T20:14:28Z")

</div>

## Project Link

> **[Thunkable](https://x.thunkable.com/copy/e21ce477cdc205dcc9ecb63462ca4293)**

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [June 6, 2021, 2:00pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/4 "2021-06-06T14:00:33Z")

</div>

Sprites use the midpoint for coords. If you try to put them half off the canvas, strange things happen.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [June 6, 2021, 3:14pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/5 "2021-06-06T15:14:44Z")

</div>

I tested the project @tatiang sent and set the x and y to 25 as mid-point and it behaved as expected. I set the other sprite to 50 and it also showed expected outcome.

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/f/1f64179b899ac2f84f0881b1c0e2ffe844a5ddd4.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/1/a1bf67a5174336c40760091def9b42f3720b9b04.png)

---

<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 6, 2021, 4:13pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/6 "2021-06-06T16:13:33Z")

</div>

That’s good to know!

@muneer thanks for confirming that. I actually did find the same to be true. My sprites still resize and move which is weird but at least they end up in the right spots using your values:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/2/a2a8a2dc43a2b005322f27a1ffe7d36a74942a8d.png)

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [June 6, 2021, 4:18pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/7 "2021-06-06T16:18:40Z")

</div>

Do your sprites resize or does your canvas? I’ve seen the canvas/stage do a resize, but not sure I’ve seen sprites do it.

---

<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 6, 2021, 4:29pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/8 "2021-06-06T16:29:41Z")

</div>

I’m not sure. If you notice the gif in my first post, that’s what I’m referring to.

It happens even in the Design tab without previewing and it happens with a brand new project if I just drop a canvas component onto a screen.

---

<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 6, 2021, 4:44pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/9 "2021-06-06T16:44:02Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/e/be4d8b21c8cb1844f598c0ff5bca88623f83475e.gif)

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [June 6, 2021, 5:08pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/10 "2021-06-06T17:08:56Z")

</div>

> [@tatiang](#):
>
> I’m not sure. If you notice the gif in my first post, that’s what I’m referring to.
> 
> It happens even in the Design tab without previewing and it happens with a brand new project if I just drop a canvas component onto a screen.

That’s your canvas resizing - if you put a border on it, you can see it. It’s not really a sprites problem.

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [June 6, 2021, 5:12pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/11 "2021-06-06T17:12:57Z")

</div>

> [@tatiang](#):
>
> 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.

Try this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/b/fb87a4ea3ac38e2e4e030f008e68ad890c6dc2bb.png)

(Do both sprites this way.)

---

<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 7, 2021, 4:19am UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/12 "2021-06-07T04:19:04Z")

</div>

How do you do that? I’m using the drag-and-drop interface and the only thing I see is “frame color.” When I set that, it seems like it might show up in the Design tab but when I preview it, the stage doesn’t have a border.

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [June 7, 2021, 7:38am UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/13 "2021-06-07T07:38:57Z")

</div>

Sorry, I meant frame. 🙂

---

<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 7, 2021, 7:55am UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/14 "2021-06-07T07:55:29Z")

</div>

Good idea but the sprites still move. Less/slower but there’s still movement rather than snapping to a position.

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [June 7, 2021, 10:32am UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/15 "2021-06-07T10:32:12Z")

</div>

> Ah. When I tested on web, it worked.

---

<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:22pm UTC](https://community.thunkable.com/t/sprite-positioning-when-canvas-loads/1327554/16 "2024-11-08T13:22:05Z")

</div>


