Hi guys, whenever I scale the graphic using scaleX or scaleY it always scales relative to the (0,0) position of the graphic. How do I make it so that the scaling comes from the actual center of the graphic?
How to scale it from a different "center"
are there any way to set arbitary center of the entity? such as set rotation center(pivot) at any given (x,y) ~
Hi ,
centerX and centerY are just readonly perperties so can’t set.
see picture below, the upper-left corner small green rect is pivot of the entity? actually setOrigin(x,y)/centerOrigen() have no impact to it. I see only hitbox is affected by setOrigin. are there ways to change pivot to center of the entity?
originX
and originY
. That’s what you are looking for.
centerX
and centerY
is a only-read property wich is the position of the center in the world.
Entities have originX
and originY
; those govern the registration point of the hitbox.
To change the center of rotation on a graphic, use centerX
and centerY
on the graphic itself. Note that they don’t exist on every type; for example, Image and Spritemap both have origins, but Tilemap and Emitter do not.