A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Need help with defeating enemies in Platform game!

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    3

    Need help with defeating enemies in Platform game!

    Hi! I'm fairly new at Flash and I haven't much skills with creating a game. But I've managed to make a small demo of a game I'm trying to make. However there are a couple of problems with my coding that I just can't figure out.

    • When my character MC is falling you can make him jump from thin air.
    • Enemies don't die. I would like the enemies to get crushed under the Character's feet, just like in Mario games. But otherwise killing the Character if touched at any other point but the head.
    • I'm using scenes as Level points but the hittest I've assigned for the character hitting the invisible object in-between the flags at the end of the level isn't making the scene switch.

    Sorry for all of the problems but I need a lot of help! Can anyone here assist me?

    Here's the link to the game since I can't upload it here.

    http://www.fileden.com/files/2007/1/...at2%282%29.swf

    http://www.fileden.com/files/2007/1/...at2%282%29.fla

  2. #2
    Game Player - Developer scheletro's Avatar
    Join Date
    Mar 2005
    Location
    México living in Barcelona
    Posts
    1,121
    WOW thats a huge file, why?

    Too much work on the game to have problems at tis time, you should add some pieces of code here for us to see, discuss and solve problems, nobody will download your game to correct it for you

    Maybe we can start with the jumping problem when the character falls


    "I love to make them as I love to play them"

  3. #3
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    the final SWF file is pretty big (3.5 MB!). Have a look in the library and from it´s select "unused times" and delete them.
    Also try to resize all bitmaps (pixel images) in Photoshop or any other real bitmap editor (resizing in flash wont do) to their minimum size and reimport them or update them.

    I agree some code snippetts are more inviting to help at first- if nothing helps there is always the option to download the FLA.

    My guess is that you´ll end up with some hitTest method to check the collision with enemies. You could even check on sub- movieClips like head parts on that particular movieClip.

  4. #4
    Junior Member
    Join Date
    Mar 2008
    Posts
    3
    Thanks for some ideas guys, I'll get back here with some coding snippets... I've got no code for the enemies so far. Only coding I have is the Character Code.

  5. #5
    Junior Member
    Join Date
    Mar 2008
    Posts
    3
    Here is the entire code for the Char.

    onClipEvent (load) {
    jumping = true;
    speed = 0;
    maxmove = 15;
    }
    onClipEvent (enterFrame) {
    jump = 0;
    if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
    this._y += 6;
    }
    if (_root.dead) {
    this.gotoAndStop("dead");
    } else {
    speed *= .85;
    if (speed>0) {
    dir = "right";
    } else if (speed<0) {
    dir = "left";
    }
    if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
    _root.score._x += speed;
    _root.score2._x += speed;
    _root.stage._x += speed;
    _root.stage2._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
    _root.score._x += speed;
    _root.score2._x += speed;
    _root.stage._x += speed;
    _root.stage2._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    if (Key.isDown(Key.LEFT)) {
    if (speed>-maxmove) {
    speed--;
    }
    this.gotoAndPlay("run");
    this._xscale = -85;
    } else if (Key.isDown(Key.RIGHT)) {
    if (speed<maxmove) {
    speed++;
    }
    this._xscale = 85;
    this.gotoAndPlay("run");
    } else if (speed<1 && speed>-1) {
    speed = 0;
    this.gotoAndStop("idle");
    }
    if (Key.isDown(Key.SPACE) && !jumping) {
    jumping = true;
    }
    if (jumping) {
    this.gotoAndStop("jump");
    this._y -= jump;
    jump -= .5;
    if (jump<0) {
    falling = true;
    }
    if (jump<-15) {
    jump = -15;
    }
    }
    if (_root.ground.hitTest(this._x, this._y, true) && falling) {
    jump = 12;
    jumping = false;
    falling = false;
    }
    }
    }
    onClipEvent (enterFrame) {
    i = 0;
    j = 20;
    // lets say if your ground instances only go up to ground5
    for (i=0; i<j; i++) {
    // executes this statement over and over until i < j is false by increasing i by one
    if (_root["ground"+i].hitTest(this._x, this._y, true) && falling) {
    // ground+i is now grounds 1-5
    jump = 12;
    jumping = false;
    falling = false;
    }
    }
    }

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