Topic Information

Is there a simple way to detect the width and heigth of a sprite? by papipupepappa in Help With Scripts

Posts: 3

1: papipupepappa wrote at 4:12:32 PM 14/5/20204011607
I am a bit surprised that there are no reporter blocks for width and height in Scratch.

As a workaround I usually check the dimensions under the costume thumbnail and create local variables for width and height with those values that are set when initializing the sprite. But this is a bit tedious, so if there is a simple way of automatically detect the dimensions of a sprite (or actually the costume of a sprite), that would help a lot.

I guess it could be done by using a sprite that moves across the other sprites and detects their dimensions, but that sounds like even more work than manually entering the values, so that is not what I'm after.

Cheers!
2: Oumuamua wrote at 4:23:00 PM 14/5/20204011625
Yes there is a way, i saw a project by @griffpatch where he measured height with two horizontal lines one going down from up the screen until it touches sprite and the other going up from down , so distance between both lines…
The same for width.

I am not sure, but it is quite possible that the main purpose of @griffpatch was to calculate offsets for bad centered costumes.
3: papipupepappa wrote at 5:39:33 PM 14/5/20204011839

Oumuamua wrote:

Yes there is a way, i saw a project by @griffpatch where he measured height with two horizontal lines one going down from up the screen until it touches sprite and the other going up from down , so distance between both lines…
The same for width.

I couldn't find the project you refer to, but going through the projects by @griffpatch was a lot of fun nonetheless. Wow!

Thanks!