A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: swapDepths not working

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    4

    swapDepths not working

    Hi,
    I'm using this tutorial http://www.stormation.info/rpg-game-...torial-part-1/ to make a simple rpg game and the depth part is not working as shown.
    (my character appears to be walking behind/under the other Movie Clips, even if those are on the same layer)
    I can't figure out what's the problem because I'm just starting to work on flash..
    so I would really appreciate some help.

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Wow, i tried to help you. I did all the steps, made a simple character movieclip and the grass is a green rectangle, and i didn't achieve to set the Depths to it. Weird.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    sorry wrong post
    Last edited by fruitbeard; 10-07-2012 at 02:54 AM.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    PHP Code:
    MovieClip.prototype.depthControl = function ()
    {
        
    this.swapDepths(this._y);
    }; 

  5. #5
    Junior Member
    Join Date
    Oct 2012
    Posts
    4
    Thanks a lot! Now everything is working fine

    but I have another little question...
    What can I do with the clips that should be on the foreground?
    because now my player can walk over everything I put on the stage, even on upper layers
    and I would like some stuff to overlap it.

    (sorry for so many newbie questions...)

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Yes, put the grass inside a movie clip of its own and change the code on the grass clip inside the new clip to this.

    PHP Code:
    onClipEvent (enterFrame) {
        if (
    this.hitTest(_root.Character))
        {
            
    _parent.depthControl();
        }

    also call your little figure "Character", or change Character in the code above to what you have called your figure

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