A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] F8[AS2]Finding coordinates in TBW problem

Threaded View

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    resolved [RESOLVED] F8[AS2]Finding coordinates in TBW problem

    Hi. This is a snippet of code from a way to find object's edges in order to check to see what cell he's in. I have been reading TonyPa's tutorials but I don't get what goes on. Don't know a thing about prototypes which is the way he declares his tiles beeing walkable or not. I am sure there has to be a way to achieve the same purpose the way I expose but I have been thinking about it over and over to the point I've become stuck. This code works fine with my character's movement but only checks for two sides which I can't manage to figure out. I'd like to flip this movement to solve my problem, but like I mentioned, I'm stuck... soemone, please open the attached file to see what I'm trying to say. Thanks in advance...


    function moveCar(dir) {
    if (dir == "up") {
    var tempx:Number = ob.x+ob.radius;
    var tempy:Number = ob.y-ob.radius;
    var cellx:Number = Math.floor(tempx/game.spacing);
    var celly:Number = Math.floor(tempy/game.spacing);
    var tempCell = game["cell"+cellx+"_"+celly];
    if (tempCell.type != 1) {
    return;
    } else {
    ob.x += speedx;
    ob.clip._x = ob.x;
    ob.y -= speedy;
    ob.clip._y = ob.y;
    }
    } if(dir == "down") {
    var tempx:Number = ob.x-ob.radius;
    var tempy:Number = ob.y+ob.radius;
    var cellx:Number = Math.floor(tempx/game.spacing);
    var celly:Number = Math.floor(tempy/game.spacing);
    var tempCell = game["cell"+cellx+"_"+celly];
    if (tempCell.type != 1) {
    return;
    } else {
    ob.y -= speedy;
    ob.clip._y = ob.y;
    ob.x += speedx;
    ob.clip._x = ob.x;
    }
    }
    }
    Attaching Fla example.
    Last edited by capdetrons; 01-09-2012 at 11:43 AM. Reason: wrong post

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