understanding "boundaries" - please assist

Hello -

I found some sample code on the internet, and I would like someone to help me understand it so i can use it appropriately in my app that I am building.

local bottomWall = display.newRect (0,0,0,0) local leftWall = display.newRect (0,0,0,0) local rightWall = display.newRect (0,0,0,0) local topWall = display.newRect (0,0,0,0)

My app’s screen resolution is 1920x1080 (Landscape) - So I am wondering if someone can edit that code to the correct values (with comments please)?

And, I was also wondering, for the “width” and “height” parameters, - Does the registration point for newly created rectangle start on the left or in the center of the rectangle? So if I put for the width 300, would it be 150 to the left and 150 to the right (reg center)? Or would it be 300 pixels to the right (reg left)?

Corona has been a bit of a learning curve for me, but Im slowly getting it! lol. Thanks in advance.  :lol:

First off, those aren’t valid rectangles. display.newRect() uses four arguments which define the size of the object. By specifying zero, that’s how big the object is. You should treat it as x,y, width, height, although semantically it’s x1,y1,x2,y2…

Second, you really don’t want to use pixels when you don’t have to, as device resolution varies a lot. Zero is fine as the top left, but for the bottom right you need display.actualContentWidth and display.actualContentHeight.

I vaguely remember most display objects being created with the top left and then immediately getting a central refpoint after, although in practice I just always manually set .anchorX/.anchorY and .x/.y after the fact…

Okay, I tried a few thing after taking into account what you said here and it looks like I got things working, now. Thanks! :slight_smile:

First off, those aren’t valid rectangles. display.newRect() uses four arguments which define the size of the object. By specifying zero, that’s how big the object is. You should treat it as x,y, width, height, although semantically it’s x1,y1,x2,y2…

Second, you really don’t want to use pixels when you don’t have to, as device resolution varies a lot. Zero is fine as the top left, but for the bottom right you need display.actualContentWidth and display.actualContentHeight.

I vaguely remember most display objects being created with the top left and then immediately getting a central refpoint after, although in practice I just always manually set .anchorX/.anchorY and .x/.y after the fact…

Okay, I tried a few thing after taking into account what you said here and it looks like I got things working, now. Thanks! :slight_smile: