Panels Moving

Is there a way to make a derma frame/panel fly in from off the screen?

PANEL:MoveTo()

When I do this, like if I want a panel to fly in from the right I cannot do negative to make the panel come from off the screen.

you have to set its pos off the screen.
like lets say its width is 200, and you want it to come in from the right, then set its pos to ScrW() + 200, and then use MoveTo

Okay. I see. Thank you!

I tried doing that with the top but the panel does not come in off of the screen

You can.

not with ScrH, I just tried it, it doesnt work, seems to be a bug.

Okay, this is pretty simple to create. Firstly, remind yourself that when working with the majority of all computer graphics, the origin (base point) is the top left. So, the top-left of your screen has the coordinates (0,0) and the bottom right of your screen has the coordinates (ScrW(), ScrH()).

This concept also applies with the positioning of panels within Garry’s Mod. The position you set to a panel is where you want the top-left corner of the panel to be. Now, you’ve said you wanted the panel to “come in from the right”? This would require the panel first being outside the right side of the screen. Below is a short snippet of code you could adapt and apply to your panel(s).

Create our panel and give it a size:



local DPanel = vgui.Create("DPanel")
DPanel:SetSize(200, 200)


Set the x-position of the panel to be off the right-side of our screen and set the y-position of the panel to be vertically centred.



DPanel:SetPos(ScrW(), (ScrH() - DPanel:GetTall())/2)


Begin to animate the panel, from the right, into the center of the screen. We’ve already centered the y-position, so we now just need to centre the x position.



local x, y = DPanel:GetPos()
DPanel:MoveTo((ScrW() - DPanel:GetWide())/2, y, 1)


You clearly didnt read, else you’d know this has been “solved” already.

Well, there appears to be some confusion above; so I thought I’d write a slightly more detailed solution. The one you provided isn’t really ‘understood’ as there is no need to add 200px to ScrW()… So, please do not be condescending to me about the clarity of me having read the thread.

Also, would you care to expand on this issue that you’ve ‘diagnosed’ as a bug?

I said “lets say its 200 px wide”, as an example…, again you didnt clearly read, and the bug has been moved to an other thread to prevent derailing.

Right, this will be my last post on this thread.
You can clearly see what you’ve told him to set the position to:

Which would effectively work but will cause the panel to move faster than would be intended (as the panel has some off-screen distance to travel).

“like lets say its width is 200, and you want it to come in from the right, then set its pos to ScrW() + 200, and then use MoveTo”

You still cant read, do you? The whole sentence is an example.