In the hamster ball example there's this:
local an,al,gr=love.graphics.getWidth(),love.graphics.getHeight(),love.graphics
function love.load()
hamster = gr.newImage("img.png")
x = 50
y = 50
speed = 300
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + (speed * dt)
elseif love.keyboard.isDown("left") then
x = x - (speed * dt)
end
if love.keyboard.isDown("down") then
y = y + (speed * dt)
elseif love.keyboard.isDown("up") then
y = y - (speed * dt)
end
end
function love.draw()
gr.draw(hamster, x, y)
end
My question is that, How can I get the width or height of the 'hamster' variable?
Thanks a lot.
How can I get the width of an image?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How can I get the width of an image?
Info on "(image):getWidth": https://love2d.org/wiki/(Image):getWidth
Re: How can I get the width of an image?
Thanks I didn't know about the ':' but I'm using it now and it works.
Who is online
Users browsing this forum: No registered users and 84 guests