I am initalizing the "Location" of an object in my init function but when I go and try to use it in my "tick" function it seems as if the orginal initaliaztion of the object i thrown out the window. Its kind of hard to explain....take a look....
Code:
MyStarFighterAlien::MyStarFighterAlien(System::Resources::ResourceManager * Resources, MyStarFighter *ship, MyStarFighterAlien *alien, MyStarFighterBullet *bullet, MyStarFighterBomb *bomb):Animation(Resources)
{ this->resources = resources;
this->alien = alien;
this->bullet = bullet;
this->ship = ship;
this->bomb = bomb;
init(resources);
}
void MyStarFighterAlien::init(System::Resources::ResourceManager * Resources)
{
myDirection = 1;//Direction of alien flight
Point alienLoc = Point(newAx,newAy);
this->Image = Image::FromFile(String::Concat(Directory::GetCurrentDirectory(),S"\\alien.bmp"));
this->Location = System::Drawing::Point(0, 10);
this->Name = S"Alien";
this->Size = System::Drawing::Size(49, 32);
this->TabIndex = 1;
this->TabStop = false;
}
void MyStarFighterAlien::handleAlienTick(MyStarFighterAlien *alien, MyStarFighterBullet *bullet, MyStarFighterBomb *bomb)
{
int newAx = alienLoc.X + myDirection;
int newAy = alienLoc.Y;
Point newlocA = Point(newAx,newAy);
alienLoc = newlocA;
if (newAx > 505)//If alien goes off screen right change direction to left
{
myDirection = -1;
}
else if (newAx < -55)//If alien goes off screen left change directon to right
{
myDirection = 1;
}
}
As you can see the constructor calls the "initialaztion" function which initalizes the Location of the object to (0,10). But when I try to move the object in the "handleAlienTick" function it start at (0,0) not (0,10). So I am guessing there is something wrong with my logic in the "handleAlienTick" function. Any suggestions would be great.
Thanks
Chad