Problem with local sky display

Hello everyone,

I’m having a issue with putting an sky image on the background. I’ve typed in the correct code of

local sky = display.newRect(centerX, centerY, screenWidth, screenHeight)

What I should have is a white background that fills the entire screen. All I get is the bottom right corner of the screen filled as if the background has been broken into 4 separate rectangles. When I try to add in a fill color the white rectangle disappears.

local sky = display.newRect(centerX, centerY, screenWidth, screenHeight)
sky:setFillColor(0,0,1)

Again my rectangle disappears instead of filling the box in with a color.

Please let me know what I can do to fix this. Thank you.

Hello,

Can you provide a bit more code? What are centerX/Y and screenWidth/Height?

Is this rectangle in a display group?

Albert

Try this

local sky = display.newRect( display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight ) sky:setFillColor( 0,0,1 )

Hi,
 
This worked perfectly fine for me, the entire view was filled with a blue rectangle.
 
Perhaps you have changed the default anchor points? Do you have code somewhere in the project like this?

display.setDefault(“anchorX”, 0);
display.setDefault(“anchorY”, 0);
 
That would place the anchor at the top-left corner, and would offset your rectangle to the bottom corner of the screen.

Try adding:

sky.anchorX = 0.5;

sky.anchorY = 0.5;

Since we can’t see the values of centerX and centerY, if they are 0, it would result in the bottom-right quadrant showing.

Rob

Hello,

Can you provide a bit more code? What are centerX/Y and screenWidth/Height?

Is this rectangle in a display group?

Albert

Try this

local sky = display.newRect( display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight ) sky:setFillColor( 0,0,1 )

Hi,
 
This worked perfectly fine for me, the entire view was filled with a blue rectangle.
 
Perhaps you have changed the default anchor points? Do you have code somewhere in the project like this?

display.setDefault(“anchorX”, 0);
display.setDefault(“anchorY”, 0);
 
That would place the anchor at the top-left corner, and would offset your rectangle to the bottom corner of the screen.

Try adding:

sky.anchorX = 0.5;

sky.anchorY = 0.5;

Since we can’t see the values of centerX and centerY, if they are 0, it would result in the bottom-right quadrant showing.

Rob