scaling sprite from center
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
scaling sprite from center
hi, im just messing around and trying things out since im new and i was wondering if it's possible to scale a sprite from it's center point? as you can see the rest works well but i couldn't figure that part out...thanks!
- Attachments
-
- uhm.love
- (1.75 KiB) Downloaded 225 times
Re: scaling sprite from center
Hi, yes, from the center or any other location.
The easiest way to do that is by using the "origin offset" coordinates, it's the ox, oy parameters found in either the love.graphics.draw() function where you manually set them, or when creating/modifying a Transform object (see the docs for love.math.newTransform for more) and using that Transform with the overload of love.graphics.draw() that takes it.
Read pgimeno's in here for more:
- viewtopic.php?p=226336#p226336
These ox,oy values work like a convenience for pre-moving the object to the origin before applying rotation or scale to it, but you still need to set an x,y so the object is moved back where it should be.
(For curiosity, you can manually do the same effect of ox,oy by doing a sequence of operations on a Transform like explained in this.)
The easiest way to do that is by using the "origin offset" coordinates, it's the ox, oy parameters found in either the love.graphics.draw() function where you manually set them, or when creating/modifying a Transform object (see the docs for love.math.newTransform for more) and using that Transform with the overload of love.graphics.draw() that takes it.
Read pgimeno's in here for more:
- viewtopic.php?p=226336#p226336
These ox,oy values work like a convenience for pre-moving the object to the origin before applying rotation or scale to it, but you still need to set an x,y so the object is moved back where it should be.
(For curiosity, you can manually do the same effect of ox,oy by doing a sequence of operations on a Transform like explained in this.)
Re: scaling sprite from center
Thank you! i'll see what i can do.RNavega wrote: ↑Sun Dec 15, 2024 7:35 pm Hi, yes, from the center or any other location.
The easiest way to do that is by using the "origin offset" coordinates, it's the ox, oy parameters found in either the love.graphics.draw() function where you manually set them, or when creating/modifying a Transform object (see the docs for love.math.newTransform for more) and using that Transform with the overload of love.graphics.draw() that takes it.
Read pgimeno's in here for more:
- viewtopic.php?p=226336#p226336
These ox,oy values work like a convenience for pre-moving the object to the origin before applying rotation or scale to it, but you still need to set an x,y so the object is moved back where it should be.
(For curiosity, you can manually do the same effect of ox,oy by doing a sequence of operations on a Transform like explained in this.)
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest