Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/23/26 21:52
WFO Training with parallel cores Zorro64
by Martin_HH. 02/23/26 15:29
Camera always moves upwards?
by clonman. 02/21/26 09:29
Zorro version 3.0 prerelease!
by TipmyPip. 02/20/26 13:22
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Martin_HH), 6,079 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Moveable Panels #407878
09/20/12 13:15
09/20/12 13:15
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
I want to make a panel move if the user drags a button.
When the users clicks and holds a button and drags it, I want the panel to move along with the mouse!
How do I do that??

Thanks for your consideration


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Moveable Panels [Re: Yashas] #407880
09/20/12 13:35
09/20/12 13:35
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
in your panel make an event like this

Code:
function move_panel(PANEL* p)
{
   while(mouse_left) //Only run while the left button is held
   {
       p.pos_x = mouse_pos.x;
       p.pos.y = mouse_pos.y;
       wait(1);
   } 
}

PANEL* BLAH =
{
      event = move_panel;
}



That should work for ya


John C Leutz II

Re: Moveable Panels [Re: lostzac] #407884
09/20/12 13:52
09/20/12 13:52
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I would first calculate the offset from the panel to the mouse position and then move it just like lostzac said:

Code:
function move_panel(PANEL* p)
{
   VECTOR tempVec;
   vec_set(tempVec, p.pos_x);
   vec_sub(tempVec, mouse_pos.x);
   
   while(mouse_left) //Only run while the left button is held
   {
       p.pos_x = mouse_pos.x + tempVec.x;
       p.pos.y = mouse_pos.y + tempVec.y;
       wait(1);
   } 
}

PANEL* BLAH =
{
      event = move_panel;
}



POTATO-MAN saves the day! - Random
Re: Moveable Panels [Re: Kartoffel] #407886
09/20/12 13:59
09/20/12 13:59
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Thanks


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Moveable Panels [Re: Kartoffel] #407887
09/20/12 13:59
09/20/12 13:59
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
Originally Posted By: Kartoffel
I would first calculate the offset from the panel to the mouse position and then move it just like lostzac said:


Yeah that is a better way, slapping himself in the forehead for not thinking about it


John C Leutz II


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1