Page 1 of 1

Pointer Question

PostPosted: Sun Oct 14, 2012 12:54 am
by Soullem
I am trying to make a little soccer game and I have a code like this.
Code: Select all
Actor* xpointer = getclone("ManU.0");
Actor* ypointer = getclone("ManU.0");
Actor* xpointer1 = getclone("ManU.1");
Actor* ypointer1 = getclone("ManU.1");
xpointer->x;
ypointer->y;
xpointer1->x;
ypointer1->y;



if (abs(xpointer-Ball.x)<abs(xpointer1-Ball.x))
{
    P=0;
}
if (abs(xpointer-Ball.x)>abs(xpointer1-Ball.x))
{
    P=1;
}






Why wont it work??? It gives me an error message

Re: Pointer Question

PostPosted: Sun Oct 14, 2012 2:16 am
by Soullem
Nevermind figured it out

Re: Pointer Question

PostPosted: Sun Oct 14, 2012 2:43 am
by skydereign
For the record, variables are multi-use. Namely you can store the clone with the getclone, and use it whenever (you don't need one per variable).
Code: Select all
Actor* p1 = getclone("ManU.0");
Actor* p2 = getclone("ManU.1");

p1->x+=10;
p2->x+=10;
p1->y+=5;
p2->y+=5;

Re: Pointer Question

PostPosted: Sun Oct 14, 2012 2:58 am
by Soullem
Pointers are one of those things that I could not get untill I had this AHA moment. And now they are really simple and obvious. And thanks for the info about multi use. Will make my code look much better.