Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I get 'original' x y postion of off centered sprite
- kbrakkee
-
Scratcher
11 posts
How do I get 'original' x y postion of off centered sprite
I have a sprite that is not located in the center (so the cross does not hit the center cross in the costume view).
How can I get the position of it?
To illustrate I have made this:
https://scratch.mit.edu/projects/997821579/
As you can see both sprites have coordinates x:0 and Y:0 while sprite2 is actually on a different location
How can I get the position of it?
To illustrate I have made this:
https://scratch.mit.edu/projects/997821579/
As you can see both sprites have coordinates x:0 and Y:0 while sprite2 is actually on a different location
- MineTurte
-
Scratcher
1000+ posts
How do I get 'original' x y postion of off centered sprite
I have a sprite that is not located in the center (so the cross does not hit the center cross in the costume view).If the sprite isn't centered in the costume editor it won't appear to be in the same location. If that is what you mean.
How can I get the position of it?
To illustrate I have made this:
https://scratch.mit.edu/projects/997821579/
As you can see both sprites have coordinates x:0 and Y:0 while sprite2 is actually on a different location
- kbrakkee
-
Scratcher
11 posts
How do I get 'original' x y postion of off centered sprite
I have a sprite that is not located in the center (so the cross does not hit the center cross in the costume view).If the sprite isn't centered in the costume editor it won't appear to be in the same location. If that is what you mean.
How can I get the position of it?
To illustrate I have made this:
https://scratch.mit.edu/projects/997821579/
As you can see both sprites have coordinates x:0 and Y:0 while sprite2 is actually on a different location
@MineTurtle, No that is not what I mean. I want to know the exact location of Sprite2 to its center, in other words: how should I alter it's x- and y-position to get it on exact the same location as sprite1
- The_wolf_KA
-
Scratcher
100+ posts
How do I get 'original' x y postion of off centered sprite
You could manually put in inputs until the sprite becomes centered.
It might take awhile though-
Also, why do you intend to make the sprite off center?
It might take awhile though-
Also, why do you intend to make the sprite off center?
- happyha8
-
Scratcher
500+ posts
How do I get 'original' x y postion of off centered sprite
Just make them be in the same place and center them on the cross
- SpyCoderTest
-
Scratcher
57 posts
How do I get 'original' x y postion of off centered sprite
I don't get what you mean.I have a sprite that is not located in the center (so the cross does not hit the center cross in the costume view).If the sprite isn't centered in the costume editor it won't appear to be in the same location. If that is what you mean.
How can I get the position of it?
To illustrate I have made this:
https://scratch.mit.edu/projects/997821579/
As you can see both sprites have coordinates x:0 and Y:0 while sprite2 is actually on a different location
@MineTurtle, No that is not what I mean. I want to know the exact location of Sprite2 to its center, in other words: how should I alter it's x- and y-position to get it on exact the same location as sprite1
Both sprite are at 0,0… they are already on the same spot.
Do you want the positions to line up? Or the costumes?
- kbrakkee
-
Scratcher
11 posts
How do I get 'original' x y postion of off centered sprite
Both sprite are at 0,0… they are already on the same spot.
Do you want the positions to line up? Or the costumes?
Please click https://scratch.mit.edu/projects/997821579/
and you can see they are not on the same location (because of the different center).
What should the position of sprite2 be to get them on exactly the same spot.
- Norse7
-
Scratcher
100+ posts
How do I get 'original' x y postion of off centered sprite
You could try this script on Sprite2 to center it:
Make the Center custom block Run Without Screen Refresh.
I got it from this tutorial by @griffpatch.
define Center
go to x (-9999) y (0)
repeat until <not <touching [edge v] ?>>
change x by (1)
end
set y to (-9999)
repeat until <not <touching [edge v] ?>>
change y by (1)
end
change x by (240)
change y by (180)
Make the Center custom block Run Without Screen Refresh.
I got it from this tutorial by @griffpatch.
- ItBeJC
-
Scratcher
1000+ posts
How do I get 'original' x y postion of off centered sprite
-Redacted
Dang I really thought that was gonna work, but it won't after further consideration.
Dang I really thought that was gonna work, but it won't after further consideration.
Last edited by ItBeJC (April 10, 2024 02:03:50)
- Norse7
-
Scratcher
100+ posts
How do I get 'original' x y postion of off centered sprite
-RedactedYeah, I'm not quite sure how to make the X position not interfere with the X in that script because I'm using
Dang I really thought that was gonna work, but it won't after further consideration.
<touching [edge v] ?>.
- SpyCoderX
-
Scratcher
1000+ posts
How do I get 'original' x y postion of off centered sprite
You could try this script on Sprite2 to center it:Slight modifications should make this work (untested though):define Center
go to x (-9999) y (0)
repeat until <not <touching [edge v] ?>>
change x by (1)
end
set y to (-9999)
repeat until <not <touching [edge v] ?>>
change y by (1)
end
change x by (240)
change y by (180)
Make the Center custom block Run Without Screen Refresh.
I got it from this tutorial by @griffpatch.
define Center
go to x ((-1)/(0)) y (0)
repeat until <not <touching [edge v] ?>>
change x by (1)
end
set y to ((-1)/(0))
repeat until <not <touching [edge v] ?>>
change y by (1)
end
change x by (240)
change y by (180)
set [x1 v] to (x position)
set [y1 v] to (y position)
go to x ((1)/(0)) y (0)
repeat until <not <touching [edge v] ?>>
change x by (-1)
end
set y to ((1)/(0))
repeat until <not <touching [edge v] ?>>
change y by (-1)
end
change x by (240)
change y by (180)
go to x: (((x1)+(x position))/(2)) y: (((y1)+(y position))/(2))
Hope this helps!
- Discussion Forums
- » Help with Scripts
-
» How do I get 'original' x y postion of off centered sprite