A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: [HELP] Swap depths [Non Tile Game]

  1. #1
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121

    [HELP] Swap depths [Non Tile Game]

    I have a non tile rpg, and how do I make it so when I walk past a tree i become under it.

    This is what I did. (Note: the origonal depth of the player is 200 and the tree is 199)

    code:
    onClipEvent (enterFrame) {
    if (_parent._parent.player._y<=this._y) {
    if (undertree<>true) {
    undertree = true;
    _parent._parent.tree01.swapDepths(_parent._parent. player);
    }
    }
    if (_parent._parent.player._y>=this._y+0.0001) {
    if (undertree == true) {
    undertree = false;
    _parent._parent.tree01.swapDepths(_parent._parent. player);
    }
    }
    }



    It works, exaclty how I want it to (Fyi, that code is on a movieclip that is inside the tree movieclip), but if I add more movie clips that overlap then im sure it will mess up. Say there is a bird in the tree and it is always sapoosed to be above, well if the player passes the tree it will be under.
    Altho that statment may not be ture, it will be true in other cases.

    Any ideas?
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  2. #2
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    Here is a sample swf.

    Also, the whole idea is for the player to always be overtop of the black line and the black line to always be over top of the tree.
    Attached Files Attached Files
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  3. #3
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    You've been programming in Director too long... :P

    code:

    if (undertree<>true) {



    should be

    code:

    if (undertree!=true) {



    I'm not sure if it will help your problem but it is a start.

  4. #4
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    Yea, lol.

    I don't think this will have any type of impact at all,
    But any bright ideas?
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  5. #5
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    if (undertree!=true) {

    Could be shortened to:

    if (!undertree) {

    http://www.birchlabs.co.uk/
    You know you want to.

  6. #6
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Visit this thread i think it might help. There is a fla file a little bit down the page you can check out that will be helpful

    http://www.flashkit.com/board/showth...ghlight=Depths
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  7. #7
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    hmm, it might work. But wont bmp make my game larger?
    Also i haven't worked with bmp and as2 together -.- and I have
    no clue about the first thing of his code, and all of his examples are gone.
    There has to be an esier way...

    Maybe if I were to set all the depths when you go under a tree, etc...
    Altho that would result in a much larger code.
    Last edited by --eXe-eXtreme--; 04-09-2006 at 11:00 AM.
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  8. #8
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Well yeah that could work and it could help in map building too. If you stored all the trees positions in an array. You would have to access there positions on a constant basis to check wether you are behind or in front. When you store the depths i suggest you have a decent space of 5 between depths so you dont need to actually swap the depths of the trees, just place the character in the depth space between trees. It actually shouldnt be that hard at all to do.

    Let me know what you come up with.
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  9. #9
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    That might work but I will have to be very carfull with the order of the trees (Not like it will just be trees tho), But I will see if I cant get a demo done this week.
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  10. #10
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    all objects should be given a depth which is based on their _y, _x, _width and _height. Static objects only need this value set once.

    get rid of all your if statements

    something like this:

    code:

    this.swapDepths(this._y*this._width);



    its not pretty but it works, there's many ways to do it, look for marmottes art based collision detection source, i think thats got depth zorting
    lather yourself up with soap - soap arcade

  11. #11
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    Well I just tried this way, and what happend was:

    Whe you start out you wan walk under the tree but you never become over the tree.
    So, I would have to manualy put that in. Is this way only usefull for objects the user never walks over or under?
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  12. #12
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    Perhaps you could link me? =D
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  13. #13
    Mя.Åŋdëŗ§&#511 --eXe-eXtreme--'s Avatar
    Join Date
    Feb 2005
    Location
    Windsor On.
    Posts
    121
    Bump?
    Link? = D
    I Use Flash 8
    Help is my last name, Freeload is my first :P
    إŦ№إ Mя. Åŋdëŗ§ǿņ

  14. #14
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    how have your objects been placed relative to their origin. My code works when the clip is placed in the center-bottom origin, not center-center origin.

    Check the sticky for marmottes code
    lather yourself up with soap - soap arcade

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