- i have my enemies just spawning in same spot forever
id like to set up a global variable that will increase when i press right
and then when that variable reaches certain numbers… like 300 and 600
i want an enemy to be attached - if u test this youll see enemies coming from one side
how would i make them come from both sides
HERE IS A DEMO
if you know how to solve either of these please by all means assist
all im doing is attachin a movie using
a copied code…
dont get me wrong i can completely remake this whole code its pretty much the only enemy ai code i ever used and ive tweaked it from bottom to top plenty of times
what it does is attaches an enemy and the enemy follows the AIzombie function
which tells it to walk or die and if i hit any of the monstersinscene they die and are removed from the stage
which will then make another respawn
this isnt the code that i will use if someone can help me with the global variable thing im asking for
i want it so that when my character is moving right the global variable called MainX is increasing by increments of 10
and once it reaches 200 i want to have a movie attached at at the coordinates _x:600, _y:305 and i want the movieclip to follow the same function that is listed below but ill take out the part that makes it spawn again
[SIZE=5]my character movement is basic[/SIZE]
**hero.step=15;
hero.attack = false;
hero.stance= 1;
hero.crouch=false;
**
**this.onEnterFrame = function()
{****if (Key.isDown (Key.RIGHT) )
{
hero._xscale = 100;
hero.stance=1;
hero._x+=hero.step;
hero.gotoAndStop(“walk”);
}
[SIZE=6][COLOR=Navy]
[/COLOR][/SIZE][SIZE=6][COLOR=Navy]this is the enemy spawn code [/COLOR][/SIZE][SIZE=6][COLOR=Navy]
[/COLOR][/SIZE]**** SpawnEnemy = function ()
{
//INITIALISE VARS
attachedObj = _root.attachMovie("zombie", "brownzombie"+tag, 9, {_x:600, _y:305});
attachedObj.health = 100;
attachedObj.speed=5;
attachedObj.hit=false;
attachedObj.alive = true;
attachedObj.gotoFunction = AIZombie;
MonstersInScene.push(attachedObj);
//MonstersInScene
tag++;
}
function AIZombie()
{
if(this.alive)
{
this.gotoAndStop(“walk”);
//YOUR FIRST AI
if(tukelay._x<=this._x-80)
{
this._xscale = 100;
this._x-=this.speed;
}
else if(tukelay._x>=this._x+80)
{
this._x+=this.speed;
this._xscale = -100;
}
//We have to add a small offset of + and - 20
//to stop the zombie
//from 'flickering' when he's close. Remove the numbers- you'll see what I mean
}
else
{
this.gotoAndStop("dead");
//Activates the dying animation, which automatically removes this movie clip/sprite
//when it reaches the final frame
}
}
function RenderEnemy()
{
for (counter=0;counter < MonstersInScene.length;counter++)
{
MonstersInScene[counter].gotoFunction();
if(tukelay.attack)
{
if(tukelay.hitTest(MonstersInScene[counter]))
MonstersInScene[counter].alive=false;
}
if(MonstersInScene[counter]._x==null)
{
MonstersInScene.splice(counter,1);
SpawnEnemy();
} ** sorry thats alot but all i need is someone to help me out or guide me in making
a global x variable that increases as my character moves right and when the global x reaches
200 attach an enemy