As an example I have a box, and the first collision I have it drop in size, it gets shorter. I read that the physics engine will keep the original size. Can you change the shape of the image during the collision? ie {8,-56, 55,… } allowing me to define a smaller shape when hit, I’m changing the image using movieclip.
Dan [import]uid: 78446 topic_id: 14830 reply_id: 314830[/import]
Changing Object properties in a collision is a no, no ( well at least it use to be) because of various reasons for box2d an multiple collisions occurring causing an error etc… more details if you search the forums.
Anyway you can usually get around the issue by executing a function
wrapped in
timer.performWithDelay()
passing in a 1 millisecond parameter
I bet it would work.
Good luck
Larry
DoubleslashDesign.com [import]uid: 11860 topic_id: 14830 reply_id: 54801[/import]
I have the original shape defined and then my trashcan setup as this-
local trashCan1 = movieclip.newAnim{ "imagesGame/trashCan01.png", "imagesGame/trashCan02.png" }
game:insert( trashCan1 )
trashCan1.x = 415; trashCan1.y = 280
physics.addBody( trashCan1, { density=metalDensity, friction=0.5, bounce=.01, shape=trashcanshape} )
trashCan1.myName = "trashCan"
I tried to redefine the shape in the collision after the event.force
by adding
local function changeshape ( event )
trashcanshape = {17,-24, 11,1, 16,23, -16,23, -11,1, -17,-24}
end
timer.performWithDelay( 100, changeshape)
to
if ( event.force \< 7 ) and ( event.force \> 4 ) then
self:stopAtFrame(2)
if reset == 1 then
timer.cancel(startresetTimer)
end
end
to get
if ( event.force \< 7 ) and ( event.force \> 4 ) then
self:stopAtFrame(2)
if reset == 1 then
timer.cancel(startresetTimer)
end
local function changeshape ( event )
trashcanshape = {17,-24, 11,1, 16,23, -16,23, -11,1, -17,-24}
end
timer.performWithDelay( 100, changeshape)
end
but it doesn’t change the shape. I’m going to make the image in frame two look damaged, but remain the same size.
Thanks,
Dan [import]uid: 78446 topic_id: 14830 reply_id: 55156[/import]