• AS2 spawning a movieclip on a lower depth
    13 replies, posted
I've had this problem for a while, everytime I try to spawn a piss puddle on the floor from the player, it spawns above everything, and the player can walk under it, which isn't cool. [code] puddle = _root.attachMovie("piss", p+pisspuddles++, 0); p += 1; puddle._y = _root.player._y; puddle._x = _root.player._x; pisspuddles = 0; [/code] this will solve a lot of my problems so any help is awesome.
[QUOTE=Parakon;22271498]I've had this problem for a while, everytime I try to spawn a piss puddle on the floor from the player, it spawns above everything, and the player can walk under it, which isn't cool. [code] puddle = _root.attachMovie("piss", p+pisspuddles++, 0); p += 1; puddle._y = _root.player._y; puddle._x = _root.player._x; pisspuddles = 0; [/code] this will solve a lot of my problems so any help is awesome.[/QUOTE] Odd...You can, when it's created, do swapDepth on the piss puddle and the player.
I tried that with "puddle.onEnterFrame = swapDepth(_root.player);" but no dice
Try tracing the puddle's depth, then the player's depth. That kind of thing has helped me a LOT. [editline]03:32AM[/editline] Actually, I don't think you can even access the depth property, can you?
[QUOTE=geel9;22271657]Try tracing the puddle's depth, then the player's depth. That kind of thing has helped me a LOT. [editline]03:32AM[/editline] Actually, I don't think you can even access the depth property, can you?[/QUOTE] mc.getDepth(); mc.swapDepths( mc_2 ); mc.swapDepths( depth value ); [I](Basically a 'setDepth')[/I]
[QUOTE=1/4 Life;22271673]mc.getDepth();[/QUOTE] Oh damn, that would have helped so many times during development of MY game.
You might want to play with mc.getNextHighestDepth(); For instance: piss_mc.swapDepths( mc_under_player.getNextHighestDepth() );
[QUOTE=1/4 Life;22271772]You might want to play with mc.getNextHighestDepth();[/QUOTE] He wants a low depth, not the highest. [editline]03:42AM[/editline] DAmn ninjas.
[code] puddle = _root.attachMovie("piss", p+pisspuddles++, holder.getNextHighestDepth()); puddle.onEnterFrame = swappy; p += 1; puddle._y = _root.player._y; puddle._x = _root.player._x; pisspuddles = 0; } function swappy():Void { _root.player.getDepth(); _root.player.swapDepth(this) _root.player.swapDepth(0);}[/code] Here's how I've got it now, same result though, i must be doing it wrong
[QUOTE=Parakon;22271832][code] puddle = _root.attachMovie("piss", p+pisspuddles++, holder.getNextHighestDepth()); puddle.onEnterFrame = swappy; p += 1; puddle._y = _root.player._y; puddle._x = _root.player._x; pisspuddles = 0; } function swappy():Void { _root.player.getDepth(); _root.player.swapDepth(this) _root.player.swapDepth(0);}[/code]Here's how I've got it now, same result though, i must be doing it wrong[/QUOTE] Should be swapDepths, not swapDepth. Everything else looks good.
I was wondering why it wasn't blue.. Anyways, it works great! except now the player goes ontop of everything else, which sucks, any ideas?
[QUOTE=Parakon;22271977]I was wondering why it wasn't blue.. Anyways, it works great! except now the player goes ontop of everything else, which sucks, any ideas?[/QUOTE] You can try something like this. pisspuddle.swapDepths( player.getNextHighestDepth() ) player.swapDepths( pisspuddle ); That should get them directly on top of each other depth wise, and correctly place the player above the puddle.
I just put an MC on a frame just above the floor, but below the player, and swapped that with the piss instead, it works, if I run into any problems i'll post here, otherwise you guys have been a gigantic help, in this game and in future ones [img]http://i46.tinypic.com/107ufzo.png[/img] the fruit of your helpfulness.
[QUOTE=Parakon;22272101]I just put an MC on a frame just above the floor, but below the player, and swapped that with the piss instead, it works, if I run into any problems i'll post here, otherwise you guys have been a gigantic help, in this game and in future ones the fruit of your helpfulness.[/QUOTE] Looks great! Glad to help!
Sorry, you need to Log In to post a reply to this thread.