Resizing from edges

NRafNRaf Member Posts: 4
edited November -1 in Working with GS (Mac)
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.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    codemonkey has a demo that shows resizing bars... look at his profile for a list of his game tutorials.
  • rebumprebump Member Posts: 1,058
    I think I understand what you are asking. It would involve knowing the actor's width and it's X positions, which you do. Use half the width and subtract it from the X position to get the left edge (base X position). Then if you re-size, you would need to re-compute that offset (width / 2) and add it back to the base X position value (not the actor's actual X position value).

    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".
Sign In or Register to comment.