Hi Dave,
I can think of two things that might help you here:
1.) With Corona, it’s generally a good idea to always size your image files as a number that can be divided by two into a whole number. So assuming that your first image is square (31x31px), resize its canvas to 32x32. Likewise for the second image, assuming that it’s square (25x25px), resize the canvas to 28x28. Images with heights/widths that are odd or that don’t divide into whole numbers can exhibit odd behavior, and I’ve even seen them appear out of focus or blurry. And this is absolutely critical when creating bitmap masks.
2.) When you specify the x and y coordinates inside of the parenthesis (like you did in your example), you’re actually defining the upper-left hand corner of the image. When you specify them outside of the parenthesis (as binc did in his example), you’re specifying the center coordinates of the image, unless you set a different reference point. It’s a little quirky, but the way I personally get around it is to never define coordinates inside the parenthesis, but rather immediately afterwards. Also, if you aren’t familiar with the object:setReferencePoint() API, you should check it out. That will allow you to define exactly where you want your X and Y coordinates to be in relation to your image (center, top-left corner, bottom-right corner, etc.). In addition to resizing your PNGs to be divisible by 2, here’s my recommended code:
gunA = display.newImage("gun.png")
gunA:setReferencePoint(display.CenterReferencePoint)
gunA.x = display.contentCenterX
gunA.y = display.contentHeight - 110
local ball = display.newImage( blueBallGroup, "ball.png")
ball:setReferencePoint(display.CenterReferencePoint)
ball.x = gunA.x
ball.y = pt.y )
Hope that helps!
Best,
Jason [import]uid: 27636 topic_id: 28698 reply_id: 115702[/import]