Function in While starten!

Posted By: Moerk

Function in While starten! - 12/25/07 03:45

Tach erstmal,

entweder stehe ich auf dem Schlauch oder ich muss das anderst angehen.

Erstmal die Function:

Ich animiere die "Laufanimation". Beim Klick auf die Linke Maustaste wird eine Function aufgerufen die eine "Angriffsanimation" addet (anm_add). Also ich arbeite mit Bones. Das ganz funktioniert auch soweit. Allerdings befindet sich das ganze in einer While Schleife somit wird die Function rasend schnell hintereinander aufgerufen.

Ich habe probiert die Function per proc_kill nur einmal in der Animationszeit ablaufen zu lassen, allerdings glaube ich war das der komplett falsche Weg. Hier erstmal der Code

Code:

action Player_Function
...

while(1)
{

//Animation
if(abs(Tastatur.x) == 1)
{
ani_walk = (ani_walk + Tastatur.x*time_step*6)%100;
ent_animate(my,"walk",ani_walk,anm_cycle);
}
if(mouse_left == 1)
{
attackit();
}

...



So... nun die attackit() Function

Code:

function attackit
{
while (ani_attack1 <= 100) // death_percentage geht hier von 0 bis 100
{
ent_animate(my, "attack", ani_attack1, anm_add); // animation adden
ani_attack1 += 8 * time_step; // 2 = animation geschwindigkeit
wait (1);
}
ani_attack1 = 0;
}



Was kann ich tun?
Posted By: TripleX

Re: Function in While starten! - 12/26/07 11:41

Eine mögliche, wenn auch nicht sehr schöne, Methode:

Code:

if(mouse_left)
{
if(proc_status(attackit)==0)
{
attackit();
}
}



Wenn deine Version proc_status ( http://www.conitec.net/beta/proc_status.htm ) nicht unterstüzt, dann wäre es auch folgende noch häßlichere methode möglich:

Code:

bool attackit_var=false; //falls wdl: var attackit_var=0;
function attackit()
{
if(attackit_var==true) { return 0; } //==1
attackit_var=true; //=1;
//....
attackit_var=false; //=0;
return 1;
}


Posted By: Moerk

Re: Function in While starten! - 12/26/07 14:34

Alles klar ich probier das ganze mal.

Und soweit ich es sehe funktioniert es auch... danke sehr
© 2024 lite-C Forums