Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/20/26 15:57
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (TipmyPip, Grant, AndrewAMD), 3,498 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
juergenwue, VladMak, Geir, ondrej, mredit
19208 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