|
-
DOT-INVADER
don't laugh: simple gotoAndStop/Play problem...
ok, i have noticed something:
code:
gotoAndStop(5);
trace("hello");
^ it traces "hello". without using any if statment, is there a way that flash goes to frame 5 without reading all the code that is above the gotoAndPlay()? imagine that the trace here is in my game something like 300 lines of code that i don't want to be calculated anymore...
another example:
code:
function next_f(frame) {
delete next_f;
gotoAndStop(frame);
trace_f();
}
function trace_f() {
trace(_currentframe);
}
next_f(5);
here, even by deleting the function, it's still read in its intergrity before being deleted.
that one works, but that's not what i want:
code:
function next_f(frame) {
delete trace_f;
gotoAndStop(frame);
trace_f();
}
function trace_f() {
trace(_currentframe);
}
next_f(5);
ok, basically what i want: is there a way to "break" a code before it's finished, like the break; method that works with for loops? i mean, without using if statments everywhere, because i have TONS of code (it's for my fighting game)
here's a better description of the little problem i have:
that fighting game require a lot of keys interaction, and is filled with tons of function... imagine that at the same frame, the player attacks and exactely at the same time recieve a hit > so there are here 2 times a gotoAndPlay() at the same time. what's the result?
the enemy loses life, the hit effect is attached, but he doesn't play his hit animation and directly goes to his attack animation... it's probably like saying:
code:
gotoAndPlay("hit")
// lose life, etc
gotoAndPlay("attack")
ok, it's not the only example i have, but when it occurs, it's not funny :-(
oh, another question, sometimes flash seems to be confused... a gotoAndStop() becomes gotoAndPlay(), or goes to a wrong frame (never mentioned by me since it was a blank and unlabelled frame in the middle of the movie), some _x/_y values may be wrong (that's true!) etc...
i'm now in the process of cleaning the code a bit, since the engine is almost finished, but i want the game to look the best possible and get rid of all these little annoying bugs.
so my question is: using a lot of values that have almost the same may confuse flash or not? example:
var key_checker
function key_checker
var key_check_minus
var key_check_error
...etc...
^ these names are quite similar, do you think they may perturb flash?
thanks for any response
Last edited by marmotte; 09-03-2003 at 08:34 AM.
-
SaphuA
:)
hmmm..
that sure is a neat question 
How about only using 1 if?
if(dosomething == true){
if(hit){
//
dosomething = false;
} else if(attack){
//
dosomething = false;
} else if(pizza){
//
dosomething = false;
} else if(hamburger){
//
dosomething = false;
} else if(macdonalds || burgerking){
//
dosomething = false;
}
}
Now I'm not sure if you can use this... but what the heck..
-
DOT-INVADER
thanks, but naaah, it will take sooo long :-)
i cannot put only one if statment because i have tons of functions called when needed...
> ok, i can do something like if(blabla==true){call function}, but again i have different calls at each frame (approximatively 100/150 frames for each character)
> ok, i can perform an if statment at the beggining of each function, but OUARGLLALAAL there are TONS of them
>ok, i can have an additional variable, like something=false, and when a gotoAndPlay() occurs it turns true, so no more qotoAndPlay() is possible... but again, where to put that, my god... i have tons of different gotoAndPlay() everywhere...
i just want to know if a break exists... just think of it, even if i put this.onEnterFrame = null, it will be deleted after having translated ALL the code, but i want it to stop the code before...
-
ism
stick everything in functions and when you want it to cutoff just use return.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
DOT-INVADER
now that's nice... too bad it cannot cut the parent functions...
(i have functions in functions in functions sometimes...)
> even the gotoAndPlay() is a function in my game (used to update your var frame that matches the next label, plus update your shadow frame)
-
DOT-INVADER
wait, i think i can do it and cut the parent function...
although that's what my test is tracing... :-)
*** EDIT ***
mmmh, not exactely... with that previous example, how to cut the function next_f from within the function trace_f? is it even possible?
code:
function next_f(frame) {
delete next_f;
gotoAndStop(frame);
trace_f();
}
function trace_f() {
// return the function next_f???
trace(_currentframe);
}
next_f(5);
Last edited by marmotte; 09-03-2003 at 10:01 AM.
-
Senior Member
Re: don't laugh: simple gotoAndStop/Play problem...
Originally posted by marmotte
imagine that at the same frame, the player attacks and exactely at the same time recieve a hit > so there are here 2 times a gotoAndPlay() at the same time. what's the result?
the enemy loses life, the hit effect is attached, but he doesn't play his hit animation and directly goes to his attack animation.
You could make array of animations to play.
Player got hit - add hit animation to the end of play_animations_array
Player attacks - add attack animation to the end of play_animations_array
Every time animation is finished, take first element from play_animations_array and play it.
so my question is: using a lot of values that have almost the same may confuse flash or not? example:
var key_checker
function key_checker
var key_check_minus
var key_check_error
^ these names are quite similar, do you think they may perturb flash?
[/B]
I would avoid those:
var key_checker
function key_checker
Those look fine:
var key_check_minus
var key_check_error
-
DOT-INVADER
Re: Re: don't laugh: simple gotoAndStop/Play problem...
Originally posted by tonypa
I would avoid those:
var key_checker
function key_checker
sorry, i misstyped it...
the var is called
> k_rec_checker
and the function
> k_rec_check()
don't you think flash can mix them accidentally during all these simultaneous codes?
about your frame array suggestion, that is interesting. i'll try do to something with it.
your idea: avoid gotoAndStop("hit") BUT use frame.unshift("stand_hit_medium"). i understand the concept, and i'll try it, thanks... (hop, a new array again :-) i have tons of them too)
-
Senior Member
Re: Re: Re: don't laugh: simple gotoAndStop/Play problem...
Originally posted by marmotte
the var is called
> k_rec_checker
and the function
> k_rec_check()
don't you think flash can mix them accidentally during all these simultaneous codes?
No, I dont think they can be mixed up.
If Flash would mix something like this, what about all the stuff in tbw:
t_0_1
t_0_2
...
t_0_235
It would be complete mess
-
ism
mmmh, not exactely... with that previous example, how to cut the function next_f from within the function trace_f? is it even possible?
you can use the calling function to delete the reference.
Code:
delete eval(next_F(frame));
function next_f(frame) {
gotoAndStop(frame);
return("next_f");
trace_f();
}
function trace_f() {
// return the function next_f???
trace(_currentframe);
}
next_f(5);
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
ʞ33ƃ
Could do something like this:
code:
//Declaring the functions
function callF(functionToCall){
if(!broken){
functionToCall()
}
}
function a(){
trace("a")
}
function b(){
trace("b")
}
function c(){
trace("c")
broken=true
}
function d(){
trace("d")
}
function e(){
trace("e")
}
//Code to show its "broken" at function c
broken=false
callF(a)
callF(b)
callF(c)
callF(d)
callF(e)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|