Well, I am developing a Tower defense game and I need some help with the duplicating movie clip and also another few thing. When I open my game and try to add a tower it doesn’t seem to add a new clip? When you click the button of the tower in the store there is a ‘clear’ button that appears above the playing field. There is a variable set to true when you click to buy the turret. When you click the ‘clear’ button, it should duplicate a movie clip that is out of view (but still added to the canvas), and add it at the mouses position.
Here is the A.S. that is on the ‘clear’ button above the playing field:
on (release) {
_root.adding = false; // sets the adding var to false
if (_root.adding_type == "green") { // checks the type of turret the player is adding
_root.green_turrets = Number(_root.green_turrets)+1; // add to the amount of green turrets
duplicateMovieClip(add_green,"green_turret" + _root.green_turrets, 1); // duplicates the green turret that is hidden (but still on the canvas)
// this is where I get lost:
setProperty("green_turret" + _root.green_turrets,_x,_xmouse); // Tries to change the x position of the new movie clip
setProperty("green_turret" + _root.green_turrets,_y,_ymouse);// Tries to change the y position of the new movie clip
} else {
// add other turret here later -.-"
}
gotoAndStop(1);
}
And here is the A.S when you click to buy the turret in the store:
on (rollOver) {
details1.gotoAndStop(3); // shows the details of the turret
}
on (rollOut) {
details1.gotoAndStop(1); // hides the details of the turret
}
on (release) {
if (_root.money <= 15) {} else { // checks if player has enough money for the turret
_root.money = number(_root.money) - 15; // takes money from player's bank
_root.money_vis.text = Number(_root.currentWave); // displays new amount of money
_root.adding = true; // sets the adding var to true (durr?)
_root.adding_type = "red"; // sets the type of turret that the player is adding
_root.add_feild_mc2.gotoAndStop(2); // shows the 'clear' button on top of the playing field.
_root.turrets.gotoAndStop(1); // closes the shop.
}
}
Thanks for any help, Andrew