A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: MC Freezes On First Frame?

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    9

    MC Freezes On First Frame?

    Hello, I'm starting to learn to use AS2 to program a beat-em up game, but I have a few problems.
    • A few different MCs on my main character freeze on the first frame even though the code is the exact same as the other frames
    • _root.health variable doesn't go down when touching an enemy
    • The player can slide left and right while ducking
    • If the character is running and they attack, the player should do a sort of roll, but it just acts as if the roll doesn't exist and executes it's normal attack

    Stick Fighter.fla
    Controls:
    Arrow Keys: Move/Duck
    A: Punch
    S: Kick
    D: Super (still working on the explosion graphics :P)

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi,

    if you're new to programming, then this might not be the best for you to deal with right now, because it may be a bit complicated for you, but I'll try to help anyways

    A few different MCs on my main character freeze on the first frame even though the code is the exact same as the other frames
    Could you perhaps elaborate on that, 'cause I can't seem to understand what you mean :S

    _root.health variable doesn't go down when touching an enemy
    It's because in your enemy, you are referring to the main character as man, but you haven't defined it - you haven't given your character movieclip an instance name of, man, which is what you need to do in order for this to work. Simply select your character, open Properties Panel [CTRL+F3], and type man in the Instance Name textfield

    The player can slide left and right while ducking
    Because you haven't defined in the code that the character shouldn't be able to move while he's ducking. Now, this may be really complicated for you (I'm assuming you're new to AS2, because there are lots of comments in the FLA file, which I'm presuming are written by someone else for a tutorial), but if you really do want it, then first of all, find this line in your character's coding:

    Code:
    if (Key.isDown(Key.DOWN)) {
    	this.gotoAndStop(6);
    }
    and change it to this:

    Code:
    if (Key.isDown(Key.DOWN)) {
        down = true;
        this.gotoAndStop(6);
    } else {
        down = false;
    }
    then, find this line:

    Code:
    if (Key.isDown(Key.LEFT) && fight != true) {
    and change it to this:

    Code:
    if (Key.isDown(Key.LEFT) && fight != true && !down) {
    finally, find this line:

    Code:
    } else if (Key.isDown(Key.RIGHT) && fight != true) {
    to this:

    Code:
    } else if (Key.isDown(Key.RIGHT) && fight != true && !down) {
    If the character is running and they attack, the player should do a sort of roll, but it just acts as if the roll doesn't exist and executes it's normal attack
    It's all due to bad structure in the character's code which doesn't work well together. Find these lines in your character's code:

    Code:
    if (Key.isDown(65) && fight != true) {
    	if (running=true) {
    	}
    	this.gotoAndStop(5);
    }
    if (Key.isDown(65) && fight != true) {
    	if (running=false) {
    	}
    	this.gotoAndStop(4);
    	fight = true;
    }
    and change it to this:

    Code:
    if (Key.isDown(65) && fight != true) {
        if (running==true) {
            this.gotoAndStop(5);
        } else {
            this.gotoAndStop(4);
            fight = true;
        }
    }
    and find this line:

    Code:
    this.gotoAndStop(2);
    both, inside if (Key.isDown(Key.LEFT) && fight != true && !down) { AND inside } else if (Key.isDown(Key.RIGHT) && fight != true && !down) {, and change them both to this:

    Code:
    if(_currentframe != 5){
        this.gotoAndStop(2);
    }
    however, this will still not work perfectly, as the structure of the code is very poorly coded. This is as far as I can help you, but I do hope you continue learning Flash, and one day return to this problem and finally program it in a better and more stable way
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center