dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: ufo problems

  1. #1
    booooosted! DJ-Anakin's Avatar
    Join Date
    Oct 2000
    Location
    ridgecrest, ca [pm me if in cali desert]
    Posts
    149

    ufo problems

    ok..

    been a while since i posted..

    im tryin to make a .. i guess its a game.. theres a map that i want to scroll up and down only (no horizontal) when the character (a ufo) reaches a point.. so..

    if your steering around.. and reach this line (mine is on 70) then the map will scroll up instead of the ufo moving up, but you can still go right or left.. same if you go down, reach the line (mine is at 330) the screen/map will scroll down instead of the ufo..

    ive been messin with it for a while, and cant quite get it..

    any help is appriciated.

    also the one thing i know im not gonna be able to figure out is getting it (the map or ufo, depending) to move with inertia.. so when you let go of the arrow key, it slows to a stop, instead of an immediate stop. anyone know where i can find something like this?

    thanks

    -frank
    Last edited by DJ-Anakin; 02-13-2003 at 03:04 PM.

  2. #2
    booooosted! DJ-Anakin's Avatar
    Join Date
    Oct 2000
    Location
    ridgecrest, ca [pm me if in cali desert]
    Posts
    149
    ok.. check this. see how
    when you go all the way up, or down, then try goin the opposite direction, it wont let go.. anyone got any better ideas? heres the code:

    On 'ship':

    onClipEvent (enterFrame) {
    if (_y >= 70 and _y <330) {
    if (Key.isDown(Key.LEFT)) {
    this._x -= 5;
    } else if (Key.isDown(Key.RIGHT)) {
    this._x += 5;
    }
    if (Key.isDown(Key.UP)) {
    this._y -= 5;
    } else if (Key.isDown(Key.DOWN)) {
    this._Y += 5;
    }
    } else {
    if (Key.isDown(Key.LEFT)) {
    this._x -= 5;
    } else if (Key.isDown(Key.RIGHT)) {
    this._x += 5;
    }
    if (Key.isDown(Key.DOWN)) {
    _root.ground._y -= 5;;
    } else if (Key.isDown(Key.UP)) {
    _root.ground._y += 5;
    }
    }
    }

    and the map bg is 'ground'.
    this is the 3rd way ive tried gettin it, and it seems to be workin the best.. except for that little hicup.. and the deceleration/inertia thing.. thanks

    -frank

  3. #3
    booooosted! DJ-Anakin's Avatar
    Join Date
    Oct 2000
    Location
    ridgecrest, ca [pm me if in cali desert]
    Posts
    149
    to the top..

    no help? i really need this. i just want the ufo to go in any direction, and have inertia.. i just want it to slow to a stop.. or if someone could point me to an example..

    thanks

    -frank

  4. #4
    Junior Member
    Join Date
    Jan 2003
    Posts
    27

    aight..

    try something like this. i dont know if it works in real life, but it works in my head..

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT)) {
    speedx = 15;
    flagx=1;
    } else if (Key.isDown(Key.RIGHT)) {
    speedx = 15;
    flagx=2;
    }
    if (Key.isDown(Key.UP)) {
    speedy = 15;
    flagy = 1;
    } else if (Key.isDown(Key.DOWN)) {
    speedy = 15;
    flagy = 2;
    }
    if (flagx=1){this._x -= speedx;}
    if (flagx=2){this._x += speedx;}
    if (flagy=1){this._y -= speedy;}
    if (flagy=2){this._y += speedy;}
    if (speedx<>0){speedx-=1;}
    if (speedx<>0){speedy-=1;}
    }

  5. #5
    booooosted! DJ-Anakin's Avatar
    Join Date
    Oct 2000
    Location
    ridgecrest, ca [pm me if in cali desert]
    Posts
    149
    well its closer.. when i put this code on the ship, then the ship just sits there, if i change on of the '+' to a '-' (or the other way around) then when you load the movie, this ship moves, quickly by itself till you hit a key, then no matter which direction you hit (left or right) it will only go in one direction. like if i hit the right or left keys it will only go right.. so.. got any ideas why? i cant see it, but im workin on it.. thanks!!

    -frank

  6. #6
    Junior Member
    Join Date
    Jan 2003
    Posts
    27

    whoop

    hmm.. maybe the problem with my code is:
    if (speedx<>0){speedx-=1;}
    if (speedx<>0){speedy-=1;}

    try changing it to:
    if (speedx>=0){speedx-=1;}
    if (speedy>=0){speedy-=1;}

    try that out..

  7. #7
    booooosted! DJ-Anakin's Avatar
    Join Date
    Oct 2000
    Location
    ridgecrest, ca [pm me if in cali desert]
    Posts
    149
    ok well.. hmmm.. i tried changin some numbers, and no closer.. here is the swf with the new changes. you wanna see the fla? this is killin me. if i change the first speedx (for Key.LEFT) to something like speedx1, then change the

    if (flagx=1){this._x -= speedx;}
    to
    if (flagx=1){this._x -= speedx1;}
    then it does something wierd.. when you open the file, the ufo is sliding to the right.. you can hit right, and it goes right, but when you let go, its still sliding left. hit left and it goes left, let go, its stil sliding left. then you hit the right arrow again, and it just sits there.. check it out.. lemme know..

    i really appriciate this help. its way closer than i could get. i think were ont he right track..

    -frank

  8. #8
    booooosted! DJ-Anakin's Avatar
    Join Date
    Oct 2000
    Location
    ridgecrest, ca [pm me if in cali desert]
    Posts
    149
    OK, WELL I MEssed around with it some last night, ended up gettin some old code from a different project i was workin on and changed it..adapted it and it works great, i even added a _x/yscale code. now i gotta figure out how to get it to stop growing/shrinking once it gets a certain size. i also wanna figure out how to make it so the ship doesnt go off the screen, but i can hitTest for that.

    got any ideas on how to make it stop _xscale/_yscale +/- once it gets to a certain size?

    -frank

  9. #9
    Junior Member
    Join Date
    Jan 2003
    Posts
    27

    aight!

    glad to hear it! good luck..

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