Setting sprite x and y pivot point programatically

Sometimes I want to adjust the sprite pivot a little bit after setting it manually so looking to see if there's a method of doing this

Is that the rotation center? The [scratchblocks]set [ v] to [/scratchblocks] block has rotation x and rotation y in the my submenu.

That certainly helps me :slight_smile:

Going to have a play around and see if I can come up with a custom block to easily adjust it

I've had a read of the manual and found this info

image

but they aren't returning the sprite's internal centers - I have to subtract the sprite's position to get at what I'd call the center value

image

image

Is this a bug? @jens @bh

I'm not sure I'm understanding correctly, but there's also [scratchblocks] (my [ rotation x v]::sensing) [/scratchblocks].

no, you're mixing up absolute and relative values. Snap's coordinates are all absolute.

Ok- understood - maybe Brian can make that explicit in the manual

image

the reason for absolute coordinates instead of - the usual - relative ones is so that you can position sprites as sprites-as-parts by referring to other sprites / parts, and then align their geometric properties. For example you can place a planet-sprite somewhere on the stage and then set its rotation center to be at the center of the sun-sprite. It's much easier to create compositions of sprites that way than treating every sprite as its own coordinate system. Of course, every "real" computer scientist and every mathematician will disagree, but hey, it's our language :slight_smile:

(and yes, In GP I've done it the other way, which I now consider to have been a mistake)

Well, after learning a lot about Snap! co-ordinate system, the answer to adjusting a sprites pivot point is to use these blocks

image

Thanks everyone

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.