A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: walls

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    49

    walls

    Okay, I can move a 2-d character left and right, make it look like its heading towards the back, by simply using _xscale and _yscale to make it seem 3d, except for the character. But this is my actual question. How do I get the characters stop at the edge of the screen? left-right-back-foward.

    Thank you in advance.

  2. #2
    Senior Member Speed85's Avatar
    Join Date
    Apr 2007
    Posts
    291
    You just want to make it so that the character cant leave the stage? As long as you're not hittesting anything thats not too hard.

    Here is a code I have from a game I made, the movie clip's name is sam.

    code:

    sam.onEnterFrame = function() {
    if (Key.isDown(Key.LEFT)) {
    this._x -= your_speed;
    if (this._x<=0) {
    this._x = 0;
    }
    }
    if (Key.isDown(Key.RIGHT)) {
    this._x += your_speed;
    if (this._x>=Stage.width) {
    this._x = Stage.width;
    }
    }
    };




    Just need to make a similar if statement for the UP and DOWN keys with 0 and Stage.height and comparing them to the _y.

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