[solved] What does ox and oy

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
Purple Fedora
Prole
Posts: 23
Joined: Fri Oct 26, 2018 8:41 pm

[solved] What does ox and oy

Post by Purple Fedora »

When I use love.graphics.draw what does the ox and oy parameters change only the rotation point or the point where you define x and y?
Last edited by Purple Fedora on Wed Nov 21, 2018 10:45 pm, edited 2 times in total.
JoshGrams
Prole
Posts: 33
Joined: Sat May 27, 2017 10:58 am

Re: What does ox and oy

Post by JoshGrams »

The origin point (ox, oy) on the image will be placed at the (x, y) coordinate that you pass to draw. So changing ox and oy will move the image. For example:

Code: Select all

function love.load()
	img = love.graphics.newCanvas(64, 64)
	love.graphics.setCanvas(img)
	love.graphics.setColor(0.5, 0, 1)
	love.graphics.rectangle('fill', 0, 0, 64, 64)

	love.graphics.setCanvas()
	love.graphics.setColor(1, 1, 1)
end

function love.draw()
	local s = 200
	love.graphics.draw(img, 1*s, 1*s, 0, 1, 1, 0, 0)
	love.graphics.draw(img, 2*s, 1*s, math.pi/8, 1, 1, 32, 32)
	love.graphics.draw(img, 2*s, 2*s, -math.pi/8, 1, 1, 64, 0)
	love.graphics.draw(img, 1*s, 2*s, 0, 1, 1, 32, 64)

	love.graphics.circle('fill', 1*s, 1*s, 3)
	love.graphics.circle('fill', 2*s, 1*s, 3)
	love.graphics.circle('fill', 2*s, 2*s, 3)
	love.graphics.circle('fill', 1*s, 2*s, 3)
	love.graphics.rectangle('line', 0.5*s, 0.5*s, 2*s, 2*s)
	love.graphics.line(0.5*s, 1.5*s, 2.5*s, 1.5*s)
	love.graphics.line(1.5*s, 0.5*s, 1.5*s, 2.5*s)
end
Post Reply

Who is online

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