Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Animation in While! #174843
12/26/07 19:11
12/26/07 19:11
Joined: Apr 2006
Posts: 58
Moerk Offline OP
Junior Member
Moerk  Offline OP
Junior Member

Joined: Apr 2006
Posts: 58
Ich habe ein kleines Random System gebaut, indem eine Zufallszahl zwischen 0 und 1 gewählt. Je nachdem welche Zahl kommt wird eine der beiden Angriffsanimationen abgespielt. Allerdings passiert bei mir da gar nichts bzw. ich sehe meine Charakter kurz "zucken" und mehr kommt nicht.

Dazu muss ich sagen, ich möchte das die Animation mit nur einem Mausklick komplett einmal durchgespielt wird, ohne dass man auf der Maustaste bleiben muss. Deshalb habe ich eine While Schleife genommen.

Hier der Code:

Code:

function attackit
{
randomize();
my.attack_choose = int(random(2));
if(my.attack_choose == 0)
{
while (ani_attack1 <= 100) // Solange ani....
{
ani_attack1 = 8 * time_step; // Ani Speed
ent_animate(my, "attack", ani_attack1, anm_cycle); // Ani Bfehl
wait(1);
}
}
ani_attack1 = 0;
if(my.attack_choose == 1)
{
while (ani_attack2 <= 100) // Solange ani....
{
ani_attack2 = 8 * time_step; // Ani Speed
ent_animate(my, "attack2", ani_attack2, anm_cycle); // Ani Bfehl
wait(1);
}
ani_attack2 = 0;
}
}



Kennt jemand des Lösungsproblem oder gibt es da ne elegantere Methode?


"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: Animation in While! [Re: Moerk] #174844
12/26/07 19:16
12/26/07 19:16

A
Anonymous
Unregistered
Anonymous
Unregistered
A



versuch mal das:

Code:
 

function attackit
{
randomize();
my.attack_choose = int(random(2));
if(my.attack_choose == 0)
{
while (ani_attack1 <= 100) // Solange ani....
{
ani_attack1 = 8 * time_step; // Ani Speed
ent_animate(my, "attack", ani_attack1, anm_cycle); // Ani Bfehl
ani_attack1 += 3*time;//animation speed
if(ani_attack1 > 100){ani_attack1 = 0;}
wait(1);
}
}
ani_attack1 = 0;
if(my.attack_choose == 1)
{
while (ani_attack2 <= 100) // Solange ani....
{
ani_attack2 = 8 * time_step; // Ani Speed
ent_animate(my, "attack2", ani_attack2, anm_cycle); // Ani Bfehl
ani_attack2 += 3*time;//animation speed
if(ani_attack2 > 100){ani_attack2 = 0;}
wait(1);
}
ani_attack2 = 0;
}
}




Re: Animation in While! [Re: ] #174845
12/26/07 19:22
12/26/07 19:22
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Du vergisst einfach nur das addieren:
ani_attack1 = 8 * time_step; // Ani Speed
->
ani_attack1 += 8 * time_step; // Ani Speed

beim anderen natürlich auch.

@Fear411: gewöhne dir mal saubereren code an, zumal deiner auch nicht funktionieren sollte, da ani_attack jedes mal zurückgesetzt wird.

Re: Animation in While! [Re: Slin] #174846
12/26/07 19:24
12/26/07 19:24

A
Anonymous
Unregistered
Anonymous
Unregistered
A



sry hab mir den code nicht genau angeschaut

Re: Animation in While! [Re: ] #174847
12/26/07 19:29
12/26/07 19:29
Joined: Apr 2006
Posts: 58
Moerk Offline OP
Junior Member
Moerk  Offline OP
Junior Member

Joined: Apr 2006
Posts: 58
Funktioniert nicht... ich schätze es liegt an der While Schleife...


"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: Animation in While! [Re: Moerk] #174848
12/26/07 20:52
12/26/07 20:52
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
Code:

function attackit
{
var doit;
while(1)
{
if(doit == 0)
{
randomize();
my.attack_choose = int(random(2));
}
if(my.attack_choose == 0)
{
doit = 1;
if(ani_attack1 <= 100) // Solange ani....
{
ani_attack1 = 8 * time_step; // Ani Speed
ent_animate(my, "attack", ani_attack1, anm_cycle); // Ani Bfehl
wait(1);
}
else{doit =0;}
}
ani_attack1 = 0;
if(my.attack_choose == 1)
{
doit = 1;
if(ani_attack2 <= 100) // Solange ani....
{
ani_attack2 = 8 * time_step; // Ani Speed
ent_animate(my, "attack2", ani_attack2, anm_cycle); // Ani Bfehl
wait(1);
}
else{doit =0;}
ani_attack2 = 0;
}
wait(1);
}
}




"empty"
Re: Animation in While! [Re: flits] #174849
12/26/07 21:25
12/26/07 21:25
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Try this :

Code:

function attackit
{
while(player != null)
{
ani_attack1_speed = 8;
ani_attack2_speed = 8;
randomize();
my.attack_choose = int(random(2));
if(my.attack_choose == 0)
{
while (ani_attack1 < 100) // Solange ani....
{
ani_attack1 += (ani_attack_speed * time_step)%100; // Ani Speed
ent_animate(my, "attack", ani_attack1, 0); // Ani Bfehl
wait(1);
}
ani_attack1 = 0;
}
if(my.attack_choose == 1)
{
while (ani_attack2 < 100) // Solange ani....
{
ani_attack2 += (ani_attack2_speed * time_step)%100; // Ani Speed
ent_animate(my, "attack2", ani_attack2, 0); // Ani Bfehl
wait(1);
}
ani_attack2 = 0;
}
wait(1);
}
}



If this doesn't work, try changing the 100 value into 99.

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Animation in While! [Re: frazzle] #174850
12/26/07 21:41
12/26/07 21:41
Joined: Apr 2006
Posts: 58
Moerk Offline OP
Junior Member
Moerk  Offline OP
Junior Member

Joined: Apr 2006
Posts: 58
Well ok but i start that script in another while loop

Code:
if(mouse_left && proc_status(attackit) == 0)
{
attackit();
}



the while loop isnt a good solution in this way!


"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: Animation in While! [Re: Moerk] #174851
12/27/07 02:29
12/27/07 02:29
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Schau mal auf meinem Blog unter Tutorials "player with Animation Tutorial" dort wirst du sehen wie es geht

cYa Sebastian

P.S. Blog siehe Signatur


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: Animation in While! [Re: rvL_eXile] #174852
12/27/07 13:00
12/27/07 13:00
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Quote:

Schau mal auf meinem Blog unter Tutorials "player with Animation Tutorial" dort wirst du sehen wie es geht

cYa Sebastian

P.S. Blog siehe Signatur



Sorry, aber den code kann man vergessen... Gerade wenn es darum geht etwas abzugucken.

Mir ist noch die Idee gekommen, dass es sein könnte, dass die Funktion für diese Animation zu häufig aufgerufen wird und die Animation also in kürzester Zeit abläuft.
Dies passiert nähmlich durch
if(key_kp)
{
funktion();
}
in einer Schleife.
Um das zu verhindern könntest du z.B. eine Variable setzen solange die Funktion ausgeführt wird und erst, wenn diese wieder 0 ist die Funktion erneut aufrufen lassen.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1