Looping a spawn function.
by Georgina Benedetti · in Torque X 2D · 12/03/2010 (2:11 am) · 1 replies
Hi,
I'm trying to loop a spawn function where items continually spawn every two seconds. But I am having a bit of a problem. I am trying to loop a clone command but it seems that a whole heap of items are being cloned all at once rather than every second and then just stops cloning all together. My code is as follows:
function itemClass::spawner(%this)
{
for(%i = 0; %i < 10; %i++ )
{
if($alive = true)
{
%this.schedule(1000,"spawnItem", 0, 6, 3);
}
}
}
function itemClass::spawnItem(%this)
{
%newItem = %this.clone(true);
%newItem.setPositionY(getRandom(-203, -158));
%newItem.setPositionX(getRandom(-30, 25));
%newItem.setFrame(getRandom(0, 9));
}
can anyone help me out?
G
I'm trying to loop a spawn function where items continually spawn every two seconds. But I am having a bit of a problem. I am trying to loop a clone command but it seems that a whole heap of items are being cloned all at once rather than every second and then just stops cloning all together. My code is as follows:
function itemClass::spawner(%this)
{
for(%i = 0; %i < 10; %i++ )
{
if($alive = true)
{
%this.schedule(1000,"spawnItem", 0, 6, 3);
}
}
}
function itemClass::spawnItem(%this)
{
%newItem = %this.clone(true);
%newItem.setPositionY(getRandom(-203, -158));
%newItem.setPositionX(getRandom(-30, 25));
%newItem.setFrame(getRandom(0, 9));
}
can anyone help me out?
G
Torque Owner Arden