I’m trying to make a game in which… Is just an operating system, for fun
But then, I confront this problem, in which when I try to drag a window, it i’ll drag ALL OTHER instances of it, since in the code I programmed for only one part be draggable and the others will follow it.
Sorry if it was hard to understand, English is not my primary language.
Here’s my code:
Any help is appreciated, thanks! :3
I notice in your ‘WindowRight is being dragged’ event that you’re not moving WindowRight. I assume that happens automatically based on a behaviour…?
The actions in that event are hard to read, and perhaps the ordering is also causing issues here… I’d try reordering them as follows:
Hopefully that helps…
And yeah, that is because of the behavior
Did what BWPanda suggested really solve your actual problem?
No, but it cleared the code a bit so people could understand a bit better, I think that was what he meant to do
You mean you have several windows or do you mean by instances the different elements that compose the window (middle, minimize etc.)?
Are you using the draggable-behavior?
I didn’t quite understood, but when I say that “it’ll drag all other instances”, I mean that when I create a new window and then drag that, all the elements are dragged with that new window, including the ones from the other one.
Yes, but only on the “windowRight”
Maybe you can add variable to the object, and in the ‘WindowRight is being dragged’ add other condition SelectedWindow=“window1”.
You also need to add variable to the windowclose, windowminimize and windowmaximize etc.
If you have more than one window, each with their own minimize, maximize, etc. elements, it sounds like you’ll need to link each element to its matching WindowRight object (sorry I can’t recall the exact action name for this).
You need to use the ‘link two objects’- action and depending on the number of your elements several of them. You also need a ‘for each’- event since this is not applying only to one but potentially to a number of windows.
Here is a quick example (I just renamed the elements to make them fit better to your case). I can create these elements (or windows in your case) and drag them around without affecting other elements/windows. top is the part with the draggable-behavior attached.
As always there is probably a better way to do that but this suggestion works at least.
I’d suggest that instead of linking the objects, use the Sticker extension and add the sticky behaviour to the keep the parts together. Then you just need the drag behaviour on the main part of the window. The sticky behaviour will keep the other window sections attached and in the right place.