A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: moving with the animations...again

  1. #1
    I'm dope. Psytrix's Avatar
    Join Date
    Aug 2002
    Location
    Slidell, LA
    Posts
    309

    moving with the animations...again

    ok im trying to make this link guy move w/ the animations i have when u press the right arrow key.let me show you how im trying to go about this:

    (on an MC called "link")
    on frame1 link is facing down(image)
    on frame2 link is facing right(image)
    on frame3 link is facing left(image)
    on frame4 link is facing up(image)
    on frame5 link is running down(an MC)
    on frame6 link is running right(an MC)
    on frame7 link is running left(an MC)
    on frame8 link is running up(an MC)

    all of the frame have "stop();" on them

    i tried to do the keypress for going left like this:
    Code:
    onClipEvent(keyDown) {
    	if (Key.getCode() == 37) {
    		gotoAndStop(7);
    		_x=_x-3;
    	}
    }
    but that is obviously the wrong way to do it, how do you suggest i do it with the MC "link" set up like that?

    i dont think i need to attach the .fla bc ive explained everything there. thank you in advance.

    btw ive already checked out marmotte's rockypack .fla and ive decided its too difficult for me.


  2. #2
    Senior Member
    Join Date
    Sep 2000
    Location
    San Diego, CA
    Posts
    669
    try this:
    Attached Files Attached Files

  3. #3
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,987

    [ Hello ] | [ gerbick ] | [ Ω ]

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    http://www.flashkit.com/board/showth...29#post1901849

    it explains how you can set up your frames to get your directions going. The obstacles part you can pretty much ignore (unless you need it) and you can re-use your up or down clips in the angle directions if you dont have animations for them (or left and right for that matter).

  5. #5
    I'm dope. Psytrix's Avatar
    Join Date
    Aug 2002
    Location
    Slidell, LA
    Posts
    309
    that .fla is using the exact same animations as i am...and it used the exact same method i am...thanks a lot, perfect.

  6. #6
    I'm dope. Psytrix's Avatar
    Join Date
    Aug 2002
    Location
    Slidell, LA
    Posts
    309
    i used the code from the .fla i got from GameDev and i made it match mine...here is the code im using:

    Code:
    onClipEvent (load) {
    	gotoAndStop(1);
    	var inc = 9;
    	var dir = "Right";
    	KeyListener = new Object();
    	KeyListener.onKeyUp = function() {
    		if (dir == "Down") {
    			gotoAndStop(1);
    		} else if (dir == "Right") {
    			gotoAndStop(2);
    		} else if (dir == "Up") {
    			gotoAndStop(4);
    		} else if (dir == "Left") {
    			gotoAndStop(3);
    		}
    	};
    }
    onClipEvent (enterFrame) {
    	Key.addListener(KeyListener);
    	if (Key.isDown(Key.LEFT)) {
    		dir = "Left";
    		this._x -= inc;
    		gotoAndStop(7);
    	} else if (Key.isDown(Key.RIGHT)) {
    		dir = "Right";
    		this._x += inc;
    		gotoAndStop(6);
    	} else if (Key.isDown(Key.UP)) {
    		dir = "Up";
    		this._y -= inc;
    		gotoAndStop(8);
    	} else if (Key.isDown(Key.DOWN)) {
    		dir = "Down";
    		this._y += inc;
    		gotoAndStop(5);
    	}
    }
    could someone explain some of it to me?
    these in particular:

    KeyListener(never seen anything like this before)
    var dir(this either, how does it work?)
    the use of "down", "up", "left", and "right".(are these constant?)

  7. #7
    Senior Member
    Join Date
    Sep 2000
    Location
    San Diego, CA
    Posts
    669
    ok dude...

    KeyListener(never seen anything like this before)
    ------------------------------------------------
    this tracks your keypresses and waits to see when you release a key. So what I did was check to see when an arrow key was pressed (note its no key in specific, just any key released) then referenced the dir variable (left, right, down, up etc). So if the dir was set to "Right" for example then goto the stand right image when the walk right key is released.

    var dir(this either, how does it work?)
    ------------------------------------------------
    var just creates the dir (direction) variable so that I know what way he is walking when you release the key so that I can send you to the stop frame.


    the use of "down", "up", "left", and "right".(are these constant?)
    -------------------------------------------------------------------
    there created strings in each direction so that the dir (direction) variable can report in which direction you are/ were walking.


    Good luck,

    Tyler

    (making a zelda type game? want to look at my zelda clone?)

  8. #8
    I'm dope. Psytrix's Avatar
    Join Date
    Aug 2002
    Location
    Slidell, LA
    Posts
    309
    well i want to get around to making a zelda clone, so i would like to see yours.

    so u made the var of dir and it could equal up down left and right?

  9. #9
    Senior Member
    Join Date
    Sep 2000
    Location
    San Diego, CA
    Posts
    669
    How expirienced w/ flash are you? Yeah, basically, but I have some updated code. I replaced the text in the variable dir for numbers. Saved me a lot of code. Anyway, you can have a variable be equal to anything, including strings ("text"). I'm getting pretty far on the clone, so when I have something worth testing ill let you know. Whats your email?


    -Tyler

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