00:00
00:00
Newgrounds Background Image Theme

Thuy78 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Following/shooting At Mouse

33,939 Views | 190 Replies
New Topic Respond to this Topic

Response to As: Following/shooting At Mouse 2007-09-29 00:21:55


That didn't work :(

Response to As: Following/shooting At Mouse 2007-10-20 22:52:29


Hey I am in trouble here
I've used the tutorial you have given at the Front Page
and when I put the gun mc in the character mc it does not works
help!!!!!!!!!!!!!!!!

Response to As: Following/shooting At Mouse 2007-12-08 13:21:32


At 12/5/07 04:41 PM, Psycho wrote: Not sure if it's been mentioned before, but if the pointing at mouse code is given to a movieclip inside another movieclip, it messes up. I tried playing around with the code, but have no idea what to change.

Basically you're making point towards the _x of the movie clip. Instead of _root._xmouse you put: _root.MC_INSIDE._xmouse. So the MC the turret is inside would ahve the instance name of MC_INSIDE

Therefore the code would be:

onClipEvent (mouseMove) {
Xd =_root.MC_INSIDE._xmouse-_x;
Yd =_root.MC_INSIDE._ymouse-_y;
radAngle = Math.atan2(Yd, Xd);
_rotation = int((radAngle*360 / (2*Math.PI))+90);
updateAfterEvent();
}


They used to call me souled...

Response to As: Following/shooting At Mouse 2007-12-14 01:27:17


Im trying to have multiple, but this code doesnt seem to work. Can anyone help?
var bc = 1000;
_root.onMouseDown = function() {
bc++;
if (bc>1100) {
bc = 1000;
}

duplicateMovieClip("bullet", "b"+bc, bc);
};
var bc = 1000;
_root.onMouseDown = function() {
bc++;
if (bc>1100) {
lc = 1000;
}

duplicateMovieClip("laser", "l"+bc, bc);
};
var bc = 1000;
_root.onMouseDown = function() {
bc++;
if (bc>1100) {
lc = 1000;
}
t
duplicateMovieClip("laser1", "l1"+bc, bc);
};

Response to As: Following/shooting At Mouse 2007-12-16 18:27:10


ok so heres for all the people who have wondered how to make it so you can fire auto but it fire every other second. Well here we go
put this code on your gun

onClipEvent(load) {_root.timer = 0}
onClipEvent(enterFrame){_root.timer++}

So timer is the var telling when it can shoot or not
so heres the bullet code. Bare with me as i try to explain
var bc = 1000;
//Bulletcount
var shooting = false;
//shooting boolean/trigger basicaly
var timer = 0;
//timer
var d = 0;
//delay time in shooting
_root.onMouseDown = function() {
shooting = true;
};
onEnterFrame = function () {
if (shooting) {
bc++;
//sets the bullet count higher so that it dosent over lap each time
if (bc>1200) {
bc = 1000;
//if you shoot more then 200 bullets then it will destroy them
}
if (timer>=1) {
//if the timer is greater then 1 it will shoot
duplicateMovieClip("bullet", "b"+bc, bc);
//creates the duplicate of the bullet
timer = -d;
//this is where the delay comes in.
}
}
};
onMouseUp = function () {
shooting = false;
//your not shooting anymore
};

as you can see i would mess around with the D var, so that you can have a diff type of delay. For me i did a code that reloved around my gun
ex:(might not work)
put on gun

onClipEvent(load) {
_root.gun = "pistol"
}
onClipEvent(enterFrame) {
if(_root.gun  =="pistol") {
_root.d = blah(make it w/e you want)
this.gotoAndStop("pistol")
}
}

Thats about it. I hope it works for you.


BBS Signature

Response to As: Following/shooting At Mouse 2008-01-17 21:26:21


Gimme me a script that makes the player cover and not cover then continue shooting..


Mystery is singing some crap and ugly songs xD Joking!

BBS Signature

Response to As: Following/shooting At Mouse 2008-01-19 13:22:49


At 1/17/08 09:26 PM, cashleycool wrote: Gimme me a script that makes the player cover and not cover then continue shooting..

Dude..

Response to As: Following/shooting At Mouse 2008-01-19 13:27:49


At 12/16/07 06:27 PM, Healthy wrote:

Instead of putting in a delay, why not just have bc += something_less_than_1?


They used to call me souled...

Response to As: Following/shooting At Mouse 2008-02-05 12:39:36


Hey guys i need the code for making a guy go on a track and gravity

Response to As: Following/shooting At Mouse 2008-02-05 13:44:30


At 1/17/08 09:26 PM, cashleycool wrote: Gimme me a script that makes the player cover and not cover then continue shooting..

No...but please make your own.

At 2/5/08 12:39 PM, taco857 wrote: Hey guys i need the code for making a guy go on a track and gravity

Good for you, now learn to actionscript and return with a real question!

Response to As: Following/shooting At Mouse 2008-02-05 16:04:00


Cool. I might be able to use this in the future.

Is it possible to do this with attachMovieClip instead of duplicate though?


"Be peaceful, be courteous, obey the law, respect everyone; but if someone puts his hand on you, send him to the cemetery"

Personal Development

Response to As: Following/shooting At Mouse 2008-02-06 00:40:27


Hey, thanks man! The other tutorials I saw for this stuff spanned 10 or so pages and were unclear, so you've really saved me heaps'a time!

Response to As: Following/shooting At Mouse 2008-02-06 01:47:14


Sorry to be a pester. In fact this is the first time a script like this has worked for me. but I do have a question. Is there anyway i can get the bullet to not appear until its outside the range of the gun. Cuz i made a tank and i noticed that the bullet came out of the buttom of the turret. So i tried to make a whole outline around it and mask it (xD). Then i tried to make a seperate barrel inside the turret so they wud both rotate but instead the barrel only rotated in a weird way (like the guy above me mentioned. so if any1 can tell me how to hide the bullet until its outside the barrel that wud be great.
(im no good at actionscript but i did what you said and end up understanding around a quarter of the code...wudnt know how to reproduce it for my life tho.


I think I would enjoy eating fruit more if it screamed when I bit into it.

BBS Signature

Response to As: Following/shooting At Mouse 2008-03-08 10:20:41


At 9/6/05 08:51 PM, CUCKA-DUDE wrote: Thanks, i had already posted a game at

http://img377.images..ssinteractive8ee.s wf


CLick the gun to shoot.

It didn't Seem to work for me, and the gun rotates on the wrong point. Break the MC Apart then remake it with the registration in the centre.

Response to As: Following/shooting At Mouse 2008-03-08 10:25:11


At 3/8/08 10:20 AM, Serpent60 wrote: It didn't Seem to work for me, and the gun rotates on the wrong point. Break the MC Apart then remake it with the registration in the centre.

Look before you bump dude. That guy must have figured out his mistake by now seeing as its been three years.

Response to As: Following/shooting At Mouse 2008-03-08 12:37:58


Hey.. if anyone can get me a script for reloading.. because I tried my own.. but it doesn't work. so if you can... could you make a script of this with the gun reload/limit. Thank you, and yes, I did try the ones before this post, they won't work. Please help.

Response to As: Following/shooting At Mouse 2008-04-05 13:01:52


I can make the gun rotate and all, even shoot rapid fire but I can't make the bullets appear from the muzzle flash, this is really getting annoying, can anyone please help?

Response to As: Following/shooting At Mouse 2008-04-11 21:15:43


At 9/6/05 04:54 PM, liaaaam wrote: Click me plz

Good tutorial =D

du u have a tutorial on making that? i made a game and i cant make him shoot and move like that

As: Following/shooting At Mouse


ima chargin my lazar... shoop da woop

BBS Signature

Response to As: Following/shooting At Mouse 2008-04-13 11:10:51


thanks man im using this for an army game.

and wouldn't it be better if you make bullet count do this

var bc = 1000;
_root.onMouse = function() {
<bold>bc--;
if (bc<100) {
bc = 1000;
}</bold>
duplicateMovieClip("bullet", "b"+bc, bc);
}

so it minus and make a dynamic box so you can see how many bullets you have
just a thought, thanks again

Response to As: Following/shooting At Mouse 2008-04-13 11:13:00


At 4/13/08 11:10 AM, coreymaroc wrote:
<bold>bc--;
if (bc<100) {
bc = 1000;
}</bold>

just without the bold in it

Response to As: Following/shooting At Mouse 2008-04-20 17:28:19


My character no longer aims towards the mouse.

He aims at approximately a 90 degree angle upward from where my mouse is located.

Help please?

Response to As: Following/shooting At Mouse 2008-05-11 19:39:15


I can't figure this out. OK I will use a visual for explanation. I want my gun to rotate from where the green dot is and I need the bullets to come from the red dot. Please help, nothing I have tried works.

As: Following/shooting At Mouse

Response to As: Following/shooting At Mouse 2008-05-15 10:01:23


Hey Denvish can I use ur code in a game that contains Newgrounds API (Flash Ad's); I though I'd ask you since it is your work. I'll PM you about it to.

Response to As: Following/shooting At Mouse 2008-05-15 10:09:33


At 5/15/08 10:01 AM, Brycearoni wrote: Hey Denvish can I use ur code in a game that contains Newgrounds API (Flash Ad's); I though I'd ask you since it is your work. I'll PM you about it to.

Although good practice to ask developers about using their code. You don't have to ask to use anything in the AS:Main that is why it was created.

Response to As: Following/shooting At Mouse 2008-05-22 17:57:49


it doesnt work


...

BBS Signature

Response to As: Following/shooting At Mouse 2008-05-24 16:08:54


So, how would I go about making the shooting a little bit more random? Like a spray?

Response to As: Following/shooting At Mouse 2008-07-30 13:34:21


Really informative, nice one denvish =)


Click my sig for a hilarious thread.

BBS Signature

Response to As: Following/shooting At Mouse 2008-08-22 04:21:50


great guide but I have a problem!! all of the angles r realy messed up and My player shoots the bullets 90 degrees right of my mouse. ive tried to change the angles but its still doesnt work. any help?

Response to As: Following/shooting At Mouse 2008-09-10 00:32:54


Savior.


Zelda is like high-fructose-corn-syrup-based cookies with extra MSG preserverative, it never goes bad!

Response to As: Following/shooting At Mouse 2008-09-12 15:48:40


can someone please JUST make a sidescroller shooter tutorial please