Rotating an object

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
GloriousDerp
Prole
Posts: 6
Joined: Tue Feb 25, 2014 10:52 pm

Rotating an object

Post 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
	
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Rotating an object

Post by Nixola »

":Rotation" should be "applyTorque" or "setAngle". Be sure to use radians with the latter.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
GloriousDerp
Prole
Posts: 6
Joined: Tue Feb 25, 2014 10:52 pm

Re: Rotating an object

Post by GloriousDerp »

Thank you!
GloriousDerp
Prole
Posts: 6
Joined: Tue Feb 25, 2014 10:52 pm

Re: Rotating an object

Post by GloriousDerp »

Is there a thing to make it so i dont rotate until i push the key to rotate?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Rotating an object

Post 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
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests