scaling sprite from center

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
daegan
Prole
Posts: 4
Joined: Mon Dec 09, 2024 9:16 pm

scaling sprite from center

Post by daegan »

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
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: scaling sprite from center

Post by RNavega »

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.)
daegan
Prole
Posts: 4
Joined: Mon Dec 09, 2024 9:16 pm

Re: scaling sprite from center

Post by daegan »

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.)
Thank you! i'll see what i can do.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 5 guests