A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AS2: Move Object Codes to a layer

  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    4

    AS2: Move Object Codes to a layer

    Hi, im a newbie when it comes to Flash, I just recently started learning it, I found This Tutorial on youtube About how to make a platform game its here : https://www.youtube.com/watch?v=NTuh...NVFcoPT3UYHqmA . The Tutorial is good, but i was wondering how do i move the codes from the object character "char" to a New seperate Layer?... Ive been fiddling around the codes but i cant seem to get it to work, my goal is to put all the codes in a Separate Layer, can you help me how to do that?..Any help will be much appreciated


    Code for the character:

    onClipEvent (load) {
    var ground:MovieClip = _root.ground;
    var grav:Number = 0;
    var gravity:Number = 2;
    var speed:Number = 7;
    var maxJump:Number = -12;
    var touchingGround:Boolean = false;
    }
    onClipEvent (enterFrame) {
    _y += grav;
    grav += gravity;
    while (ground.hitTest(_x, _y, true)) {
    _y -= gravity;
    grav = 0;
    }
    if (ground.hitTest(_x, _y+5, true)) {
    touchingGround = true;
    } else {
    touchingGround = false;
    }
    if (Key.isDown(Key.RIGHT)) {
    _x += speed;
    }
    if (Key.isDown(Key.LEFT)) {
    _x -= speed;
    }
    if (Key.isDown(Key.UP) && touchingGround) {
    grav = maxJump;
    }
    if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
    _x -= speed;
    }
    if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
    _x += speed;
    }
    if (ground.hitTest(_x, _y-(height), true)) {
    grav = 3;
    }
    }

  2. #2
    Registered User
    Join Date
    Sep 2014
    Posts
    4
    Anyone?

Tags for this Thread

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