View Full Version : problem with excessively complex AS
daperson
01-22-2006, 02:05 PM
hi, im having a little trouble, im trying to make a spark appear to fly between 2 points in my flash creation, thats fine apart frfom the fact that both of these points will be moving in an unpredictable manner, one of themwil be rotating, the other moved by the user.
how do i make a spark fly between them when triggered by another event?
goliatone
01-22-2006, 02:35 PM
hey, could you give us a hint on how you have set up everything so far? code or fla?
daperson
01-22-2006, 03:02 PM
lol sorry, im a bit of an idiot really arent i?
what ive done is i have the enemy as a movieclip, when it gets hit by a bullet movieclip it plays and therefore, explodes, on the enemy i have this basic script
this._rotation = this._rotation-5;
this._y += 1;
so its moving down the screen spinning, inside it, on the frame i want the movieclip to be at when the spark fires i have an explosion MC, on that i have....
onClipEvent(enterFrame) {this._rotation = this._rotation+5}
to cancel out the rotation when it gets fired, this is the important bit, what i wanna do is have a spark origionate from a random point on the explosion movieclip, and fly across to a random point on the ship movieclip.
the ship movieclip is configured as follows....
i have the movieclip of the ship, configured similartly to the other one with the second frame containing an explosion effect, on the movieclip is the following script...
onClipEvent (load) {
speed = 5;
leftgo = Key.LEFT;
rightgo = Key.RIGHT;
upgo = Key.UP;
downgo = Key.DOWN;
}
onClipEvent (enterFrame) {
if (Key.isDown(leftgo)) {
_x -= speed;
}
if (Key.isDown(rightgo)) {
_x += speed;
}
if (Key.isDown(upgo)) {
_y -= speed;
}
if (Key.isDown(downgo)) {
_y += speed;
}
if (_x<=0) {
_x = 0;
}
if (_y<=0) {
_y = 0;
}
if (_x>=Stage.width) {
_x = Stage.width;
}
if (_y>=Stage.height) {
_y = Stage.height;
}
}
onClipEvent (enterFrame) {
if (_root.health<=0) {
this.play();
}
}
which defines the movement of the ship, so how do i get a spark origionate from a random position on the explosion MC on the enemy, and zap a random point on the ship MC then make the variable names health increase by 1?
that any more help?
daperson
01-22-2006, 04:37 PM
please help me! :D
daperson
01-23-2006, 11:53 AM
please?
goliatone
01-23-2006, 12:00 PM
its a bit complicated, plus the code is long...why dont you wrap it with the ... tags? it will be much reader-friendly. plus...i dont know, im just confused by it! sorry :(
majicassassin
01-23-2006, 02:42 PM
I'm not actually reading the code, but I've done this before. I'll pseudocode it for you:
1) Have the program take down the location information of the two points (start and end) for the spark.
2) Create the spark movie (i usually duplicate it, tha way it can have code on it)
3) When creating, assign a start and end location to the spark movie.
4) Have the spark movie have an onClipEvent(enterFrame) handler that will move teh spark. It looks like:
//startlocX = X component of starting point, and rest are similarly named
this._x += (startlocX - endlocX)/number moves wanted
this._y += (startlocY - endlocY)/number moves wanted
5) after the spark has moved the number of moves you want (add a variable that increments every time teh spark moves to keep track of this), have it unload it self.
If you want the spark to follow the second point, pass it a link to the second point so that it can re-find the endlocX and endlocY again.
You can also do other different alterations to this, like constant speed (pass speed to determine dist moved every increment), increasing/decrasing speed (sin/cos determination), but that's really up to what you prefer.
Hope this helps,
-Maji
daperson
01-24-2006, 11:21 AM
right, il have a bash, ive mad emy post more user friendly, i dont really understand the psuedocode, can u try and make it mroe specific?
cos i dunno how i wouldmake the program take down the 2 points where it needs to go, or basicvially any of the rest of it :'(
Billy T
01-24-2006, 11:40 AM
I havent read the whole thread but see if the attached file helps
daperson
01-25-2006, 11:45 AM
the shooter thing is useful, did u make it? can i use the graphics from it :D?
problem is it doesnt help with the spark :D
Billy T
01-25-2006, 11:59 AM
no I didn't and no you can't ;)
daperson
01-25-2006, 08:15 PM
oh nuts, ill have tio take the turret graphic out now :'(did u make it then?
cant i us it even if i giv u credit :(
Billy T
01-25-2006, 10:08 PM
did you read my post? I didn't make it mate...it came with a book...so don't use it for anything other than educational purposes...
daperson
01-26-2006, 08:41 AM
ahh nuts, that sucks :P
Billy T
01-26-2006, 12:01 PM
welcome to buy the book then ask permission from the author
jobe makar I think
flash mx games demystified
daperson
01-26-2006, 05:36 PM
bah, i have the actionscript bible, any ideas how i can contact the author?
Billy T
01-26-2006, 11:16 PM
let me check....ah no sorry I dont have his home phone number in my mobile anymore
better try google
daperson
01-27-2006, 09:37 AM
do i detect sarcasm?
bah, illt try google
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.