View Full Version : shooting with attachMovie
mario_hater
January 15th, 2007, 12:20 PM
i finally figured out how to shoot with duplicateMovieClip but i always have one stray bullet. Is there a way to do it with the attachMovie? Are there any tutorials out there that would telle me how to do this?
bombsledder
January 15th, 2007, 05:45 PM
Ok
1.) Open up the library (Ctrl+L)
2.) Right click your bullet mc goto linkage...
3.) Check Export for ActionScript
4.) For Identifier put the name as "my_bullet" (or what ever you want it to be)
var temp_bullet:MovieClip=_root.attachMovie("my_bullet","my_bullet"+_root.getNextHighestDepth(),_root.getNextHighestD epth())
now if you changed the name of my_bullet you will have to replace it everywhere else,
this is pretty much the low-down on how to use the attachMovie
mario_hater
January 16th, 2007, 11:54 AM
thanks but how do you make the bullet keep going up? i have this code:
i = 0;
speed = 10;
onMouseDown = function () {
i++;
bullets = attachMovie("bullet", "bullet"+i, i);
bullets._x = _xmouse;
bullets._y = _ymouse;
};
onEnterFrame = function () {
bullets._y -= speed;
if (bullets._y<0) {
removeMovieClip(bullets);
}
};
the problem is that the bullets stop moving when i click again, anyone know how to fix this or what i'm doing wrong?
shortwod
January 18th, 2007, 04:06 AM
Here is the code that will make your bullets moving when you click again
var i:Number = 0;
var speed:Number = 10;
onMouseDown = function () {
i++;
var bullets = attachMovie("bullet", "bullet"+i, i);
bullets._x = _xmouse;
bullets._y = _ymouse;
bullets.onEnterFrame = function() {
bullets._y -= speed;
if (bullets._y<0) {
removeMovieClip(bullets);
}
};
};
this should work for you.
SacrificialLamb
January 18th, 2007, 04:54 AM
déjà vus (http://www.kirupa.com/forum/showthread.php?t=247132)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.