attempting to call function help!
by jerryg7rk3w · in General Discussion · 11/26/2010 (4:58 pm) · 2 replies
I keep getting this error every time i run my project in TGB.
game/gamescripts/player.cs (197) : unable to find object: '' attempting to call function 'start'
This is my code:
function PlayerShip::explode(%this)
{
%this.ship = new t2dstaticSprite()
{
scenegraph = %this.scenegraph;
class = shipblinking;
player = %this;
};
%this.shipblinking.start();
}
function shipblinking::start(%this)
{
// Pick the image and set its size
%this.setImageMap(shipImageMap);
%this.setSize(31.598, 15.799);
%this.setlayer(5);
%this.setPositionX(%this.player.getPositionX() + 1);
%this.setPositionY(%this.player.getPositionY() + 1);
%cameraViewBounds = sceneWindow2D.getCurrentCameraArea();
%this.setWorldLimit( kill, getword(%cameraViewBounds, 0) - (%this.getWidth() / 2),
getword(%cameraViewBounds, 1) - (%this.getHeight() / 2),
getword(%cameraViewBounds, 2) + (%this.getWidth() / 2),
getword(%cameraViewBounds, 3) + (%this.getHeight() / 2) );
// Turn on collision, but turn off physics
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}
The funny thing is the same exact code works fine for a tutorial im following. Theirs has the following code, now i know its not the same exact code 100% but its set up the same way.
function PlayerShip::fireMissile(%this)
{
// Create a missile
%this.playerMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = PlayerMissile;
missileSpeed = %this.missileSpeed;
player = %this;
};
// Fire the missile
%this.playerMissile.fire();
}
function PlayerMissile::fire(%this)
{
// Pick the image and set its size
%this.setImageMap(playerMissileImageMap);
%this.setSize(6.25, 3.125);
%this.setlayer(5);
// Set the missile position to where the player is, plus
// a small offset so that the missile lines up with missile
// launcher in the player ship image
%this.setPositionX(%this.player.getPositionX() + 1);
%this.setPositionY(%this.player.getPositionY() + 1);
%this.setLinearVelocityX(%this.missileSpeed);
// Use the camera view bounds as the basis for the missile's world limits
%cameraViewBounds = sceneWindow2D.getCurrentCameraArea();
%this.setWorldLimit( kill, getword(%cameraViewBounds, 0) - (%this.getWidth() / 2),
getword(%cameraViewBounds, 1) - (%this.getHeight() / 2),
getword(%cameraViewBounds, 2) + (%this.getWidth() / 2),
getword(%cameraViewBounds, 3) + (%this.getHeight() / 2) );
// Turn on collision, but turn off physics
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}
So what is causing my code not to work, its set up the same exact way the tutorial is so how can i tweak mine to make it work?
game/gamescripts/player.cs (197) : unable to find object: '' attempting to call function 'start'
This is my code:
function PlayerShip::explode(%this)
{
%this.ship = new t2dstaticSprite()
{
scenegraph = %this.scenegraph;
class = shipblinking;
player = %this;
};
%this.shipblinking.start();
}
function shipblinking::start(%this)
{
// Pick the image and set its size
%this.setImageMap(shipImageMap);
%this.setSize(31.598, 15.799);
%this.setlayer(5);
%this.setPositionX(%this.player.getPositionX() + 1);
%this.setPositionY(%this.player.getPositionY() + 1);
%cameraViewBounds = sceneWindow2D.getCurrentCameraArea();
%this.setWorldLimit( kill, getword(%cameraViewBounds, 0) - (%this.getWidth() / 2),
getword(%cameraViewBounds, 1) - (%this.getHeight() / 2),
getword(%cameraViewBounds, 2) + (%this.getWidth() / 2),
getword(%cameraViewBounds, 3) + (%this.getHeight() / 2) );
// Turn on collision, but turn off physics
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}
The funny thing is the same exact code works fine for a tutorial im following. Theirs has the following code, now i know its not the same exact code 100% but its set up the same way.
function PlayerShip::fireMissile(%this)
{
// Create a missile
%this.playerMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = PlayerMissile;
missileSpeed = %this.missileSpeed;
player = %this;
};
// Fire the missile
%this.playerMissile.fire();
}
function PlayerMissile::fire(%this)
{
// Pick the image and set its size
%this.setImageMap(playerMissileImageMap);
%this.setSize(6.25, 3.125);
%this.setlayer(5);
// Set the missile position to where the player is, plus
// a small offset so that the missile lines up with missile
// launcher in the player ship image
%this.setPositionX(%this.player.getPositionX() + 1);
%this.setPositionY(%this.player.getPositionY() + 1);
%this.setLinearVelocityX(%this.missileSpeed);
// Use the camera view bounds as the basis for the missile's world limits
%cameraViewBounds = sceneWindow2D.getCurrentCameraArea();
%this.setWorldLimit( kill, getword(%cameraViewBounds, 0) - (%this.getWidth() / 2),
getword(%cameraViewBounds, 1) - (%this.getHeight() / 2),
getword(%cameraViewBounds, 2) + (%this.getWidth() / 2),
getword(%cameraViewBounds, 3) + (%this.getHeight() / 2) );
// Turn on collision, but turn off physics
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}
So what is causing my code not to work, its set up the same exact way the tutorial is so how can i tweak mine to make it work?
Associate Rene Damm
should be
i.e. slight mixup of the property and class name here.