Page 1 of 1

create actor events for fighting

PostPosted: Fri Feb 16, 2007 2:07 pm
by Bat Man
how can i use a create actor event for fighting. 4 example, when i press a button, it destroys an actor and another sprite/actor appears in the same place, because the collision event doesn't really work that well.

i m so confused :cry:

PostPosted: Fri Feb 16, 2007 3:06 pm
by Sgt. Sparky
collision works perfectly.
Example: make a var (GlobalVar) called Punch,
when the hitting key is pressed Punch = 1;
when the punch animation is finished Punch = 0;
also, make a var Called Animfinish, when any animation is finish AnimFinish = 1;
or when moving keys that have to do with animations are released.
here is code for the right moving key pressed:
Code: Select all
char *key=GetKeyState();
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0 && Punch == 0)
{
    x += 5;
    if(AnimFinish == 0)
    {
       ChangeAnimation("Event Actor", "Right", FORWARD);
    }
}
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 1)
{
    ChangeAnimationDirection("Event Actor", STOPPED);
}

and for the left moving key:
Code: Select all
char *key=GetKeyState();
if (key[KEY_RIGHT] == 0 && key[KEY_LEFT] == 1 && Punch == 0)
{
    x -= 5;
    if(AnimFinish == 0)
    {
       ChangeAnimation("Event Actor", "Left", FORWARD);
    }
}
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 1)
{
    ChangeAnimationDirection("Event Actor", STOPPED);
}

this event needs to be repeated, that way he will not move hile punching, Exept for his punching. :D
when the player collides with the badguys,
have this:
Code: Select all
if(Punch == 1)
{
     DestroyActor("Collide Actor");
}

I hope that helps, if you want any help with health bars ect. just let me know :D
this is part of a code I made for Anti-Moonwalking :D
http://game-editor.com/forum/tp-3039-Pe ... nwalk.html
for some Ai for a shooting game:
http://game-editor.com/forum/tp-3049-AI ... game-.html