Having problems with Display.contentWidth, display.contentHeight

Hello! I wanted to make a game for the iphone and my friend told me that Corona SDK is a good game engine to help you create games in lua. I am taking some tutorials on how to create games and on one tutorial they gave me this code:

display.setDefault("background", 255, 255, 255) local wall = display.newRect(display.contentWidth / 2, display.contentHeight / 2, display.contentWidth, display.contentHeight); wall:setFillColor(black)

For them, the code makes a black rectangle fill up the whole screen but for me, the white background is still showing with the black rectangle in front of it. I don’t know what to do and it is hard for me to figure out what to do because I am a beginner. Please make your answer easy to understand and don’t link me to a complicated post. I tried everything. I looked if it was just the device that did it so I tried it on every single other device but it still had the white lines. The device I am using is an iPhone 5 because that is the phone I use in real life. I also don’t know the proper section to post this in because I don’t use forums that much but since this is a lua problem I am guessing this belongs in the lua section.

Your problem is related with scale mode.

Try

local \_T   = display.screenOriginY local \_B   = display.viewableContentHeight - display.screenOriginY local \_L   = display.screenOriginX local \_R   = display.viewableContentWidth - display.screenOriginX local \_CX = display.contentCenterX local \_CY = display.contentCenterY local wall = display.newRect( \_CX, \_CY, \_R - \_L, \_B - \_T )

Read more about display.*

Read more about Content Scaling.

Note: From documentation

object:setFillColor(red, green, blue, alpha)

gray, red, green, blue, alpha (optional)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the fill color/tint.

Simply use numbers 0-1 instead of 0-255.

ldurniat

Your problem is related with scale mode.

Try

local \_T   = display.screenOriginY local \_B   = display.viewableContentHeight - display.screenOriginY local \_L   = display.screenOriginX local \_R   = display.viewableContentWidth - display.screenOriginX local \_CX = display.contentCenterX local \_CY = display.contentCenterY local wall = display.newRect( \_CX, \_CY, \_R - \_L, \_B - \_T )

Read more about display.*

Read more about Content Scaling.

Note: From documentation

object:setFillColor(red, green, blue, alpha)

gray, red, green, blue, alpha (optional)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the fill color/tint.

Simply use numbers 0-1 instead of 0-255.

ldurniat