Moveable User interface - snapping issues

0 favourites
  • 8 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Hello there fellow nerds!

    I am currently creating a Moveable user interface that allows the player to...well....move the interface.

    I have currently got to a state where I have pinned events onto the frame and have a lock mechanism that enabled/disables the frame from being moved.

    This frame can be dragged (if unlocked) anywhere on the screen however, when I move the playable character outside of the standard window size area (854, 480), The user interface moves as if paralexed incorrectly and snaps to the extreme side of the screen, however this is not the case as the layer has a 0, 0 paralex.

    Below is a screenshot for the events I have just to show you I am not crazy hehe.

    pasteboard.co/1BWOpfJm.png

    Another point to add is that I have only been able to use the left/right viewport along with original windowheight as the other options were not valid.

    Thanks in advance to anyone that is willing to lend a hand on this matter!

    I look forward to receiving help

    Stay awesome.

    Chris

  • It is a bit unclear exactly what you are trying to do here. I mean obviously you want movable UI pieces, but they snap to... what exactly?

  • I see

    All of the User interface events are set on their own layer above the game layer, it has a 0, 0 parallax setting.

    The UI events should not be moved beyond the boundaries of the screen.

    In order to define the "boundaries of the screen" I have to compare the events in the screenshot above.

    Once the player has moved the User Interface events outside of the "boundaries of the screen", the user interface does successfully snap to the "boundaries of the screen". This only works while within the default window size and when this is no longer true the user interface events snap to the left/right side of the screen or moves as if paralaxed.

    The goal is simple. create a user interface that can be dragged within the boundries of the screen,

    once released from the dragdrop behaviours, it will stay there regardless of where the player is within the level.

    I'm not really sure what else I can convey :/

    Thanks for respondingGumshoe2029

  • What you might try doing is putting a thin sprite on each side of the screen just outside of the screen area, then just assign "Solid" to all of the boundaries, and 8-direction to all of the UI pieces.

  • You should use ViewPortLeft/Right/Bottom/Top and specify for which layer you want the coordinates. ViewPortRight(0) gives you the y coordinates of the visible right edge of layer 0. If layer 0 is not your UI layer, it will not work correctly. Also, since you are using a System Condition and not actual "Frames" conditions, I recommend you add "For each Frames" and put all 4 events under it, otherwise, unwanted behavior will most likely occur.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the replies guys/gals

    gum I want to optimise the performance of the game so while that method is easily implemented and pretty much guaranteed to work, I don't think it would be optimal to have the event there. I want to have 1 box of code that does all of the work rather then having unnecessary events that will slow down the game.

    MaGi the viewports only work for the viewport right and left for some reason =/

  • well I never...

    I was playing around with the program and ended up fixing it.

    here's a link to the completed program <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    pasteboard.co/1EdPQKgo.png

    I might put together a tutorial for this at some point too hehe

    Thanks for your assistance guy/gals! <3

  • That is usually how it works. My quote for this stuff is always: "Fiddle with it until it works or you break it."

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