newWorld - what units does it use?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
newWorld - what units does it use?
Now, http://love2d.org/docs/love_physics_newWorld_1.html mentions width and height, but my question is quite simple - is this in pixels or is it in Box2D units?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: newWorld - what units does it use?
Whatever you chose, though by default scaling is enabled, allowing you to use pixels.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: newWorld - what units does it use?
I believe the default unit is 1/30 of a meter.
Help us help you: attach a .love.
Re: newWorld - what units does it use?
In other words, it uses Box2D units? So, if I had a fixed screen res of 800x600, and a unit size of 64pixels-per-metre, then love.physics.newWorld (800/64, 600/64) would be correct?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: newWorld - what units does it use?
Nope, the default is 1/30th of a Box2D unit (B2D unit = meter). That makes it easier to avoid twiddling with scaling, and just say "a LÖVE unit equals one pixel on screen, thus 30 pixels = 1 meter".Sslaxx wrote:In other words, it uses Box2D units? So, if I had a fixed screen res of 800x600, and a unit size of 64pixels-per-metre, then love.physics.newWorld (800/64, 600/64) would be correct?
Code: Select all
pixels <-> your own drawing scale <-> LÖVE units <-> World:getMeter() <-> Box2D units
Code: Select all
300px -> *1 -> 300px -> /30 -> 10 meter
That depents what "unit size" means. Is it World:setMeter(64)? Then, yes.Sslaxx wrote:So, if I had a fixed screen res of 800x600, and a unit size of 64pixels-per-metre, then love.physics.newWorld (800/64, 600/64) would be correct?
Help us help you: attach a .love.
Re: newWorld - what units does it use?
I see an issue, or I think I do.
A new world object is created at a scale of 30px-per-metre, yes? So if I were to create a world using love.physics.newWorld (800/30, 600/30) and were then to rescale that world to, say, 64 pixels, what would happen to the scale of that world?
A new world object is created at a scale of 30px-per-metre, yes? So if I were to create a world using love.physics.newWorld (800/30, 600/30) and were then to rescale that world to, say, 64 pixels, what would happen to the scale of that world?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: newWorld - what units does it use?
I don't think setting the scale changes anything. You usually set the scale of the world only once, right after creating the world, which would result this:Sslaxx wrote:I see an issue, or I think I do.
A new world object is created at a scale of 30px-per-metre, yes? So if I were to create a world using love.physics.newWorld (800/30, 600/30) and were then to rescale that world to, say, 64 pixels, what would happen to the scale of that world?
Code: Select all
w = love.physics.newWorld (800/30, 600/30)
w:setMeter(64)
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests