I’m new to Corona and game development. I am making a simple game with physics to move objects with touch. Here is my code
local physics = require"physics";
local gameUI = require("gameUI")
physics.setDrawMode( "normal" )
physics.setScale( 40)
physics.setPositionIterations( 60 )
physics.start();
local _H=display.contentHeight;
local _W=display.contentWidth;
local crat1=display.newImageRect("crate1.png",40,40)
crat1.x=20;crat1.y=200;
physics.addBody(crat1,"dynamic",{density=-1000,bounce=0.1,friction=100});
local function dragBody_call(event)
--Calling drawBody() From gameUI
gameUI.dragBody(event);
end
crat1:addEventListener( "touch", dragBody_call) -- make object draggable
In the simulator, movement and touch events are working perfectly and it also runs on Android device. Physics works perfectly and I can also move objects with Touch but it’s very laggy and very hard to move a objects. And sometime it does not move. It’s not as smooth as simulator. How can I fix this?
I think the the problem is your
According to the docs
See here http://docs.coronalabs.com/api/library/physics/setPositionIterations.html
Remove that line or if you REALLY need performance, increase it by a smaller value. Say to 12 or 16.