Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,387 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
about pan_setbutton`s question #336658
08/05/10 16:22
08/05/10 16:22
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Code:
function buttonpro(var i){
	switch (i)
	{
		case 0:
			gv=2;	
		break;
		case 1:
			gv=3;
		break;
	}
}	

pan_setbutton(gp[0],0,1, // set a new push button for quitting the game
     			10,10,gb[1],gb[2],gb[3],NULL,buttonpro(1),NULL,NULL);


buttonpro(1) is error,i want set function parameter for buttonpro.is it impossibility?

Last edited by frankjiang; 08/05/10 16:24.

development 3d game is interesting!
Re: about pan_setbutton`s question [Re: frankjiang] #336663
08/05/10 16:48
08/05/10 16:48
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
if then can`t set function parameter ,i write code like this :
--------------------------------------------------------------------------------
function buttonpro(var i){
var x = mouse_pos.x;
var y = mouse_pos.y;
if(x>=0&&x<=40){
if(y>=0&&y<=20){//btn1
gv = 20;
}
if(y>=40&&y<=60){//btn2
gv = 60;
}
}
}
pan_setbutton(gp[0],0,1,0,0,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL); //btn1
pan_setbutton(gp[0],0,1,0,40,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL);//btn2
--------------------------------------------------------------------------------


development 3d game is interesting!
Re: about pan_setbutton`s question [Re: frankjiang] #336742
08/05/10 22:32
08/05/10 22:32
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

If you wrote the following line like this
Quote:

pan_setbutton(gp[0],0,1, // set a new push button for quitting the game
10,10,gb[1],gb[2],gb[3],NULL,buttonpro(1),NULL,NULL);

Then you should write it like

pan_setbutton(gp[0],0,1, 10,10,gb[1],gb[2],gb[3],NULL,buttonpro(1),NULL,NULL); // set a new push button for quitting the game


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: about pan_setbutton`s question [Re: frankjiang] #336749
08/05/10 23:07
08/05/10 23:07
Joined: Mar 2002
Posts: 1,774
Magdeburg
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

Joined: Mar 2002
Posts: 1,774
Magdeburg
buttonpro(1) assigns not the functions itself (resp a pointer to the function) but its return value.

Code:
pan_setbutton(gp[0],0,1,	10,10,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL);



You can only use it without the bracket and you cannot pass any arguments to the function urself.
Anyway the button functions gets - the number of the button in the panel - automatically passed as first argument and this might be waht u need/want


I <3 LINQ
Re: about pan_setbutton`s question [Re: FlorianP] #336764
08/06/10 01:08
08/06/10 01:08
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
thanks ,guys.

did you have any good idea to design it?
pan_setbutton(gp[0],0,1,10,10,gb[1],gb[2],gb[3],NULL,buttonpro(1),NULL,NULL);

is it possiable to pass any arguments for buttonpro?
if not,did you have any good ideas to do that?
...............................................................................
why i want to do write code like this:buttonpro(1)?
my point of view:
in code files,just used a few of functions to do any things like butt on events.
one panel objest has 3 buttons events ,so you must be to creat 3 functions . i think it is not better than just used one functions .
if there are much more function`s name ,it`s so hard to mangaged them.

well,just want to find a good way to managed my codes. it is so import.



ok show my idea,just used one function to control their events,and different for your mouse postion.
Code:
var gv;
function buttonpro(var i){
   var x = mouse_pos.x;
   var y = mouse_pos.y;
   if(gp[0].flag=SHOW){   //gp[0] is a panel object
      if(x>=0&&x<=40){
          if(y>=0&&y<=20){//btn1
            gv = 20;
          }
          if(y>=40&&y<=60){//btn2
            gv = 60;
          }
       } 
    }
}
pan_setbutton(gp[0],0,1,0,0,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL); //btn1
pan_setbutton(gp[0],0,1,0,40,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL);//btn2



Last edited by frankjiang; 08/06/10 01:27.

development 3d game is interesting!
Re: about pan_setbutton`s question [Re: frankjiang] #336776
08/06/10 07:15
08/06/10 07:15
Joined: Mar 2002
Posts: 1,774
Magdeburg
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

Joined: Mar 2002
Posts: 1,774
Magdeburg

Code:
var gv;
function buttonpro(var i, PANEL* p)
{
   if (p == my_firstPanel)
   {
     //only if this specific panel is clicked
     if (i == 1)
     {
        //first button of the panel
     }
     if (i== 2)
     ....
   }
   if (p == my_secondPanel)
   {
   .....
   }
}
pan_setbutton(gp[0],0,1,0,0,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL); //btn1
pan_setbutton(gp[0],0,1,0,40,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL);//btn2



The function gets the number of the button and a pointer to the panel passed automatically.


I <3 LINQ
Re: about pan_setbutton`s question [Re: FlorianP] #336782
08/06/10 08:38
08/06/10 08:38
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
thanks ,FlorianP
how to you know that?

Last edited by frankjiang; 08/06/10 09:17.

development 3d game is interesting!
Re: about pan_setbutton`s question [Re: frankjiang] #336795
08/06/10 11:50
08/06/10 11:50
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
From the manual wink


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

Gamestudio download | chip programmers | 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