The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 7 of 7

Thread: help with 2d platform game actionscripting

  1. #1
    7
    posts
    Registered User

    help with 2d platform game actionscripting

    Hey there! ^_^ I have just started using flash MX quite a lot and Iam working on a 2d
    platform game. I have been using a tutorial on this website so far, however I have also added my own things here and there to the scripting to help my game function the way I want.. by doing this I my game's scripting is all over the place and Iam finding it difficult make certain things work.. :S I was just wondering if somebody who is farmiliar with actionscripting in flash MX could possibly take the time to help me with my game, so I can make it functional this would be greatly appreciated thankyou

    regards cadz xD

    can be contacted via blam_020@hotmail.com

  2. #2
    Hello Friend,

    I'm ready to help you.... Can you please tell me your concept and over all requirements and where you are getting problem... etc etc....

    Thanks,
    vamsi.g

  3. #3
    7
    posts
    Registered User
    Hey thanks a lot Iam very greatful. Basicaly my game is a 2d platform ( megaman style ) I have at the moment my character which can move around ( not completely ) and a score system ( basic ) and an enemy ( dies if you go near it haha ). The protaganist is a character called lex who is sent from the heavens to eliminate all the demonic powers that threatend earth. At the moment I have a very small level, that contains quite a few bugs.. I will list my issues and maybe you can help me resolve them?

    1) I want my backround to scroll, atm its just a stretched symbol

    2) my enemy is un animated, and dies when you go near it instead of when I attack it
    with my control attack.

    3) I need a health system so when my enemy attacks me, my character dies (atm he is invincible )

    4) my character movement is nearly good, except I can't get him to attack to the left.. everything is configured so all of his actions are right.

    haha Iam sorry this is quite a lot of stuff Iam asking for and I do understand that this will be taking up your time however this will help me a lot. I have gone through several tutorials and cut and pasted and edited many different scripts into my game without really knowing how they work properly and I have hit a point where I can no longer do this without something else not working haha. I have spent the past 1-2 weeks infront of my screen fustrated but still motivated to learn the program haha thanks for your help
    much appreciated

  4. #4
    7
    posts
    Registered User
    Is this asking to much Vamsig? sorry haha

  5. #5
    sounds like your having some fun problems. if you can put up a code or a fla it might help so we can get an idea pof where your bugs are. o and one more thing alot of issues can come from having the code on the object if you read up a bit you can get it all on the timeline and will be around 100 times easier to debug. believe me ive been there and learned my lesson. keep your code in one spot.

  6. #6
    7
    posts
    Registered User
    here is my characters coding

    onClipEvent (load) {
    jumping = true;
    jump = 0;
    speed = 0;
    maxmove = 15;
    }
    onClipEvent (enterFrame) {
    if (_root.dead) {
    this.gotoAndStop("dead");
    } else {
    speed *= .93;
    if (speed>0) {
    dir = "right";
    } else if (speed<0) {
    dir = "left";
    }
    if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
    _root.john._x += speed;
    _root.sun._x += speed;
    _root.score._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
    _root.john._x += speed;
    _root.sun._x += speed;
    _root.score._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    if (Key.isDown(Key.LEFT)) {
    if (speed>-maxmove) {
    speed--;
    }
    this.gotoAndStop("left");
    } else if (Key.isDown(Key.RIGHT)) {
    if (speed<maxmove) {
    speed++;
    }
    dir = "right";
    this._xscale = 100;
    this.gotoAndStop("run");
    } else if (Key.isDown(Key.DOWN)) {
    this.gotoAndStop("idle");
    } else if (Key.isDown(Key.CONTROL)) {
    this.gotoAndStop("attack");
    attacking = true;
    speed = 0;
    } else if (speed<1 && speed>-1 && !attacking) {
    speed = 0;
    this.gotoAndStop("idle");
    }
    if (speed<1 && speed>-1 && !attacking) {
    speed = 0;
    this.gotoAndStop("idle");
    if (speed<1 && speed>-1 && !attacking) {
    speed = 0;
    this.gotoAndStop("idle");
    }
    if (Key.isDown(Key.UP) && !jumping) {
    jumping = true;
    }
    if (jumping) {
    this.gotoAndStop("jump");
    this._y -= jump;
    jump -= .5;
    if (jump<0) {
    falling = true;
    }
    if (jump<-15) {
    jump = -15;
    if (jump<-15) {
    jump = -15;
    }
    }
    if (_root.ground.hitTest(this._x, this._y, true) && falling) {
    jump = 12;
    jumping = false;
    falling = false;
    }
    }
    if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
    _root.score._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
    _root.score._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    }
    }
    }
    onClipEvent (keyUp) {
    // on Key Up
    if (Key.getCode() == Key.CONTROL) {
    // if the release is control
    attacking = false;
    // attacking is false
    }
    }



    and here is my enemy's coding


    onClipEvent (load) {
    enemyspeed = 2;
    //this sets the speed your enemy will move at
    enemystepsright = 0;
    //how far it has moved right
    enemystepsleft = 0;
    //how far it has moved left
    enemydir = "left";
    //its direction is set left
    }
    onClipEvent (enterFrame) {
    if (!dead) {
    //if NOT dead
    if (enemydir == "right") {
    //if the direction (enemydir) is right
    enemystepsright += 1;
    //its amount of steps (enemystepsright) right goes up 1
    this._xscale = -100;
    //_xscale (flips character) is set to neg. 100
    this._x += enemyspeed;
    //its X goes up the value of enemyspeed
    } else if (enemydir == "left") {
    //otherwise if the direction (enemydir) is left
    enemystepsleft += 1;
    //its amount of steps (enemystepsright) left goes up 1
    this._xscale = 100;
    //_xscale (flips character) is set to 100
    this._x -= enemyspeed;
    //its X goes down the value of enemyspeed
    }
    if (enemystepsright == 100) {
    //if enemystepsright is equal to 100
    enemystepsright = 0;
    //enemystepsright is set to 0
    enemydir = "left";
    //direction is set to left
    } else if (enemystepsleft == 100) {
    //otherwise if enemystepsleft is equal to 100
    enemystepsleft = 0;
    //enemystepsleft is set to 0
    enemydir = "right";
    //direction is set to right
    }
    }
    }
    onClipEvent (enterFrame) {
    if (_root.char.hitTest(this)) {
    _root.hp--;
    }
    }
    onClipEvent (enterFrame) {
    distance = 5;
    ux = _root.char._x;
    uy = _root.char._y;
    hx = this._x;
    hy = this._y;
    if (Math.sqrt((ux-hx)*(ux-hx)+(uy-hy)*(uy-hx))) {
    }
    }
    onClipEvent (enterFrame) {
    if (_root.char.hitTest(this)) {
    _root.batman
    += 10;
    unloadMovie(this);
    }
    }

  7. #7
    u should use frame coding instead of coding on movieclips

    its so much faster and easier

    i never use movieclip coding

    the only codes on my moviclips are things like stop(); and

    parent attack=false

    thats so i can make it go to certain animations or make it stop attacking

    but that is done by the code on the frame

    message me if u dont get what im sayin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012