Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Finding corner of a rotatated sprite
- Him_is_bob
-
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
-
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
I think this will work, i haven't tested it lol
Last edited by RoboRo21 (Feb. 13, 2025 20:10:28)
- Him_is_bob
-
75 posts
Finding corner of a rotatated sprite
i mean in code so i can find where it is located on the stage 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?
- RoboRo21
-
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
-
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
The ball goes to the sprite 1 corner
Last edited by RoboRo21 (Feb. 13, 2025 20:31:17)
- Him_is_bob
-
75 posts
Finding corner of a rotatated sprite
https://scratch-mit-edu.ezproxyberklee.flo.org/projects/1133764063/Thx So much! I did it:
The ball goes to the sprite 1 corner
- RoboRo21
-
49 posts
Finding corner of a rotatated sprite
no problem! It was a fun challenge lol
- Discussion Forums
- » Help with Scripts
-
» Finding corner of a rotatated sprite