Scaling a single image

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
Charlie
Prole
Posts: 2
Joined: Wed May 02, 2012 4:29 pm

Scaling a single image

Post by Charlie »

Hi everyone. I am just starting with LOVE (not programming) and am just tinkering with some basic things right now.
Is the love.graphics.scale() the appropriate way to scale a single image, using push and pop with it?
This doesn't seem too practical if so because it offsets the location on screen of the image.
This command seems more geared towards total screen zooming.

Below is a small script i made to test scaling.
One block scales and one doesn't. But the scaling block moves across the screen while scaling before ending up at it's correct x and y position.
Is this the only way of scaling a single image? This would require creating offsets of positions for images which could become pretty messy to deal with.
I hope I'm just missing something lol.

Code: Select all

function love.load()
	block = love.graphics.newImage("/images/block.png")
	x = 300
	y = 300
	scale = 0.5
end

function love.update(dt)
	if scale < 1 then 
		scale = scale + 0.01
	end
end

function love.draw()
	love.graphics.push()
	love.graphics.scale(scale,scale)
	
	love.graphics.draw(block,x,y)
	
	love.graphics.pop()
	love.graphics.draw(block,30,30)
end
Thanks in advance!
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Scaling a single image

Post by bartbes »

I see this come up a lot with new users, why, though? It's all on the wiki.

Short answer: love.graphics.draw has scale arguments!
Charlie
Prole
Posts: 2
Joined: Wed May 02, 2012 4:29 pm

Re: Scaling a single image

Post by Charlie »

lol thanks. I got it figured out before this post got approved. Yes it's on the wiki..but it's impossible to see everything right away when you know nothing about the language. Thanks again!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests