Pardon the mess, Play My Code is in beta!

READY TO PLAY?
CLICK TO LOG IN!

sign up - lost password

getScreenWidth

getScreenWidth()

Returns the width of the screen, in pixels.

This value will always be a fixed value, regardless of if the screen has been scaled or not.

// Draws a gradient across the screen
fill( :white )

width = getScreenWidth()

setColor( :pink, 1 )
width.times() do |x|
    setAlpha( x / width )
    drawLine( x, 0, x, getScreenHeight() )
end

See Also