Image sizes clarifications

Hello,

I am new to corona, so I am watching video tutorials and in a couple of them they entered the following code:

local background = displaynewRect (0, 0, 320, 480) ;

When they launched their simulator, all of their device’ screen was filled with the background. However, only half of my screen was filled. Hence, I tried to double the width and height of the shape and it worked.

My question is the following: Is this due to the retina display? Is it set by default? Is there a way to remove the retina display in the simulator to avoid this “problem”?

Thank you in advance!

Read http://docs.coronalabs.com/guide/basics/configSettings/ to understand how Corona content scaling works.

Daniel

Hello @raffi_michali,

In the legacy 1.0 graphics engine (which the video tutorial you’re watching might be using), vector objects like newRect() were created with their top-left point at the first two parameters (0,0), and the object extended down and right to fill the screen. In the current 2.0 graphics engine, objects are created around their center point… so if you’re seeing the rectangle occupy only the top-left 1/4 of the screen, then it’s because 3/4 of the rectangle resides off screen. Just reposition it to the center of the content area and it should be placed correctly.

Best regards,

Brent

Thank you very much for your replies! 

If 3/4 of the rectangle resides off screen, is there a “formula” that i can apply so that the code using the 1.0 graphics engine work with the 2.0 graphics engine by any chance?

Hi @raffi_michali,

You can actually run things in V1 Compatibility mode, as outlined in the link below:

http://docs.coronalabs.com/daily/guide/graphics/migration_v1.html

However, we strongly suggest that you design and/or modify all existing code to work under the Graphics 2.0 engine.

http://docs.coronalabs.com/daily/guide/graphics/migration.html

Take care,

Brent

Read http://docs.coronalabs.com/guide/basics/configSettings/ to understand how Corona content scaling works.

Daniel

Hello @raffi_michali,

In the legacy 1.0 graphics engine (which the video tutorial you’re watching might be using), vector objects like newRect() were created with their top-left point at the first two parameters (0,0), and the object extended down and right to fill the screen. In the current 2.0 graphics engine, objects are created around their center point… so if you’re seeing the rectangle occupy only the top-left 1/4 of the screen, then it’s because 3/4 of the rectangle resides off screen. Just reposition it to the center of the content area and it should be placed correctly.

Best regards,

Brent

Thank you very much for your replies! 

If 3/4 of the rectangle resides off screen, is there a “formula” that i can apply so that the code using the 1.0 graphics engine work with the 2.0 graphics engine by any chance?

Hi @raffi_michali,

You can actually run things in V1 Compatibility mode, as outlined in the link below:

http://docs.coronalabs.com/daily/guide/graphics/migration_v1.html

However, we strongly suggest that you design and/or modify all existing code to work under the Graphics 2.0 engine.

http://docs.coronalabs.com/daily/guide/graphics/migration.html

Take care,

Brent