im creating an animation by caching quads from a tileset of 256*256
this means it's 16 frames of 64*64 images
question is, im not sure im understanding how quads work. if i create this animation (eg.: on my cursor's position), will the animation be made of 64*64 images because each quad is that size? i wanted it custom size
quad resize
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: quad resize
You can create the quads with whatever dimensions you want but they can't be resized after creation. https://love2d.org/wiki/love.graphics.newQuad
Re: quad resize
(image not showing? https://imgur.com/43sPEUx)
in my example, i made a quad on my cursor (position 64, 128), which is the tileset's 10th sprite
but how to set a custom size? let's say i want that same one, but sized 50x50
Code: Select all
local parent_effect = GRAPHICS.newImage("sprites/effects/explosion1.png")
local quad = GRAPHICS.newQuad(64, 128, 64, 64, parent_effect:getDimensions())
GRAPHICS.draw(parent_effect, quad, mouseX, mouseY)
poof()
Re: quad resize
You mean you want to draw it at a custom size? Use the sx and sy parameters of the draw function. You'd need to work out the correct fraction of the true size to make it 50x50px (in this case 50 divided by 64, or 0.78125).
You should really get comfortable reading the documentation, finding this kind of thing out will be much quicker for you than waiting for a response on here.
https://love2d.org/wiki/love.graphics.draw
You should really get comfortable reading the documentation, finding this kind of thing out will be much quicker for you than waiting for a response on here.
https://love2d.org/wiki/love.graphics.draw
Re: quad resize
i read, problem is it doesnt always explain what each thing mean/does, and examples dont always use all things (obviously)
trying to find examples with quad's SX SY OX OY KX KY whatever they mean lol
my resized quad is being drawn on another position, not being drawn at cursor coordinates
trying to find examples with quad's SX SY OX OY KX KY whatever they mean lol
my resized quad is being drawn on another position, not being drawn at cursor coordinates
poof()
Re: quad resize
Hi, some comments:
1) To not use any calls to the asset loading functions (like .newImage()) inside a high-frequency function, or you're gonna wear out your disk. The love.draw() function is always called at least 30 times per second (usually 60 or more), and each time it's called, you're loading that image from disk. Better to cache the image once during startup into some outer scope variable, then use that variable later as explained by pgimeno in here: viewtopic.php?p=261188#p261188
2) You need to do some math on the X, Y coordinates that you're sending to the draw() call so that the quad is positioned how you want to. The quad begins being drawn by its top-left corner, so if you want to draw it centered at the mouse cursor, you should subtract half the quad width from its desired x position, and half the quad height from its desired y position. Use the quad width and height in pixels, and already scaled by the same SX and SY scaling factors that you'll send to draw().
3) The optional OX,OY parameters control the origin offset of the scale and rotate and shearing transformations done by the optional R and SX,SY and KX,KY parameters.
The default origin is the top-left corner of the sprite, so the sprite gets scaled by that corner for example, but by using the origin offset you can scale it from its center or some other position.
This is written in the introduction to that love.graphics.draw() docs page that marclurr pointed to (it does help to have some previous experience with using sprites and 2D affine transformations, but it's too much stuff to explain in forum posts)
1) To not use any calls to the asset loading functions (like .newImage()) inside a high-frequency function, or you're gonna wear out your disk. The love.draw() function is always called at least 30 times per second (usually 60 or more), and each time it's called, you're loading that image from disk. Better to cache the image once during startup into some outer scope variable, then use that variable later as explained by pgimeno in here: viewtopic.php?p=261188#p261188
2) You need to do some math on the X, Y coordinates that you're sending to the draw() call so that the quad is positioned how you want to. The quad begins being drawn by its top-left corner, so if you want to draw it centered at the mouse cursor, you should subtract half the quad width from its desired x position, and half the quad height from its desired y position. Use the quad width and height in pixels, and already scaled by the same SX and SY scaling factors that you'll send to draw().
3) The optional OX,OY parameters control the origin offset of the scale and rotate and shearing transformations done by the optional R and SX,SY and KX,KY parameters.
The default origin is the top-left corner of the sprite, so the sprite gets scaled by that corner for example, but by using the origin offset you can scale it from its center or some other position.
This is written in the introduction to that love.graphics.draw() docs page that marclurr pointed to (it does help to have some previous experience with using sprites and 2D affine transformations, but it's too much stuff to explain in forum posts)
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 12 guests