A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: falling/jumping script in side-scroller

  1. #1

    falling/jumping script in side-scroller

    I'm working on a side-scorlling game at the moment and im trying to make it so that if youre neither jumping nor touching the floor, but in the air, you fall to the floor. In the start script, i have 4 flags (jumping, falling, goingup, and goingdown) set to false. then when you enter the first level, the i have the following script:
    if (element ("Apocolypse").collideRect element ("Floor"))=false{
    falling=true
    }
    if (falling=true){
    element ("Apocolypse").velocity.y=-100
    }
    i know that once i get to trying to add jumping to the mix, im gunna have to add:
    && jumping=false
    to the "if", but for now, all i wanna know is why this one wont work. The error message i get is:
    expresion could not be evaluated on line 4 (its actually line 4 cuz i got comments and crap above it): if (element("Apocolypse").collideRect element ("Floor")
    1 error found.
    so tell me, what is this error?? much thanx in advance.
    www.freewebs.com/protocomics
    the beginning of a very great comic. Will i ever continue? doubtful.

    Feel the Blight.

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    to test for equal you have to use 2 ='s

    if (element ("Apocolypse").collideRect element ("Floor"))==false{
    falling=true
    }
    if (falling==true){
    element ("Apocolypse").velocity.y=-100
    }

  3. #3
    thanx for the tip, that'll save me future trouble, but i put it in there and it came up with the same message...ugh.
    www.freewebs.com/protocomics
    the beginning of a very great comic. Will i ever continue? doubtful.

    Feel the Blight.

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Oh I see it:
    if (element ("Apocolypse").collideRect (element ("Floor")))==false{
    falling=true
    }


    all those () are confusing.
    did you try getting a handle on the elements first?

    i.e. In your start script do:

    Floor=element("floor")
    Apocolypse=element ("Apocolypse")


    then in your scripts you can just use
    if (Apocolypse.collideRect(Floor)==false){
    falling=true
    }
    NOTE THIS IS UNTESTED
    You can simplify this further like so

    falling=!Apocolypse.collideRect(Floor)

  5. #5
    thanx, now i get no error message. But still when the game opens up and you go to the first level, Apocolypse, a stick figure at the moment, just floats in the air... I'm going to attach the file here, so if you would be so kind as to dl it and fix it up or examine the script and tell me whats wrong with it, id be much appreciative. sorry for all the trouble, i just cant figure it out...
    EDIT: ok i think i fixed it, beause by the time i get to the stage, he's gone. (im assuming he fell thru the floor) now i need some way to make it so that when he gets to the floor, he'll stop moving down. here's what i tried:
    if (Apocolypse.hitcheck(Floor)==true){
    falling=false
    Apocolypse.velocity.y=0
    }
    i get a message saying:
    hitcheck() is not a method of paint Apocoylpse. what do i do? thanx in advance.
    Attached Files Attached Files
    Last edited by NireksAdvocate; 07-30-2003 at 05:12 PM.
    www.freewebs.com/protocomics
    the beginning of a very great comic. Will i ever continue? doubtful.

    Feel the Blight.

  6. #6

    jump time

    Ok, in the meantime, i began to work on the script for jumping. it starts out with
    if (falling==false){
    jumping==true
    }
    if (jumping==true){
    Apocolypse.velocity.y=-100
    after this, i want it to wait for 1.5 seconds and then set the velocity back to 100 'til it hits the floor. i know how to reset the velocity, but how do i make it wait a certain amount of time before doing it? thanx in advance. signing off--
    www.freewebs.com/protocomics
    the beginning of a very great comic. Will i ever continue? doubtful.

    Feel the Blight.

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