[Behaviour]-Dock

  • Hi! There is another of my plugins, this time a behavior, which i decided to do because i was unable to get work the vanilla Anchor even rex-anchor mod never worked for me, i dont know if those behaviors works for you, well i made my own docking plugin and this one works nicely.

    Docks, works just like its name states, use this to dock objects to the edges or corners of the screen, its useful for creating UIs even you can give it some offsets so it docks using some margins.

    the behavior:

    old version

    https://drive.google.com/drive/folders/ ... sp=sharing

    new versions

    1.1 - https://drive.google.com/file/d/0B8613P ... sp=sharing

    1.2 - https://drive.google.com/file/d/0B8613P ... sp=sharing

    Changes in version 1.2:

    • Added new property (in Editor) 'Keep size' which prevents resizing when using edge docking (Left, Top, Right or Bottom).
    • Added a new action to set Keep size via runtime.

    Changes in version 1.1:

    • Added new action to setup offsets.
    • Added 4 expressions to retrieve each offset.

    PD: sorry my bad english not my native language.

  • This looks great! Thank you!

    Is it possible to add actions to change the offsets with events? This could be really helpful!

    Thanks again!

  • Yaottabyte

    Nice work! I wish I had this at the start of my last game!

  • Hi guys i'm so sorry for the late, i was something sick around last months, but i'm back.

    @eli0s: of course as soon as possible i will add a couple of actions to setup offsets.

    @cjbruce: Thanks, well i started to coding plugins just recently so that plugins was needed a lot for me, also a long time ago, that was my motivation to make my own docking plugin. i hope this still be helpful for you.

  • Yaottabyte , no worries, I'm glad you are back, I hope you're well and fully recovered!!!

    I thank you in advance for your time and effort!

  • eli0s iagree with the essence!

  • Hi guys! updated to version 1.1, check out the top post. I'd added the features asked by eli0s. Hope those changes fits to your needs.

    Get fun!

  • Yaottabyte , Thank you so much!!! This is how the default anchor behavior should behave! This is actually very useful when dynamically applying positions based on layout/screen widths/heights!!!

    Thank you again for the behavior and the update!

  • When i pick Top/Left/Right?Bottom - it stretches the sprite to the width of the layout. Is it possible to have a checkbox or dropbown that prevents that behavior?

    to keep the aspect ratio of the sprite, but still pins it to the side of the screen?

    (and therefore keeping the X or Y value of the sprite where its originally placed too)

    thanks!

  • Hi justifun, yes sure, it is possible to add an optional param to tells Dock not to stretch the object, so just fits it to the chosen screen's edge instead, let me review the behavior code and make the changes and so then i'll post the new features...

    EDIT:

    @justifun, already done, i'd added that functionality to the behavior i hope it fits to your needs. Good Luck!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Awesome!! Thanks!

  • Yaottabyte - I just noticed that apparently when you use the "set object dock to right" at runtime, that it results in the object having a X/Y of NaN and a width / height of blank.

    Also, is it possible to have the object align based on the origin point of the sprite? right now it seems to align in the middle regardless of where the origin is set.

    Thanks!

  • Hi justifun im so sorry for late response, i was unable to get connected to internet lately... well i reviewed plugin functionality and for me it works good... you refers to changing edge docking during runtime, or do you mean set the edge in the editor and on start of layout its fails to dock object?... or maybe you could send me a .capx with the fail... ¿did you dowloaded the last version?

    Edit: i forgot mention this, this plugin takes always the the last position of object as reference for docking and saves it internally, so when you disable the behavior its returns to that last position. If you sets param "keep size" to Enabled, the object wont be resized when docking and its will move to the chosen edge using actual coordinates as reference, e.g. if you docks to right and object is currently positioned at x=100, y=200, and have width = 100 and height = 50, will dock to the right at same Y coord in this case 200, and will have x = viewportrigth - width.

  • I'll put together an example but it was when I tried to use the runtime action to set it. However I think what's happening is that since it's already docked to the left and keep size is on. That when I try to dock it to the right it gets confused or something.

    So to repro it. Set to dock to left in the properties panel with keep size on. Then on start of layout set dock to right via an action.

    The debug screen will show a x and y position value of NaN and the object disappears.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)