Get calculated width/height block

What exactly does the Get Calculated Height or Width of element block give you? I can’t figure it out and not finding any info in searches. It gives a number with decimals… for example… a row that is 50% of screen which is 320px, returns a value of 89.66666412353516

Anybody can clarify??

1 Like

There doesn’t seem to be anything in docs, though I’ve only noticed this feature lately.

This might be of help to understanding this.

I believe web and mobile app development terms go hand in hand. Eg. Padding and margin both mean the same in web and app development.

My guess is that the link above may roughly/correctly explain the computed height/width block. But I’m sure a more knowledged member of the community will have an answer here for us. :slight_smile:

These blocks return the client dimensions of the screen area. For example, the screen resolution of my device is 360 x 780, and blocks will return 360 x 711, because at the top and bottom of the screen there are system panels that reduce the height available for the app.

3 Likes

Hey man, thanks for trying to help me figure this out. I’m still not clear after checking out that link. Still doesn’t make sense to me, at least according to the numbers I posted…

So how come it’s giving me a value of 89.66666412353516 for 320px?

I think I have a workaround.
Use 2 sprites to calculate the width and the height using a while loop and the edge reached event block.
Then you can use your variables to get the actual height and width of the canvas.

1 Like

Can you explain to me what this does?

An you post a screenshot of the results?! Great work!

Could you also post a share link of just that screen?

So I started out both sprites in the top left corner.
The sprite then moves 1 pixel to the right and records how many pixels it moves (variable canvasHeight and canvasWidth) until it hits the edge (That is what the while loop does, it stops doing this in the collides with edge event.)
While loops keep working until the statement changes (which happens when an edge is hit)

I did the same for the height.
For testing purposes, I spit the values on the label to see if it works.
In the test screen, the canvas height is 380 and the width is 227. I’m going to use those values to move the mushroom around the canvas randomly.

Looks like it works because I get different values on my iPhone screen.

3 Likes

Wow, that is so cool!! Thanks for sharing this!!

1 Like