Discuss Scratch

Peach2555
Scratcher
4 posts

How can I calculate the sprite width and height?

How can I calculate the sprite width and height? even if the sprite is not in the center of the costume editing? (The unit is pixels.)
Intelligent684
Scratcher
100+ posts

How can I calculate the sprite width and height?

Can you elaborate a little bit more? maybe give some more information and send the link to the project.
awesome-llama
Scratcher
1000+ posts

How can I calculate the sprite width and height?

The costume editor says how large the sprite is, in the costume list.

Are you asking how to find it programmatically, i.e. using scratch blocks?
You can use the touching blocks to move the sprite towards the edges of the stage (or another sprite). Do it for all 4 sides, subtract the differences for both axes.
Malicondi
Scratcher
1000+ posts

How can I calculate the sprite width and height?

awesome-llama wrote:

The costume editor says how large the sprite is, in the costume list.

Are you asking how to find it programmatically, i.e. using scratch blocks?
You can use the touching blocks to move the sprite towards the edges of the stage (or another sprite). Do it for all 4 sides, subtract the differences for both axes.
to add onto this post, you can use this script below to calculate the width and height:
define find width and height
go to x: (0) y: (0)
set x to (-9999)
repeat until <not<touching [edge v]?>>
change x by (1)
end
set [i v] to ((x position) + (240))
set x to (9999)
repeat until <not<touching [edge v]?>>
change x by (-1)
end
set [width v] to (((i) + (240)) - (x position))
go to x: (0) y: (0)
set y to (-9999)
repeat until <not<touching [edge v]?>>
change y by (1)
end
set [i v] to ((y position) + (180))
set y to (9999)
repeat until <not<touching [edge v]?>>
change y by (-1)
end
set [height v] to (((i) + (180)) - (y position))
This finds the difference in how far off the screen both sides of the costume is, hope this helps!
AffanShaikh2021
Scratcher
15 posts

How can I calculate the sprite width and height?

Is there a way I can find the whole stage's width and height? For example, if someone happened to be running the project in TurboWarp, with a custom stage size, is there a way I could find the size of the stage?
cheddargirl
Scratch Team
1000+ posts

How can I calculate the sprite width and height?

AffanShaikh2021 wrote:

Is there a way I can find the whole stage's width and height? For example, if someone happened to be running the project in TurboWarp, with a custom stage size, is there a way I could find the size of the stage?
This is unfortunately an old thread you had posted in, and unfortunately your question is related to a non-Scratch service.

You may have better luck posting a separate thread in the Advanced Topics forums, where modifications to the Scratch software, such as TurboWarp, are discussed.

Powered by DjangoBB