config.lua on Android

How do you actually position the green and white balls in your code? I can’t imagine that they’re purely “display.contentCenterX” and “display.contentCenterY” because they’re not aligned in the center (the green ball is definitely somewhere above the horizontal center).

Brent

This is cut and pasted from my code.  I do have to add + or - on either side of center of the X so that it will align in a row.

Below the ball code is the set up for the table.  I think the graphic for the table is not sizing correctly.  If the graphic for the table (picture) were larger it would align with the hidden bumpers with physics and would be placed under the target etc…’


–GAME BALL 1 BOTTOM ROW LEFT SIDE


ball1=display.newImage(“Images/ballFuryGreen.png”) 

ball1.x = display.contentCenterX-100; ball1.y = display.contentCenterY +100

sceneGroup:insert(ball1)

physics.addBody(ball1, ballBody)

ball1.id = “gameBall1”

ball1.type = “solid”

ball1.value = 10

ball1.count = -1

ball1.postCollision = ballCollisionAudio

ball1.linearDamping = 0.3 – simulates friction of felt

ball1.angularDamping = 2 – stops balls from spinning forever

ball1.isBullet = true – If true physics body always awake

ball1.active = true – Ball is set to active

ball1.bullet = false – force continuous collision detection, to stop really fast shots from passing through other balls


–TABLE TOP


local tableTop = display.newImage(“Images/borderYellowGreen2.png”)

tableTop:scale(0.98, 0.98)

tableTop.x = display.contentCenterX; tableTop.y = display.contentCenterY

sceneGroup:insert(tableTop)

Hi Lori,

I notice you’re not using dynamic image selection. You really should be using that if you’re deploying to devices with varying aspect ratios and resolutions (which you are doing).

Brent

OK.  What is that?

It’s basically using “display.newImage Rect ()” which tells Corona to use the proper-resolution image depending on the resolution of the device. That ensures that you get sharp, precise images on a wide array of devices without taking up excessive texture memory on older/smaller devices which don’t necessarily need hi-res images.

Still, that might not be the issue here. Can you try just putting a vector rectangle in the center of the scene, tinted transparent red, and test out different devices?

[lua]

local testRect = display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY, 200, 300 )

testRect:setFillColor( 1, 0, 0, 0.5 )

[/lua]

Brent

The vector square is in the center on both of the devices.

I’m having trouble with the picture again.  I can’t figure out how to get it it  into my media to attach.  I’m not sure what i did to get those others two in my media.

Thanks

Lori

OK, now try to set the vector square to the same location as the ball. Does it reside centered around the ball?

Used the Y location of the cue ball and did it again with the Y of the green balls.  The brighter colored square is over each of the type of balls respectfully.  However, the rectangle is longer with darker colors on the outside and a bright red in the center.

Thanks

What do you mean by rectangle? I think you’ll need to post another screenshot. :slight_smile:

You can use a free image host like postimage.org to upload images, then just post the link here

screenshot1.jpgThanks for the tip. screenshot0.jpg

This is what I meant by the rectangle

The rectangle covers a large area but the brighter part is over the balls.

How is there a brighter part? Did you create 2 rectangles for testing?

Brent

No.  The only think I did was  Y+200 to make the rectangle over the game balls.

  1. local testRect = display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY+200, 200, 300 )
  2. testRect:setFillColor( 1, 0, 0, 0.5 )

Since the target is over the table and the game balls touch the table logically I think the problem is in the way the graphic is sizing the table graphic.  I have two sizes for the table and those two work great on all the other devices.    I’ve tried everything I can t think of.  But then again - I have limited experience.

Also, the same thing is happening on my end game screen.  It is sizing it (the background photo) too small as well.

Thanks

Lori

Hi Lori,

I still don’t understand why there is a brighter red rectangle (shorter, about 20% the height) compared to a dimmer red rectangle.

Naturally, the rectangle won’t be in the vertical center if you’re adding 200 to its Y value…

What is the rectangle supposed to be aligned to (vertically)? The row of green balls, or the white ball?

Brent

The rectangle is not part of my code.  I added it as a request in one of the responses above.  I tried to align it over the balls since that is one of the problem area’s.  If I do not add the 200 to the Y then the rectangle is in the center of the screen.  

The game table is centered.  It appears the table is not sizing correctly.

I have two table sizes that work on all the other devices.  So the only thing I can logically deduce is that the png selected is not resizing in the same fashion as on the other devices.  I’m not sure how all of that works behind the scene.

Do I need a third size for this device?  But then it might mess up the sizing on all the other devices that are currently working.  This is the last issue before I can release on Google.  Apple is already accepted and in production.

Thanks

Lori

Corona_Simulator_Nexus_One_480x800.png Corona_Simulator_HTC_Sensation_540x960.p

I know why the rectangle was off.  I had the code in twice so there were two over lapping.  

I reposted with one rectangle and it is definitely in the center. The first picture is incorrect (NEXUS ONE) and the second picture is correct (HTC Sensation).

I think the problem lies with the sizing on the table.  It is like it should choose the larger of the two images or it is sizing the table too small.

Thanks

Lori

Lori, can you put some print statements in  your code and run it on both devices and post the results:

display.contentWidth

display.contentHeight

display.actualContentWidth

display.actualContentHeight

display.pixelWidth

