To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Games

Reply
 
Thread Tools Search this Thread Display Modes
Old 02-22-2005, 11:18 PM   #1
TheLostGuru
Senior Member
 
TheLostGuru's Avatar
 
Join Date: Aug 2004
Location: I live on this webpage...
Posts: 772
Random Shots

I have these airplanes that are attached to the screen on using attachMovie("aircraft", "aircraft" + p, p);
you get the picture. They fly across the screen from right to left with a random speed and y position. What I am trying to randomly get bombs to drop from the planes. Right now all I have been able to do is randomly drop bombs from the corner of the screen. Does anyone know of a good way to do this? I'm open to any suggestion.
__________________
"If I have seen further it is by standing on the shoulders of giants." Isaac Newton
------------------------------------------------------------------------------
OneDayGamer-Looking to sponsor games?
TheLostGuru is offline   Reply With Quote
Old 02-22-2005, 11:32 PM   #2
swcAndrew
Impressive Click
 
swcAndrew's Avatar
 
Join Date: Oct 2004
Location: USA
Posts: 468
why don't you attach the random code to the airplane. Then set the x and y position to that of the plane at the time.
__________________
Andrew Webster
Impressive Click
swcAndrew is offline   Reply With Quote
Old 02-22-2005, 11:56 PM   #3
DayDream
Senior Member
 
DayDream's Avatar
 
Join Date: Aug 2000
Location: Cairns / Australia
Posts: 366
or simply get the _x of the plane dropping the bomb and use it as the starting point for the bomb when you attach it...
__________________
DayDream is offline   Reply With Quote
Old 02-23-2005, 12:04 AM   #4
UnknownGuy
Senior Member
 
UnknownGuy's Avatar
 
Join Date: Jul 2003
Location: Canada
Posts: 1,366
This might help, if its what you want...
code:

//Do this when the game loads
createEmptyMovieClip("airplanes");
createEmptyMovieClip("bombs");
maxtime=30

//Do this when your creating the movies
airplanes.attachMovie("aircraft", "aircraft" + p, p);
airplanes["aircraft" + p].current=0
airplanes["aircraft" + p].interval=random(maxtime)
p++
//Do this everyframe

for(plane in airplanes){
airplanes[plane]._x+=xspeed
airplanes[plane].current++
if(airplanes[plane].current==airplanes[plane].interval){
bombs.attachMovie("bomb", "bomb" + p, p);
bombs["bomb"+p]._x=airplanes[plane]._x
bombs["bomb"+p]._y=airplanes[plane]._y
airplanes[plane].interval=random(maxtime) }
}

for(bomb in bombs){
bombs[bomb]._y+=bombyspeed
//Do whatever actions bombs do
}



I think that should all work, if you need any clarfication just ask!

Hope that Helps!

Edit:Code Change

Last edited by UnknownGuy; 02-23-2005 at 08:43 AM.
UnknownGuy is offline   Reply With Quote
Old 02-23-2005, 12:26 AM   #5
TheLostGuru
Senior Member
 
TheLostGuru's Avatar
 
Join Date: Aug 2004
Location: I live on this webpage...
Posts: 772
I think I might work with the code you gave me unknownguy. Where you say use this when you movie loads and stuff, does this code all go on the same frame? Does it go on a frame or a movieclip? Also in your code you switched from aircraft to plane. Did you mean to? Also where does P get increased? Should I put these things in functions?
__________________
"If I have seen further it is by standing on the shoulders of giants." Isaac Newton
------------------------------------------------------------------------------
OneDayGamer-Looking to sponsor games?

Last edited by TheLostGuru; 02-23-2005 at 12:32 AM.
TheLostGuru is offline   Reply With Quote
Old 02-23-2005, 12:43 AM   #6
TheLostGuru
Senior Member
 
TheLostGuru's Avatar
 
Join Date: Aug 2004
Location: I live on this webpage...
Posts: 772
Alright, I give in... I really didn't want to end up posting my fla, but I'm sick of this bomb not dropping. My bomb dropping code is in my aircraft mc. Any help would be appreciated.
__________________
"If I have seen further it is by standing on the shoulders of giants." Isaac Newton
------------------------------------------------------------------------------
OneDayGamer-Looking to sponsor games?
TheLostGuru is offline   Reply With Quote
Old 02-23-2005, 12:44 AM   #7
TheLostGuru
Senior Member
 
TheLostGuru's Avatar
 
Join Date: Aug 2004
Location: I live on this webpage...
Posts: 772
fla
__________________
"If I have seen further it is by standing on the shoulders of giants." Isaac Newton
------------------------------------------------------------------------------
OneDayGamer-Looking to sponsor games?
TheLostGuru is offline   Reply With Quote
Old 02-23-2005, 08:42 AM   #8
UnknownGuy
Senior Member
 
UnknownGuy's Avatar
 
Join Date: Jul 2003
Location: Canada
Posts: 1,366
When I say when the movie loads I mean, it should just be executed once, while the next piece of code should be done when you create the fighter, and the last everyframe. It dooesn't matter if its in a frame or a movieclip(you might have to use root to get out of the movie).
And no, its doesn't matter I switched from aircraft to plane, plane is a variable and holds data like aircraft1, aircraft2 etc...
I forgot to increase p, so I've edited the code so it does.

I don't have time to look at the .fla, but hopefully I will tonight.

Hopefully that clarifies a few things...
UnknownGuy is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:45 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.