Crash when using datablocks

Posted by scorcher24 on Game Development See other posts from Game Development or by scorcher24
Published on 2012-04-06T12:26:02Z Indexed on 2012/04/06 17:43 UTC
Read the original article Hit count: 219

Filed under:
|

I have really throughly searched the net and could not find any solution for this so I ask for help here.

Anyway, I have this datablock in datablocks.cs:

    datablock t2dSceneObjectDatablock(EnemyShipConfig)  
{  
   canSaveDynamicFields = "1";  
   Layer = "3";  
   size = "64 64";  
   CollisionActiveSend = "1";  
   CollisionActiveReceive = "1";  
   CollisionCallback = true;  
   CollisionLayers = "3";  
   CollisionDetectionMode = "POLYGON";  
   CollisionPolyList = "0.00 -0.791 0.756 0.751 -0.746 0.732";     
   UsesPhysics = "0";  
   Rotation = "-90";  
   WorldLimitMode = "KILL";  
   WorldLimitMax = "880 360";  
   WorldLimitMin = "-765 -436";  

   minFireRate = "2000";  
   maxFireRate = "1200";  
   laserSpeed  = "800";  
   minSpeed    = "100";  
   maxSpeed    = "150";  
};  

This is an exact reproduction of an object that I have manually edited in the editor. So far, I just used clone() to get as many enemies as I need, while it was out of sight. It is a r-type style shooter, so I need a variable amount of enemies. Since clone() spams my log, I decided to use datablocks, since it is also more flexible.

That's what I get when I use clone():

Con::execute - 0 has no namespace: onRemoveFromScene

However, once spawning begins, my game freezes and crashes:

    function SpawnEnemy()  
{  
    //%spawnedEnemy = EnemyShipMaster.clone(true);  
    %spawnedEnemy = new t2dStaticSprite()  
    {  
       class         = "EnemyShip";  
       sceneGraph    = $global_sceneGraph;  
       datablock     = "EnemyShipConfig";    
       imageMap      = "starshipImageMap";  
       layer = 3;  
    };  

    %speed  = getRandom(%spawnedEnemy.minSpeed, %spawnedEnemy.maxSpeed);  
    %y      = getRandom(-320, 320);  

    // Set Properties  
    %spawnedEnemy.setPositionX(700);  
    %spawnedEnemy.setPositionY(%y);  
    %spawnedEnemy.setVisible(true);  
    %spawnedEnemy.setLinearVelocityX( -%speed );          
    %spawnedEnemy.setTimerOn( getRandom( %spawnedEnemy.maxFireRate, %spawnedEnemy.minFireRate ) );  
}  

// Definition of $global_sceneGraph from game.cs:  
$global_sceneGraph = sceneWindow2D.loadLevel(%level);  

As I said, it works fine when I use clone() (which is commented out here), but my log gets spammed. I really hope someone can shed some light for me, this is driving me crazy.

© Game Development or respective owner

Related posts about PC

Related posts about torque