0

So basically I have two questions. I am also copying off this video from 2014: https://www.youtube.com/watch?v=w8JgpEjm8i8&t=2792s

Question 1 At the end of the video above the guys computer completely crashed and he wasnt able to show the end of how to setup a death animation for my player (link). So currently I have setup a movie clip of the death animation - just the playing spinning around - and put it in another movie clip called 'All Sprites' in which I have my other movie clips such as the different walking directions. So I have placed it in there, labelled it with "Link Death Frame". I then went back to the main script and added code so that once my player dies, the animation will play. Such as: ~

if(linkHealthBarMC.scaleX <= 0.01)
    {
        linkAlive = false;
    }
    trace(linkAlive);
if(linkAlive == false)
{
    linkMC.gotoAndStop("Link Death Frame"); 
}

~ However, the issue comes in which the animation doesnt actually play, it just goes straight to the first frame and doesnt play. I have tested it and I know for sure that it gets stuck on the first frame and that something must be wrong with the animation as I tested it with another animation and it worked fine (once I met the requirements for the animation to play). So does anyone have any idea how I can fix this issue so that my character can play a death animation?

Question 2 How do I stop time? Like just completely freeze everything after my character is dead? Because at the moment I am just going to the first frame of the death animation and can still move and attack.

  • 1. If another animation works, then investigate, what's wrong with the death one. A stray **stop();** in the first frame? A wrong type of object (not set to **MovieClip** but to **Graphics**) instance? Who knowns. 2. There's no simple way to do so. In order to have it, you need to program the whole concept of time so that every single animation and every single action performs according to how much time has passed. It is a complex thing, but you will be able not only stop time completely, but also have a slow-mo mode when you want it, and probably even reverse (one step more complicated). – Organis Aug 12 '22 at 20:23
  • @Organis just looking at your comment and I am sure where to look for the stray **stop();** in my animation. Do you mind telling me where I can find this? – DaGoldenGam3r Aug 13 '22 at 04:39
  • I'd look into the first frame of the animation in question. Then, I remember there was some Library button or whatever, that could show all the frame scripts in the project, but it was Flash 5 and like 20 years ago, so I can't be sure it actually exist now, still worth looking though. Other than that — no idea. I don't know your project structure and what kind of mistakes you might have made there. – Organis Aug 13 '22 at 08:29

1 Answers1

0

I'd assume this is on an EnterFrame loop. Then you would have two possible causes for this:

1.) You're loop is constantly checking if the 'linkAlive' if statement is false (which it is) and setting your Animation to the first frame. You can check this method by putting a Trace statement in your if statement and if the output window overflows, then that's your culprit.

2.) What you want is gotoAndPlay(-insert label here-)

Tho it is outside the scope of the question you have, I create a variable~Switch State machine to control states for me: 1.) Current State as a number (int, number, or uint) 2.) function with a switch statement (Switch is kind of a fancy if Statement) 3.) inside the cases are instructions

switch(current_state){
   case 1:
       linkMC.gotoAndPlay('death animation');
   break;
}
if (current_state != 1){
   -put movement code here-
}

This is close to what I use for my game. Just checking states or you can have a variable like the one above that explicitly checks for the death state and remove the ability to move. If you use a mouse (and I assume event listener) then you can remove the event listener for the mouse. If you use a solution like keyboard inputs then an if statement would be more what you are looking for.

Brandon Reed
  • 33
  • 1
  • 9