Passing variables?
by Kevin James · in Torque Game Builder · 04/07/2010 (10:45 am) · 3 replies
function SectorLevel::onLevelLoaded(%this)
{
$CurSector=%this;
lblSector.text = "Sector:" SPC %this.sector;
%this.MakeCell(44,-30);
}This puts the cell somewhere off scene (not where I want it):
function SectorLevel::MakeCell(%x,%y)
{
%Cell = new t2dStaticSprite() {
sceneGraph = $CurSector;
Position = %x SPC %y;
};
}This puts it where I want it, but obviously I need to know why it doesn't work when I pass in the variables from another function:
function SectorLevel::MakeCell(%x,%y)
{
%x = 44;
%y = -30;
%Cell = new t2dStaticSprite() {
sceneGraph = $CurSector;
Position = %x SPC %y;
};
}About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
Torque Owner RollerJesus
Dream. Build. Repeat.
TGB is probably choking because it is exepecting %this to be the first argument passed in a class method but it's getting %x.
Try this:
function SectorLevel::MakeCell(%this, %x,%y) { %Cell = new t2dStaticSprite() { imagemap = "IMAGEMAPNAME"; sceneGraph = $CurSector; Position = %x SPC %y; }; }