I've been fixing up an old platformer I found and I happened to stumble upon some extreme lag.
First there's no lag, then it increases by time.
Hope you can fix it.
lag using love.physics
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
lag using love.physics
- Attachments
-
- platformer.love
- laggy
- (2.27 KiB) Downloaded 76 times
Re: lag using love.physics
I do realize this is a double post, but I'M LOSING MY PATIENCE!
Re: lag using love.physics
You are creating thousands of new bodies, fixtures and shapes each second.
Code: Select all
function love.draw()
...
rect.body = love.physics.newBody(world, x * 20, y * 20, "static")
rect.shape = love.physics.newRectangleShape(20, 20)
rect.fixture = love.physics.newFixture(rect.body, rect.shape)
...
end
Re: lag using love.physics
How do I fix this?Azhukar wrote:You are creating thousands of new bodies, fixtures and shapes each second.Code: Select all
function love.draw() ... rect.body = love.physics.newBody(world, x * 20, y * 20, "static") rect.shape = love.physics.newRectangleShape(20, 20) rect.fixture = love.physics.newFixture(rect.body, rect.shape) ... end
Re: lag using love.physics
Create the bodies, shapes and fixtures only once (probably in love.load or some other loading function) and then keep using those.
The same way you'd do it with images and sounds and the like; store the return value from the creator function and keep using it.
The same way you'd do it with images and sounds and the like; store the return value from the creator function and keep using it.
Re: lag using love.physics
OK, so I did that now, but the problem is it only draws the last block. How do I make it so it draws them all?Plu wrote:Create the bodies, shapes and fixtures only once (probably in love.load or some other loading function) and then keep using those.
The same way you'd do it with images and sounds and the like; store the return value from the creator function and keep using it.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: lag using love.physics
It was 4 hours. Calm down.Doctory wrote:I do realize this is a double post, but I'M LOSING MY PATIENCE!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest