Physics object scale

Hey forum,

I have seen several threads on people who have had trouble with this before but I decided I would bring the issue back to life because I still can’t find the answer.

So my predicament is: I am trying to create a physics based circle and when you touch the circle it scales a certain amount until you “end” your touch event and then the circle remains the size it is after the touch.

I have figured out how to implement this with an object (a simple image) but I can’t figure out how to do it with a physics object. I realize that several posts have been created explaining that you must remove the object, flag it, then recreate the new physics object in the new position. I’ve also seen a post stating that you can place the objects you want to scale inside a display group and thenscale the group but I’m not sure if they is trully ideal for my situation.

I guess what I’m asking is for someone to look through my code and possibly share some code or add to mine that will perform the task I have stated. So if someone could possibly share code or correct the given in order to give the desired result of a physics circle that can scale that would be greatly appreciated.

I thank you again in advance! :smiley:

[lua]
local box = display.newRect(0,0,50,50)
box.x = 150
box.y = 150
box.xScale = 1
box.yScale = 1
Score = 0
boxtouched = false
Time = 0 
 
function addtime()
Time = Time + 1
end
 
function touch_that(event)
if event.phase == “began” then
boxtouched = true
elseif event.phase == “ended” then
boxtouched = false
print(Time)
end
end
 
 
 
function sizebox()
if boxtouched == true then
box.xScale = box.xScale + 0.125
box.yScale = box.yScale + 0.125
timer.performWithDelay(300, addtime, 1)
elseif boxtouched == false then
return false
end
end
 
scoreField = display.newText(" ", 50,50, native.systemFont, 30)
 
function showScore()
if boxtouched == true then
 
end
end
 
box:addEventListener(“touch”, touch_that)
Runtime:addEventListener(“enterFrame”, sizebox
)[lua] [import]uid: 66902 topic_id: 14140 reply_id: 314140[/import]

Hi Thomas,

take a look at this
http://www.emanueleferonato.com/2009/12/12/scaling-objects-with-box2d/

Br,
Alen [import]uid: 9592 topic_id: 14140 reply_id: 52049[/import]

Thanks for the reply Alen.

However, I understand “theoretically” how to accomplish this, Ive just been trying over and over and I just can’t get it right. The link helps again to explain what to do but without the knowledge of actionscript and the ability to port I feel to be in the same position as before.

If you or someone could help using the lua language possibly using my own code posted that would be great since I have hit this roadblock and production time has completed halted at the moment.

Thank you all in advance and thanks again to Alec for the reply! [import]uid: 66902 topic_id: 14140 reply_id: 52137[/import]

Are you trying to make a filler game?

http://www.kongregate.com/games/SimianLogic/filler

I was just posting that scaling a group seemed to have worked for physics scaling but I don’t know if it will work if you scale 2 groups separately. Worth a try though. just make a new display group for the object you want to scale. [import]uid: 19176 topic_id: 14140 reply_id: 52183[/import]