Canvas get width returns "fill container" instead of a number

Hello,

I am using the canvas and want to get the width of it to determine where to randomly place a sprite. However, the get width method returns the string “fill container” when I run it on my phone. I would assume it should return the numeric value of the size of the canvas?
I display the value in my button text for debugging purposes.

Thanks,
Ann

To solve your problem of the absolute size of the canvas must be set to the size of the Stage.

1 Like

I did exactly what you mention, but the result is not my expectation
image

1 Like

You are replying on a post written 2 years ago. If you want to get attention, create a new post and explain your problem in a clear way and provide screenshots of design and code so others can respond to it.

1 Like

I’ve got some ideas to share but will wait for the new post. :slight_smile:

3 Likes