Physics body is applied only on small part of image.

Hi , i got problem… 

If i create a new image and add physics body to it , its applied just on small part of it. 

I recorded it on video and upload it on yt:

https://www.youtube.com/watch?v=FApGoNTqTq0&feature=youtu.be

at 0:08 you can see where is physic body applied and at 0:16 you can see my problem.

Code:

------------- loading images and applying physics here ------- local hero\_1 = display.newImage( "heroes/yellow/idle.png"); hero\_1:scale(1.2\*mp\_w,3.4\*mp\_h); hero\_1.x = 240\*mp\_w; hero\_1.y = 350\*mp\_h; hero\_1.myName = "hero" local brick1 = display.newImage("brick\_1.png") brick1:scale(0.5\*mp\_w,1.5\*mp\_h); brick1.x = 350\*mp\_w; brick1.y = 550\*mp\_h; physics.addBody( hero\_1 , "dynamic",{ density=0, friction=0, bounce=0, radius=0 } ) physics.addBody( brick1, "static", { friction=10, bounce=1 } ) -------- Hero move -------- local function moveguy (event) hero\_1.x = hero\_1.x + motionx; end Runtime:addEventListener("enterFrame", moveguy) ---------------------------

Thanks for reply :slight_smile:

A couple (well, 3) things to help.

  1. add physics.setDrawMode( “hybrid” ) to see the physics boundries.
  2. The player has a radius of 0, which means there is no phyiscs boundry at all.  Radius parameter is for circular objects.
  3. I believe you should not be moving dynamic objects directly.  You need to allow the physics library to handle movement.  Check out setLinearVelocity and/or applyForce.

Hope this helps.

Hi @arsimek,

You can’t scale objects with physics bodies applied. Well, you can scale them, but it will only scale the image aspect of the object. The defined physical body will remain the same as the non-scaled (1:1 ratio) image that was initially set up.

Take care,

Brent

Thanks ! :) 

A couple (well, 3) things to help.

  1. add physics.setDrawMode( “hybrid” ) to see the physics boundries.
  2. The player has a radius of 0, which means there is no phyiscs boundry at all.  Radius parameter is for circular objects.
  3. I believe you should not be moving dynamic objects directly.  You need to allow the physics library to handle movement.  Check out setLinearVelocity and/or applyForce.

Hope this helps.

Hi @arsimek,

You can’t scale objects with physics bodies applied. Well, you can scale them, but it will only scale the image aspect of the object. The defined physical body will remain the same as the non-scaled (1:1 ratio) image that was initially set up.

Take care,

Brent

Thanks ! :)