In my game I’m spawning randomly big say birds, and as I spawn these birds in different sizes I want to assign each one of them a unique physics body being the same size. So this is my code at the moment:
local function choose1(event)
local choose = math.random(1, 2)
if choose == 1 then
local enemy = display.newImage(“Images/Enemy.png”, math.random(15, 300), -200)
local enemySize = math.random(10, 30)
enemy.yScale= enemySize
enemy.xScale = enemySize
physics.addBody(enemy, { friction=0.5, bounce=0, radius=enemySize})
end
end
timer.performWithDelay(300, choose1, 0)
I tried using scale to achieve my purpose but it won’t work since Scale and Radius are using different measurements. Is there any way I can decide and image’s size by giving it a value with pixels? I tried enemy.ySize / enemy.xSize but it doesn’t work for some reason
Thanks in advance! [import]uid: 14018 topic_id: 5114 reply_id: 305114[/import]