Game Development Community

any difference, ways to call a variable.

by rennie moffat · in Torque Game Builder · 02/17/2010 (1:54 pm) · 6 replies

Is there any differnece between this...

%this.setPostion(%this.x, %this.y)
{
%x = 3;
%y = 3;
}

and this.....

%this.x = 3;
%this.y = 3;
%this.setPosition(%this.x, %this.y);



?

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
02/17/2010 (2:28 pm)
The first one won't work and will produce an error. The second one is ok.
#2
02/17/2010 (2:39 pm)
and why is that different from an if, while, for, else if, else?

simply because thats exactly what those are while, %this.thing(%this.putHere) is a string and thus needs to be closed via ;?


#3
02/17/2010 (4:41 pm)
Because you're first statement has brackets but the line preceding it isn't a valid command for brackets. A Function, IF, WHILE, FOR, etc would need brackets after it.

#4
02/17/2010 (5:25 pm)
and it is sort of like, when you have an if()...... this space here, doesn't need a terminator, aka semi colon. cause that terminates it.

I am going to like programming very much.



#5
02/17/2010 (11:20 pm)
I'm not sure the commands you're using will do what you want.

it looks like you're wanting to do %this.setPosition(3,3)...
#6
02/17/2010 (11:33 pm)
um no, the thing is I began building my game and noticed a lot of separate behaviors on multiple objects were going to have to talk to each other. Having a classBehavior I think worked as I can set up all data I need (foreseeable anyway) in the onBehavior add then manipulate it in the editor, instead of reloading my game all the time.

Anyways it is no worries, this thread began as a way for me to just get my coding basics down pat.

thanks