love.physics.setMeter() changes behaviour but not the size of drawn bodies

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
mrdarip
Prole
Posts: 1
Joined: Sat May 20, 2023 8:40 pm

love.physics.setMeter() changes behaviour but not the size of drawn bodies

Post by mrdarip »

:emo: when calling love.physics.setMeter(5) when drawing objects.player.shape = love.physics.newRectangleShape(0, 0, 3, 5) the drawn size is always 3x5 px not mattering what i input as parameter in love.physics.setMeter().
Is this the intended behaviour or am i missing something

Is this correct?
love.physics.setMeter(meters)
love.physics.newRectangleShape(meters, meters, meters,meters)

Should i be using love.graphics.scale()?
User avatar
H.I
Prole
Posts: 6
Joined: Wed Mar 29, 2023 3:34 pm

Re: love.physics.setMeter() changes behaviour but not the size of drawn bodies

Post by H.I »

s = love.physics.newRectangleShape( body, x, y, width, height, angle )

you are not attaching it to any body, and this is how i use meter:

meter = 10
love.physics.setMeter(meter)

world = love.physics.newWorld(0,100*meter,true)
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: love.physics.setMeter() changes behaviour but not the size of drawn bodies

Post by pgimeno »

H.I wrote: Sun May 21, 2023 3:51 am s = love.physics.newRectangleShape( body, x, y, width, height, angle )
This is for Löve 0.7.2 and earlier. It doesn't work in any recent version.
Rigachupe
Citizen
Posts: 83
Joined: Fri Jun 18, 2021 11:21 am

Re: love.physics.setMeter() changes behaviour but not the size of drawn bodies

Post by Rigachupe »

setMeter tells the physics of löve2d how much pixels are a meter. So value 20 means each 20pixels is one meter.

The shape functions are based in pixels.

Code: Select all

body = love.physics.newBody(world, 300, 300, "dynamic") -- place the body at pixel coordinates (300,300) or in meter coordinates (10,10)
love.physics.setMeter(10) -- set 10 pixels/meter
body:getPosition() -- returns pixel coordinates (100,100)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 45 guests