Resizing from edges
NRaf
Member Posts: 4
Sorry for all the topics.
I'm trying to resize the width for an object - the way the application is set up, objects are resizing from the center. How can I resize objects from edges (i.e. the X position doesn't change)? I tried to set a Constrain Attribute property, setting it to the correct X position, but that's not working.
I'm trying to resize the width for an object - the way the application is set up, objects are resizing from the center. How can I resize objects from edges (i.e. the X position doesn't change)? I tried to set a Constrain Attribute property, setting it to the correct X position, but that's not working.
Comments
The problem is you need to retain that base X position as it will keep the object's left edge aligned at that position. I was able to use all this to have a generic square actor grow to the right only (instead of both left and right from the center). That base X position could be held in an additional attribute that has additional logic placed upon it if you need to allow drag-n-drop or movement changes because of some condition.
Also, the equations/logic could be modified to grow from the right instead of the left as well as using height and the Y position to grow up or grow down.
Basically for my test, I constrained the actor's X position to:
self.BaseXPosition + (self.Size.Width / 2)
And then just had some logic that changed the Width over time. "BaseXPosition" did not change (but could as I mentioned before for drag-n-drop, etc.) May need to play with ceiling()/floor() for possible division clean-up but my quick test grew properly when growing by 1 each time.
If the actor is going to be moving around willy-nilly, then figuring out the base X position would be a bit hectic because you lose the "grow to one side" effect unless you took the X position at some point and halted movement for a brief time after getting the X position to do the grow "animation".