Constraint movable element on an axis

Hello,

As says in the title, is it possible to constraint a movable element on an axis as X or Y so, when the element move he can only be moved on the constrained axis.
As i’m talking about it, is it possible to get an offset with that, like you got you element movement constrained on X axis but the offset allow you to move on the Y axis untill you reach the offset limit.
I’m asking since i didn’t found where you update movable element and how you do it… don’t want to mess with it by adding something on top of you lib… nvm.

Ps : I realy like the libs :smiley:

@kobRoah said: Hello,

As says in the title, is it possible to constraint a movable element on an axis as X or Y so, when the element move he can only be moved on the constrained axis.
As i’m talking about it, is it possible to get an offset with that, like you got you element movement constrained on X axis but the offset allow you to move on the Y axis untill you reach the offset limit.
I’m asking since i didn’t found where you update movable element and how you do it… don’t want to mess with it by adding something on top of you lib… nvm.

Ps : I realy like the libs :smiley:

Sorry for the delay… was a bit tired last night and called it early.

The quickest way of doing this would be: (I’ll use X as an example)

  1. Create an element the width of the screen and the height of the element you want to limit.
  2. Remove all render components by calling element.setAsContainerOnly();
  3. Add the element you want to limit as a child of this element
  4. set the following flags:
    ** setLockToParentBounds(true);
    ** setIsMovable(true);

This will limit the movement to the parent element and only move along the X axis. You can modify the shape of the parent to only allow movement along the Y axis.

Let me know if this answered your question!

Thx it work as espected :D.
Maybe put this in the wiki could avoid people to search for stuff like this. Like having a hint section…

1 Like