Page 1 of 1

Global codes Help. calling

PostPosted: Thu Sep 23, 2010 9:59 pm
by amanuob
Umm hello all can anyone help?
Ive been looking around in global code and learend that using
void myfunction(int XXX,int XXX)
{
function
}

but how do I call it?

by putting myfunction(yyy,yyy)
then????

help please XD....

Re: Global codes Help. calling

PostPosted: Thu Sep 23, 2010 10:19 pm
by DST
Yes, that is exactly how you call it.

Code: Select all
int iLoop(int xx, int ll, int ul){
if(xx>ul){xx=ll;}
else if(xx<ll){xx=ul;}
return xx;
}


is then called as
Code: Select all
x=iLoop(x, 0, 10);


int will return an integer. Notice the 'return xx' line in the function.

You can return almost anything...

int ()
float ()
char ()
void () - has no return.

Code: Select all
void nothing(int xx){
int i=xx;
}


Code: Select all
nothing(0);


Code: Select all
void evennothinger(){
}


Code: Select all
evennothinger();

Note: The iLoop function is how you might make pac-man move from one side of the screen to the other. (value, lower limit, upper limit); Will loop the integer if it is out of bounds.

x=iLoop(x, 0, view.width);

You could call this at the end of draw actor, after all the normal x functions were called (you can move pacman at will, then call this event at the end of draw actor just to make sure pacman stays onscreen).

x+=5;
x=iLoop(x, 0, view.width);

Once you make the function, it's name should be yellow when you type it in a normal script window (you may have to save and close the global code window first).

Re: Global codes Help. calling

PostPosted: Sat Sep 25, 2010 4:58 am
by amanuob
Thanx xD......