Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 2 of 2
  1. #1

    Default Y coordinate problems

    Well since I'm an AS noobie I guess I'd post here.

    I was using a guide to make a simple platform game and I came across an annoying problem.


    // jumping down
    function jump_down(valueY) {
    if (!this.stage.limit.hitTest(this.character._x, this.character._y, true)) {
    this.character._y += valueY;

    } else {
    // if you fall too deep in a limit, then you are placed correctly
    for (i=1; i<=5; i++) {
    if (!this.stage.limit.hitTest(this.character._x, this.character._y-i, true)) {
    this.character._y -= i-3;
    break;
    }
    }
    this.character.gotoAndStop("stand");
    }
    }


    Stage is the actual stage.
    Limit are the borders that cannot be crossed.

    Anyways, this results in a problem; when the character jumps, it always goes to the normal y (a normal jump landing), then subtracts 8 y the jump afterwards (making the character go inside the limits, 8y below), then the third jump it goes back to y, then subtracts 8, and etc.

    I am pretty sure the problem eminates from this part of the AS, but if more information is needed do say so, i'm pretty bad at explaining as well.

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    Assuming that the limit values range from 1 to 5, instead of subtracting i from the _y value, it would seem that you need to subtract i from the total limits value or...... 5-i.... in the for loop....

    if (!this.stage.limit.hitTest(this.character._x, this.character._y-(5-i), true)) {

    This may be incorrect as I've only glanced at the code and not tested it but worth a quick test to see if it might be the issue. I didn't follow the explanation of the jumping problem. Maybe post a demo file to show the problem.
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. LoadVars Problems
    By dkeegh in forum Flash Scripting
    Replies: 1
    Last Post: 03-28-2006, 09:06 PM
  2. Preloader Problems. Help!!!
    By cknick in forum Flash Scripting
    Replies: 1
    Last Post: 11-08-2005, 03:03 PM
  3. URL Problems
    By liqidhed in forum General Flash
    Replies: 1
    Last Post: 06-24-2005, 02:15 AM
  4. x coordinate of an element in a shape tween
    By tron in forum General Flash
    Replies: 1
    Last Post: 03-11-2004, 08:56 PM
  5. Tracking X coordinate
    By Ninchilla in forum Flash Scripting
    Replies: 1
    Last Post: 03-03-2004, 09:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial