Forum Topic: Shooting objects =[

(141 views • 11 replies)

This topic is 1 page long.

<< < > >>
Sad

Spiff

Reply To Post Reply & Quote

Posted at: 10/6/08 09:21 PM

Spiff LIGHT LEVEL 09

Sign-Up: 06/24/06

Posts: 1,096

Can someone please help me with my code so that it will shoot the desired object? All it does is make the movie clip stick to the player ship.

if (Key.isDown(Key.SPACE)) {
this.attachMovie("missle", "missle"+i, i);
_root.missle.xv = 10;
_root.missle._x += missle.xv;

PM me for a Signature. | Add me on Steam: Sneakers25


None

BleeBlap

Reply To Post Reply & Quote

Posted at: 10/6/08 11:21 PM

BleeBlap LIGHT LEVEL 24

Sign-Up: 03/08/05

Posts: 944

Try:

At 10/6/08 09:21 PM, Spiff wrote: if (Key.isDown(Key.SPACE)) {
this.attachMovie("missle", "missle"+i, i);
_root.missle.xv = 10;

_root.missle.onEnterFrame = function () {

_root.missle._x += missle.xv;

}


None

zedd56

Reply To Post Reply & Quote

Posted at: 10/6/08 11:27 PM

zedd56 LIGHT LEVEL 14

Sign-Up: 08/31/07

Posts: 1,475

At 10/6/08 09:21 PM, Spiff wrote: Can someone please help me with my code so that it will shoot the desired object? All it does is make the movie clip stick to the player ship.

if (Key.isDown(Key.SPACE)) {
this.attachMovie("missle", "missle"+i, i);
_root.missle.xv = 10;
_root.missle._x += missle.xv;

If i am correct, what you are doing is that you are executing this line:

_root.missle._x += missle.xv;

only one time, whereas you want it to be moving 10 pixels to the right every frame.
The above solution should work.

I've been noticing a LOT of AS help threads around here. We should really have one massive thread. It would clear up SOOOO many of those junk threads with 1 question post, 1 crappy answer post, 1 final answer post, and 1 thanks, problem resolved post.
Makes 4 posts, and the thread is never to be seen again. Seriously, it's a massive waste of space.


None

Spiff

Reply To Post Reply & Quote

Posted at: 10/7/08 03:20 PM

Spiff LIGHT LEVEL 09

Sign-Up: 06/24/06

Posts: 1,096

This provides me with the same result. Missle does not go anywhere.

PM me for a Signature. | Add me on Steam: Sneakers25


None

zedd56

Reply To Post Reply & Quote

Posted at: 10/7/08 04:22 PM

zedd56 LIGHT LEVEL 14

Sign-Up: 08/31/07

Posts: 1,475

provide a bit more code and maybe an fla. At least a swf so we can see what's going on.


None

UnknownFury

Reply To Post Reply & Quote

Posted at: 10/7/08 04:30 PM

UnknownFury EVIL LEVEL 26

Sign-Up: 08/10/05

Posts: 6,027

At 10/6/08 11:27 PM, zedd56 wrote: I've been noticing a LOT of AS help threads around here. We should really have one massive thread. It would clear up SOOOO many of those junk threads with 1 question post, 1 crappy answer post, 1 final answer post, and 1 thanks, problem resolved post.
Makes 4 posts, and the thread is never to be seen again. Seriously, it's a massive waste of space.

Don't be stupid. The whole idea of this forum is for people to ask questions. Why sqaush it all up in one thread? Duh.

Try:

if (Key.isDown(Key.SPACE)) {
this.attachMovie("missle", "missle"+i, i);
_root["missle"+i].xv = 10;
_root["missle"+i].onEnterFrame = function(){
this._x += this.xv;
}

Portfolio(Under construction): UnknownFury.com |
Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com
Follow me on twitter!


None

Spiff

Reply To Post Reply & Quote

Posted at: 10/7/08 04:37 PM

Spiff LIGHT LEVEL 09

Sign-Up: 06/24/06

Posts: 1,096

At 10/7/08 04:30 PM, UnknownFury wrote:
At 10/6/08 11:27 PM, zedd56 wrote: I've been noticing a LOT of AS help threads around here. We should really have one massive thread. It would clear up SOOOO many of those junk threads with 1 question post, 1 crappy answer post, 1 final answer post, and 1 thanks, problem resolved post.
Makes 4 posts, and the thread is never to be seen again. Seriously, it's a massive waste of space.
Don't be stupid. The whole idea of this forum is for people to ask questions. Why sqaush it all up in one thread? Duh.

Try:

if (Key.isDown(Key.SPACE)) {
this.attachMovie("missle", "missle"+i, i);
_root["missle"+i].xv = 10;
_root["missle"+i].onEnterFrame = function(){
this._x += this.xv;
}

Ugh, that's not working either. All that happens is it creates the missle, but it sticks to the player ship. do I have to do something to make it detach from the ship?

PM me for a Signature. | Add me on Steam: Sneakers25


None

zedd56

Reply To Post Reply & Quote

Posted at: 10/7/08 05:17 PM

zedd56 LIGHT LEVEL 14

Sign-Up: 08/31/07

Posts: 1,475

wouldn't "this.attachMovie" attach the mc inside the ship mc?
Not sure, like i said before, i am a programmer, just new to AS.

try _root.attachMovie. Keep everything else the same.


None

Spiff

Reply To Post Reply & Quote

Posted at: 10/7/08 05:43 PM

Spiff LIGHT LEVEL 09

Sign-Up: 06/24/06

Posts: 1,096

I'm about ready to give up. I don't understand why the code isn't working. It should be, without any issues.

PM me for a Signature. | Add me on Steam: Sneakers25


None

Spiff

Reply To Post Reply & Quote

Posted at: 10/7/08 05:56 PM

Spiff LIGHT LEVEL 09

Sign-Up: 06/24/06

Posts: 1,096

Alright, I put this code into the missle movie clip.

onClipEvent(load) {
this.xv = 10;
missleCount = 0;
}
onClipEvent(enterFrame) {
this._x += this.xv;
if (Key.isDown(Key.CONTROL)) {
missleCount++;
this.duplicateMovieClip("missle", "missle"+i, i);
_root["missle"+misslecount]._x =_root.playership._x;
_root["missle"+misslecount]._x =_root.playership._y;
}
}

it works, but if I press control again, it takes the first missle and puts it back at the start position. Can I make it so that it will create a new one every time I press control, instead of taking the old one?

PM me for a Signature. | Add me on Steam: Sneakers25


None

korded

Reply To Post Reply & Quote

Posted at: 10/8/08 02:23 AM

korded EVIL LEVEL 06

Sign-Up: 02/06/00

Posts: 1,094

Try swapping the "i" variables out with your "misslecount" variables in the duplicate function. Also, in case you haven't already caught it, those last lines of code are setting your new "missle" movieclips X positions to both the X and Y position of the ship.

Also also, for future reference, it's spelled missile.


None

RyanPridgeon

Reply To Post Reply & Quote

Posted at: 10/8/08 02:27 AM

RyanPridgeon LIGHT LEVEL 11

Sign-Up: 12/07/05

Posts: 1,982

onClipEvent(load) {
this.xv = 10;
missleCount = 0;
}
onClipEvent(enterFrame) {
this._x += this.xv;
if (Key.isDown(Key.CONTROL)) {
missleCount++;
_root..duplicateMovieClip("missle", "missle"+i, i);
_root["missle"+misslecount]._x =_root.playership._x;
_root["missle"+misslecount]._y =_root.playership._y;
}
}

then on the missile movie clip put
onClipEvent(enterFrame){
_x+=15;
}

I make flashes because I can.
PM me for anything flash or web related or visit my blog here on NG!
Also, here's my DICK

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 05:54 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!