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


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.


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

1 Like