Author Topic: Calling a function on an object  (Read 429 times)

I've always been confused about this, and I will try to explain best I can. When you call some function from an object and there's only one variable do you have to put it?
For example:
Code: [Select]
function gameConnection::doStuff(%this)
when I call it I would do this
Code: [Select]
%this.doStuff();
or this?
Code: [Select]
%this.doStuff(%this);
Is there much of a difference/prefered way to do it?

Did a little searching and it seems like it would work either way? I'm still not completely sure, would it make a difference if the function had more than one variable? Would I include %this then? Or not include it?



You only have to include the object itself if you're doing direct namespace calling.

This is valid: %obj.doStuff();
This is valid: gameConnection::doStuff( %obj );

The advantage of direct namespace calling is that you can do stuff like this:
Code: [Select]
function myImage::onFire( %this, %obj, %slot, %x, %y )
{
wandImage::onFire( %this, %obj, %slot, %x, %y );
}