display.pixelHeight

Also print out the width and height of the background box that’s changing size on the different devices. Finally can you copy/paste your config.lua file (I know you published it earlier), but this time please click on the blue <> button the edit bar with Bold, Italic and such and paste it into the box that pops up.  This feels like a syntax error in config.lua causing the content area to not get defined.

Rob

I have two sizes for the actual PNG for the table.

table.png  = 768 x 768 pixels

table@2x.png = 1536 x 1536 pixels

Below is the prints from the terminal

HTC (From the Terminal)

Dec 20 10:58:43.029 ----------Pressed Level #  =  1-------------

Dec 20 10:58:43.035 ++++++++++++++++++++ LEVEL #1 +++++++++++++++++++++++++++++++++++++

Dec 20 10:58:43.035 display.contentCenterWidth =

Dec 20 10:58:43.035 nil

Dec 20 10:58:43.042 -------------------------

Dec 20 10:58:43.042 display.contentHeight=

Dec 20 10:58:43.043 1422

Dec 20 10:58:43.043 -------------------------

Dec 20 10:58:43.043 display.actualContentWidth =

Dec 20 10:58:43.043 800

Dec 20 10:58:43.043 -------------------------

Dec 20 10:58:43.043 display.actualContentHeight=

Dec 20 10:58:43.043 1422.2221679688

Dec 20 10:58:43.043 -------------------------

Dec 20 10:58:43.043 display.pixelWidth=

Dec 20 10:58:43.043 540

Dec 20 10:58:43.043 -------------------------

Dec 20 10:58:43.043 display.pixelHeight=

Dec 20 10:58:43.043 960

Dec 20 10:58:43.043 -------------------------

Dec 20 10:58:43.044 ++++++++++++++++++++ LEVEL #1 +++++++++++++++++++++++++++++++++++++

Dec 20 10:58:43.044 +++++++++++++++++++++TABLE TOP WIDTH/HEIGHT++++++++++++++++++++++++++

Dec 20 10:58:43.044 Table Top Width = 

Dec 20 10:58:43.044 768

Dec 20 10:58:43.044 ---------------------

Dec 20 10:58:43.044 Table Top HEIGHT = 

Dec 20 10:58:43.044 768

Dec 20 10:58:43.044 +++++++++++++++++++++TABLE TOP WIDTH/HEIGHT++++++++++++++++++++++++++

NEXUS ONE **  (From the Terminal)**

Dec 20 10:59:32.654 ----------Pressed Level #  =  1-------------

Dec 20 10:59:32.660 ++++++++++++++++++++ LEVEL #1 +++++++++++++++++++++++++++++++++++++

Dec 20 10:59:32.661 display.contentCenterWidth =

Dec 20 10:59:32.661 nil

Dec 20 10:59:32.669 -------------------------

Dec 20 10:59:32.669 display.contentHeight=

Dec 20 10:59:32.669 1333

Dec 20 10:59:32.669 -------------------------

Dec 20 10:59:32.669 display.actualContentWidth =

Dec 20 10:59:32.669 800

Dec 20 10:59:32.669 -------------------------

Dec 20 10:59:32.669 display.actualContentHeight=

Dec 20 10:59:32.669 1333.3332519531

Dec 20 10:59:32.669 -------------------------

Dec 20 10:59:32.669 display.pixelWidth=

Dec 20 10:59:32.669 480

Dec 20 10:59:32.669 -------------------------

Dec 20 10:59:32.669 display.pixelHeight=

Dec 20 10:59:32.670 800

Dec 20 10:59:32.670 -------------------------

Dec 20 10:59:32.670 ++++++++++++++++++++ LEVEL #1 +++++++++++++++++++++++++++++++++++++

Dec 20 10:59:32.670 +++++++++++++++++++++TABLE TOP WIDTH/HEIGHT++++++++++++++++++++++++++

Dec 20 10:59:32.670 Table Top Width = 

Dec 20 10:59:32.670 512

Dec 20 10:59:32.670 ---------------------

Dec 20 10:59:32.670 Table Top HEIGHT = 

Dec 20 10:59:32.670 512

Dec 20 10:59:32.670 +++++++++++++++++++++TABLE TOP WIDTH/HEIGHT++++++++++++++++++++++++++

config.lua

--calculate the aspect ratio of the device local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 800 or math.floor( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.floor( 800 \* aspectRatio ), scale = "letterBox", fps = 30, imageSuffix = { ["@2x"] = 1.3, }, }, --------------------------------------------- license = { google = { key = "my google key", }, }, }

 Let me know if I failed to include everything.   

 

Thanks,

 

Lori

For the output, I wanted to see display.contentWidth, not display.contentCenterWidth (which doesn’t exist), but I suspect it would be 800 in both cases since that’s what it should be.

Personally I would recommend you do:

local tableTop = display.newImage Rect (“Images/borderYellowGreen2.png”, 768, 768 )

and loose the scaling. The difference between display.newImage() and display.newImageRect() is that the first loads the image at the physical pixels of the image.  The second form you say how big you want the image relative to the content are. In this case you’re saying make it 768 of 800 pixels wide. Since the image is square, the height is also 768.

I almost never use display.newImage() unless I don’t know the size of the image before I load it. If I know the dimensions, I will always use the display.newImageRect() version.

Rob