I’m creating a border around the screen using a single image, which is scaled based on the size of the display and the number of images used. Apparently, the physics engine is using the actual size of the image as the extent for collisions, evidenced by drawing in debug mode. Is there a way to get physics to use the scaled size of the image for collisions, or do I need to maintain different sized images for each type of display (iphone, ipad, droid) and just use a scale of 1.0?
The code to create a single image follows:
function newCrate(game, physics)
local sprt = display.newImage("crate.jpeg")
sprt.xScale = 1/NUM\_CRATES \* (display.contentWidth / sprt.contentWidth)
sprt.yScale = 1/NUM\_CRATES \* (display.contentHeight / sprt.contentHeight)
game:insert(sprt)
physics.addBody( sprt, "static", { friction=0.5, bounce=0.3 } )
return sprt
end
And this code draws the top row.
for i = 0, NUM\_CRATES - 1
do
local sprt = newCrate(game, physics)
sprt.x = sprt.contentWidth \* 0.5 + (sprt.contentWidth \* i)
sprt.y = sprt.contentHeight \* 0.5
top[i+1] = sprt
end
Both the game group and physics module are passed in from the main.lua script. [import]uid: 58455 topic_id: 10590 reply_id: 310590[/import]