Page 1 of 1

Rotating an object

Posted: Wed Feb 26, 2014 10:49 pm
by GloriousDerp
I'm new to lua and through some luck and determination have made a program that boxes and circles bounce around and i want to make it so that i am able to rotate a box. I tried but when i push the key it comes up with an error screen.

Code: Select all

	elseif love.keyboard.isDown("w") then
		objects.box.body:applyForce(0, -1000)
	elseif love.keyboard.isDown("s") then
		objects.box.body:applyForce(0, 1000)
	elseif love.keyboard.isDown("a") then
		objects.box.body:applyForce(-1000, 0)
	elseif love.keyboard.isDown("d") then
		objects.box.body:applyForce(1000, 0)
	elseif love.keyboard.isDown("e") then
		objects.box.body:Rotation(45)
	end
	

Re: Rotating an object

Posted: Wed Feb 26, 2014 10:52 pm
by Nixola
":Rotation" should be "applyTorque" or "setAngle". Be sure to use radians with the latter.

Re: Rotating an object

Posted: Wed Feb 26, 2014 10:55 pm
by GloriousDerp
Thank you!

Re: Rotating an object

Posted: Wed Feb 26, 2014 11:04 pm
by GloriousDerp
Is there a thing to make it so i dont rotate until i push the key to rotate?

Re: Rotating an object

Posted: Wed Feb 26, 2014 11:07 pm
by Nixola
You could be able to do it with [wiki]Body:setFixedRotation[/wiki]
Also, double posting isn't seen well here, please edit your last post if no one has answered yet