A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [n00b][Question] About this engine I found...

  1. #1
    Member
    Join Date
    Dec 2003
    Location
    Here.
    Posts
    48

    [n00b][Question] About this engine I found...

    onClipEvent(load) {
    speed = 5;
    }
    onClipEvent(enterFrame) {
    if (key.isDown(key.RIGHT)) {
    _x += speed;
    } else if (key.isDown(key.LEFT)){
    _x -= speed;
    } else if (key.isDown(key.UP)){
    _y -= speed;
    } else if (key.isDown(key.DOWN)){
    _y += speed;
    }
    }


    This is what I am using to make the character move, I am just testing this thing. I don't get one thing, what if I wanted to make the right arrow key make it go up? I do not see any reference to the direction except for the key and the negative and positive.

    I know how to change left into right, and vice versa, and the same with up and down. Just wondering what makes it change so I can make the right key move the Symbol upwards.

    Thanks.
    Ding.

  2. #2
    Member
    Join Date
    Dec 2003
    Location
    Here.
    Posts
    48

    Re: [n00b][Question] About this engine I found...

    Originally posted by mrwackoisme
    onClipEvent(load) {
    speed = 5;
    }
    onClipEvent(enterFrame) {
    if (key.isDown(key.RIGHT)) {
    _x += speed;
    } else if (key.isDown(key.LEFT)){
    _x -= speed;
    } else if (key.isDown(key.UP)){
    _y -= speed;
    } else if (key.isDown(key.DOWN)){
    _y += speed;
    }
    }


    This is what I am using to make the character move, I am just testing this thing. I don't get one thing, what if I wanted to make the right arrow key make it go up? I do not see any reference to the direction except for the key and the negative and positive.

    I know how to change left into right, and vice versa, and the same with up and down. Just wondering what makes it change so I can make the right key move the Symbol upwards.

    Thanks.
    P.S. Those are called engines... right?
    Ding.

  3. #3
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    nope,the code you posted wouldn´t be called an engine.
    the code to build the game world (maps for example),scroll the map,character control,enemy control,collision detection,sound control etc are just the parts,the sum of it all is the engine.(pretty much the whole codeside of the game).
    _x is the _x property of a symbol,_y is the _y property.
    in flash the coordinate system is left to right= x axis (the more right,the more positive the value)
    top to bottom= y axis,the more to the bottom,the more positive the value (unlike the math coordinate system).
    so if you want to move a movieclipsymbol to the right,you increase its _x propertie´s value,if you want to move it to the bottom,you increase the value of its _y property.

  4. #4
    Member
    Join Date
    Dec 2003
    Location
    Here.
    Posts
    48
    Oh, ok. Thanks very, very much!

    Now I understand it, like a coordinate plane almost. Thanks again!
    Ding.

  5. #5
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    no probs

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