Graphics not displaying correctly

Hi guys, I’ve got a weird error that is occurring with a handful of the graphics in my game.

EDIT: The graphics are not being displayed at their true dimensions.  For some reason they are being re-sized.

[lua]

road = display.newImage(“Road_Back_Cliff.png”)

road.x = display.contentWidth/2

road.x = display.contentHeight/2

background = display.newImage(“background1.png”)

background.x = display.contentWidth/2

background.y = display.contentHeight/2

print(display.contentWidth)

print(road.width)

print(background.width)

[/lua]

terminal:

1536 – screen width

1024 – road width

768 – background width

However, those aren’t the actual dimensions of those graphics.

“Road_Back_Cliff.png”

The actual image dimensions 1536x599

The displayed dimensions 1024x399

If I scale this image by 1.5 it displays at the size it is suppose to be when it is not scaled.

“background1.png”

The actual image dimensions 1536x2048

The displayed image dimensions 768x1024

If I scale this image by 2 it displays at the size it is suppose to be when it is not scaled.

I have no idea why this is happening.  For the images it is happening to I can easily fix it by scaling them.

This problem does not show up on the simulator for Windows.

The mac I’m using does not have the latest os could that be the problem?

Any ideas?  Thanks

Whats the error? You can try this code.

road = display.newImageRect ("Road\_Back\_Cliff.png", display.actualContentWidth, display.actualContentHeight ) road.x = display.contentCenterX road.x = display.contentCenterY background = display.newImageRect( "background1.png", display.actualContentWidth, display.actualContentHeight ) background.x = display.contentCenterX background.y = display.contentCenterY

–SonicX278

The images aren’t being displayed at the correct dimensions.

The road image for example is actually 1536x599, however the image is being displayed at 1024x399.

The background image is actually 1536x2014, however the image is being displayed at 768x1024.

I edit the description hope that clarifies the problem.

Can you post your config.lua please?

Rob

[lua]

–config.lua file

application =
{
    content =
    {

        width = 1536,–aspectRatio>1.5 and 320 or 480/aspectRatio,
        height = 2048,–aspectRatio<1.5 and 480 or 320*aspectRatio,
        scale = “letterbox”,
   yAlign = “top”,
        fps = 60
    }
}

[/lua]

Since you know the desired width and height of the images, why don’t you use display.newImageRect():

road = display.newImageRect (“Road_Back_Cliff.png”, 1536, 599 )

Rob

Why don’t you use the original config?.. I use it for everything and it works like a charm.

–SonicX278

Thanks for the suggestion guys but no luck.

Rob, even when I do what you suggested the image still has to be scaled up the amounts specified above.

SonicX278, I’m not sure what the original config.lua file is but I don’t see why the config.lua file I used wouldn’t work.

This is a strange error guys there are 145 graphics and sprite sheets and only 4 of them have this error.  Maybe they got corrupted in some way I’ll render them later and report back otherwise I will just plan on scaling them up the needed amounts.

Corrupt images could very well be the issue. Is your app landscape or portrait oriented?

Whats the error? You can try this code.

road = display.newImageRect ("Road\_Back\_Cliff.png", display.actualContentWidth, display.actualContentHeight ) road.x = display.contentCenterX road.x = display.contentCenterY background = display.newImageRect( "background1.png", display.actualContentWidth, display.actualContentHeight ) background.x = display.contentCenterX background.y = display.contentCenterY

–SonicX278

The images aren’t being displayed at the correct dimensions.

The road image for example is actually 1536x599, however the image is being displayed at 1024x399.

The background image is actually 1536x2014, however the image is being displayed at 768x1024.

I edit the description hope that clarifies the problem.

Can you post your config.lua please?

Rob

[lua]

–config.lua file

application =
{
    content =
    {

        width = 1536,–aspectRatio>1.5 and 320 or 480/aspectRatio,
        height = 2048,–aspectRatio<1.5 and 480 or 320*aspectRatio,
        scale = “letterbox”,
   yAlign = “top”,
        fps = 60
    }
}

[/lua]

Since you know the desired width and height of the images, why don’t you use display.newImageRect():

road = display.newImageRect (“Road_Back_Cliff.png”, 1536, 599 )

Rob

Why don’t you use the original config?.. I use it for everything and it works like a charm.

–SonicX278

Thanks for the suggestion guys but no luck.

Rob, even when I do what you suggested the image still has to be scaled up the amounts specified above.

SonicX278, I’m not sure what the original config.lua file is but I don’t see why the config.lua file I used wouldn’t work.

This is a strange error guys there are 145 graphics and sprite sheets and only 4 of them have this error.  Maybe they got corrupted in some way I’ll render them later and report back otherwise I will just plan on scaling them up the needed amounts.

Corrupt images could very well be the issue. Is your app landscape or portrait oriented?