goaganesha
Programmer
Hi,
I’m making a videogame like spaceinvaders. Enemy ships are at the top of the screen moving from left to right. They are supposed to drop a shot under following circumstances :
1 :skullshotInAir = false (skullshotInAir is a global variable which is initially set to false in the first frame of the main scene) This variable makes shure there can only be one shot in the air at the same time.
2 :The enemy’s x position has to be in a range of +-7pixels of the "myship mc " This is to avoid that the "myship" can stand still for a long period.
3 : the skullship isn’t allready shot.
Here’s the code I put in the object panel of the "shot mc "
//===============================================
onClipEvent (enterFrame)
{
//min and max values my ship
myshippos = _root.myship._x;
myshipmin = myshippos - 7;
myshipmax = myshippos + 7;
//bounds skullship
bounds = _root.skulltotaal.skull.getBounds(_root);
xpos = ((bounds.xMax - bounds.xMin)/2) + bounds.xMin;
//conditions to fire
if(!_root.skullshotInAir && !_root.skullDead && xpos >= myshipmin && xpos <= myshipmax)
{
trace (_root.skullshotInAir);
this._x = xpos;
this._y = bounds.yMax + 20;
this._visible = true;
_root.skullshotInAir = true;
trace (_root.skullshotInAir);
}
else
{
if(this._y > 300)
{
this._visible = false;
_root.skullshotInAir = false;
}
else
{
this._y = this._y + 12;
}
}
}
//=============================================================
At the moment there are two "skullshipmc’s" and two "shot mc’s ". The 2 "skullmc’s" are in the "skulltotaal mc" which is moving from left to right.
Here’s what’s going wrong :
The shots start to fall when the skullship reaches the myship –7 xvalue but then the shot keeps hanging till it reaches the myship +7 xvalue and than it comes down. They are supposed to fall right away between these values .
Both shots fall even if there still is another shot from the other "skullmc" in the air.
Thanx for your help.
Regards, goaganesha
I’m making a videogame like spaceinvaders. Enemy ships are at the top of the screen moving from left to right. They are supposed to drop a shot under following circumstances :
1 :skullshotInAir = false (skullshotInAir is a global variable which is initially set to false in the first frame of the main scene) This variable makes shure there can only be one shot in the air at the same time.
2 :The enemy’s x position has to be in a range of +-7pixels of the "myship mc " This is to avoid that the "myship" can stand still for a long period.
3 : the skullship isn’t allready shot.
Here’s the code I put in the object panel of the "shot mc "
//===============================================
onClipEvent (enterFrame)
{
//min and max values my ship
myshippos = _root.myship._x;
myshipmin = myshippos - 7;
myshipmax = myshippos + 7;
//bounds skullship
bounds = _root.skulltotaal.skull.getBounds(_root);
xpos = ((bounds.xMax - bounds.xMin)/2) + bounds.xMin;
//conditions to fire
if(!_root.skullshotInAir && !_root.skullDead && xpos >= myshipmin && xpos <= myshipmax)
{
trace (_root.skullshotInAir);
this._x = xpos;
this._y = bounds.yMax + 20;
this._visible = true;
_root.skullshotInAir = true;
trace (_root.skullshotInAir);
}
else
{
if(this._y > 300)
{
this._visible = false;
_root.skullshotInAir = false;
}
else
{
this._y = this._y + 12;
}
}
}
//=============================================================
At the moment there are two "skullshipmc’s" and two "shot mc’s ". The 2 "skullmc’s" are in the "skulltotaal mc" which is moving from left to right.
Here’s what’s going wrong :
The shots start to fall when the skullship reaches the myship –7 xvalue but then the shot keeps hanging till it reaches the myship +7 xvalue and than it comes down. They are supposed to fall right away between these values .
Both shots fall even if there still is another shot from the other "skullmc" in the air.
Thanx for your help.
Regards, goaganesha