Corona Physics custom body collision problem

Hello. I am new in corona sdk, trying to learn it. I am trying to make a new game where i have a rocket object(physics) staying on screen which’s x position is fixed , move on y axis by tapping it. There are are some rock obstacle coming from  the right side of screen. All object are in custom physics shape. When my rocket and stone come face to face they should collide each other but they don’t as i  can see that in physics hybrid mode and by collision event handler result. But after leaving the rock object , the rocket collide in open space about 50-60 pixel far from the rock’s axis position. Where is the problem? I am giving some code here. Can any one familar with these type of problem?

-----Code for rocket

local rocket = display.newImage(“images/Rocket/new-rocket.png”, 60, 30);

rocket.xScale = 15;

rocket.yScale = 15;

rocket.x = 70;

rocket.y = 130;

rocket.xScale = n/5;

rocket.yScale = n/5;

rocket.id=“Rocket”;

local pBody = {};

pBody.rocket = {

{

friction = 0.2,

shape = { -16 , -17 ,-3 , -19, 4 , -14, 25, -13, 43, -1, 31 , 11, 8, 14, -11 , 20  }

}

}

physics.addBody(rocket,“dynamic”,unpack(pBody.rocket));

—Code for randomly generated rock on a function

    local randStone= display.newImage(“images/Stone/stone2.png”, _W, _H);

    randStone:setReferencePoint( display.CenterLeftReferencePoint );

    randStone.x=stoneX;

    randStone.y=stoneY;

    randStone.xScale=0.2;

    randStone.yScale=0.2;

    randStone.id=“Random stone 2”;

    pBody.randStone = {

   {

      friction = 0.2,

      shape = {-17,-29,23,-21, 21, 24, -22, 25}

   }

   } 

physics.addBody(randStone,“kinematic”,unpack(pBody.randStone));

    else

Hi @sulaiman.sust,

You can’t scale physics objects (i.e. .xScale and .yScale). Well, you can, but it will only scale the image associated with the object and not the physical body.

Take care,

Brent

Thanks for your reply Brent. I  scaled my object and made the physics shape according to scaled object on that code. I could see the shape in physics hybrid mode. and physics should work on the shape area only but rock collide with my rocket about 50-60 pixel later.

Thank you. My problem is solved. 

Hi @sulaiman.sust,

You can’t scale physics objects (i.e. .xScale and .yScale). Well, you can, but it will only scale the image associated with the object and not the physical body.

Take care,

Brent

Thanks for your reply Brent. I  scaled my object and made the physics shape according to scaled object on that code. I could see the shape in physics hybrid mode. and physics should work on the shape area only but rock collide with my rocket about 50-60 pixel later.

Thank you. My problem is solved.