Discuss Scratch

Him_is_bob
Scratcher
75 posts

Finding corner of a rotatated sprite

If we already know the width and height of our sprite how can we move something to the relative corner of the sprite even if it is rotated
RoboRo21
Scratcher
49 posts

Finding corner of a rotatated sprite

you need to find the distance from the sprite to the corner by using the distance to block. Then find the angle from the centre to the corner by doing the inverse tan of change in y divided by the change in x. to find the new x position of the rotated corner, use the distance and multiply it by the cos of the old and calculated earlier + the angle its rotated. do the same for the y but use sin instead.

I think this will work, i haven't tested it lol

Last edited by RoboRo21 (Feb. 13, 2025 20:10:28)

Him_is_bob
Scratcher
75 posts

Finding corner of a rotatated sprite

RoboRo21 wrote:

cant you just go to the centre of the sprite, then move to the right/left side of it then going up/down by half the height?
i mean in code so i can find where it is located on the stage
RoboRo21
Scratcher
49 posts

Finding corner of a rotatated sprite

yeah sorry, realised after i posted that, i updated my original answer lol. Im trying to make an example project

Last edited by RoboRo21 (Feb. 13, 2025 20:27:24)

RoboRo21
Scratcher
49 posts

Finding corner of a rotatated sprite

I did it: https://scratch-mit-edu.ezproxyberklee.flo.org/projects/1133764063/
The ball goes to the sprite 1 corner

Last edited by RoboRo21 (Feb. 13, 2025 20:31:17)

Him_is_bob
Scratcher
75 posts

Finding corner of a rotatated sprite

RoboRo21 wrote:

I did it: https://scratch-mit-edu.ezproxyberklee.flo.org/projects/1133764063/
The ball goes to the sprite 1 corner
Thx So much!
RoboRo21
Scratcher
49 posts

Finding corner of a rotatated sprite

no problem! It was a fun challenge lol

Powered by DjangoBB