# Getpos

**URL:** <https://forum.makecode.com/t/getpos/1922>\
**Category:** Arcade\
**Created:** [May 2, 2020, 1:07pm UTC](https://forum.makecode.com/t/getpos/1922 "2020-05-02T13:07:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![otorp2](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/otorp2/32/940_2.png) [@otorp2](https://forum.makecode.com/u/otorp2)\
**Post date:** [May 2, 2020, 1:07pm UTC](https://forum.makecode.com/t/getpos/1922/1 "2020-05-02T13:07:40Z")

</div>

Wonderful stuff here!  
Is there a getposition(x,y) if not, it would be convenient  
thanks!  
otorp

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 3, 2020, 2:05pm UTC](https://forum.makecode.com/t/getpos/1922/2 "2020-05-03T14:05:38Z")

</div>

What do you mean my `getposition(x, y)`?  
Like getting the position of a sprite?

---

<div class="post-metadata">

**Author:** ![otorp2](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/otorp2/32/940_2.png) [@otorp2](https://forum.makecode.com/u/otorp2)\
**Post date:** [May 3, 2020, 3:29pm UTC](https://forum.makecode.com/t/getpos/1922/3 "2020-05-03T15:29:33Z")

</div>

Yeah - I see set setPosition(x,y)

I can print mySprite.x mySprite.y but mabe would be nice to have a getPosition(x,y) if there isn’t currently one

otorp

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 3, 2020, 3:44pm UTC](https://forum.makecode.com/t/getpos/1922/4 "2020-05-03T15:44:55Z")

</div>

I don’t think there is one, at least in blocks.  
Maybe there is one in TypeScript, but you would have to ask the moderator to make sure.  
Maybe you could find it in the [Arcade docs?](https://arcade.makecode.com/docs)

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [May 3, 2020, 4:46pm UTC](https://forum.makecode.com/t/getpos/1922/5 "2020-05-03T16:46:18Z")

</div>

You can do mySprite.x and mySprite.y to read the position of a sprite

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 4, 2020, 1:22am UTC](https://forum.makecode.com/t/getpos/1922/6 "2020-05-04T01:22:09Z")

</div>

Yeah, that’s true, but @otorp2 wants to combine them into a single reading. Instead of having to combine the to variable calls.

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 3, 2020, 10:51am UTC](https://forum.makecode.com/t/getpos/1922/7 "2020-10-03T10:51:30Z")

</div>

I agree with @UnsignedArduino and understand what @otorp2 is trying to say. Let’s say there is a class called _Point_, which represents the (x,y) position on the screen.

You could then have a block function such as:

set (sprite) position to (point)

When you click on (point), you are presented with the editor for picking coordinates.

I have written a function to do this, but I am new to Arcade and still need to figure out how to make extensions. Also I would want the function to appear under the Sprites section (like an extension function in C#). This is probably possible, I just need to read more of the documentation of block editing.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [October 4, 2020, 9:47pm UTC](https://forum.makecode.com/t/getpos/1922/8 "2020-10-04T21:47:52Z")

</div>

> [@cosmoscowboy](#):
>
> Also I would want the function to appear under the Sprites section (like an extension function in C#)

You can create an exported function in the same namespaces as the toolbox category you want to add it in. In your case, probably `sprites`. Alternatively, you can use the `blockNamespace` comment metadata override the bloc toolbox (those are the comments in //% comments line)

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 4, 2020, 10:06pm UTC](https://forum.makecode.com/t/getpos/1922/9 "2020-10-04T22:06:25Z")

</div>

Thanks @peli , when I get around to developing extensions I might hit you up on the topic.
