Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Having problems with Display.contentWidth, display.contentHeight
Started by qvindicator May 27 2018 03:47 PM

- - - - -
1 reply to this topic
problem lua display help corona game rectangle fill
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 1 posts
  • Corona SDK

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);

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. Attached File  Screenshot (16).png   17.31KB   0 downloads 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.

[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 389 posts
  • Corona SDK

Your problem is related with scale mode.



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.