Getpos

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

1 Like

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

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

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?

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

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

1 Like

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.

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)

1 Like

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