dcsimg
A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [F8] Making items i've picked up go away?

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Posts
    26

    [F8] Making items i've picked up go away?

    Let's say for a minute I've got a character who walks into an item that increases his score for aslong as he's standing on it by 100 or so, how would I make it, dissapear after a time limit, once collected,?, I'm aware you can just put a "Stop" on a blank frame to give it that effect but the score will keep going up once he's stood in that blank space due to the hitest, maybe it's a stupid question but I'd like some advice.

    (my character walks into an item, which degenerates, pixel by pixel and awards him points while doing so via a simple hitest, how do I make this item dissapear / remove itself from the scene after it's degenerated?)
    Last edited by yeahright; 04-20-2007 at 06:00 PM.

  2. #2
    Senior Member
    Join Date
    Oct 2006
    Posts
    221
    um, wouldn't it be something like"
    if(timer==0){
    unloadMovie(powerup_mc)
    }

  3. #3
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    if you used attachMovie or duplicateMovieClip to put the mc up there, then you can use removeMovieClip(<insert mc's name>)

  4. #4
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by squidgie90
    um, wouldn't it be something like"
    if(timer==0){
    unloadMovie(powerup_mc)
    }

    I tried using,

    if (_root.player.hitTest(_root.powerup._x, _root.powerup._y, true)) {
    gotoAndStop("animation");
    _root.score += 1;
    unloadMovie(_root.powerup)

    this got rid of the powerup, but it still increased the score when I stood in the powerup's previous position, am I missing some sort of variable/else if command I should be using, i'm nowhere close to an AS expert.

    I'd like an item, that animates, adds a certain amount to the score, and respawns, maybe randomly? (prehaps to a set position) once my player walks over and / collects it.

    </noob>
    Last edited by yeahright; 04-20-2007 at 06:37 PM.

  5. #5
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    There's no need to reply to this anymore, I fixed my own problem, apparently, to remove movieclips placed at authoring time, you are required to swap it's depth before removal, the correct syntax for removing a movieclip after it's been "used" so to speak is the following.

    onClipEvent(enterFrame){ // when clip is loaded //
    if (_root.PLAYER.hitTest(_root.ITEM._x, _root.ITEM._y, true)) { // if player hits item //
    _root.score += 100; // add one hundred to the score //
    _root.burger.swapDepths(1); // swap it's depth to any # //
    _root.burger.removeMovieClip(); // remove it from the scene //

    there's also a nice explanation on depths here

  6. #6
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    You hadn't mentioned anything about depth, and I've completely forgot it to be a common mistake. You can't delete a clip with a negative depth. For future reference, whenever you duplicate something, just always use the .getNextHighestDepth() of the parent clip, like _root, or _parent; It saves headaches trying to plan depths. Then you only have to use the movieClip.removeMovieClip() method and voila; it's gone.
    Last edited by ImprisonedPride; 04-21-2007 at 06:10 AM.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  7. #7
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by ImprisonedPride
    You hadn't mentioned anything about depth, and I've completely forgot it to be a common mistake. You can't delete a clip with a negative depth. For future reference, whenever you duplicate something, just always use the .getNextHighestDepth() of the parent clip, like _root, or _parent; It saves headaches trying to plan depths. Then you only have to use the movieClip.removeMovieClip() method and voila; it's gone.

  8. #8
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    Hm, now that I've got it to dissapear, how do I go about bringing it back?, prehaps in a different position, set by coordinates? or a certain time limit, myMovieClip .attachMovie?

  9. #9
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    Just attachMovie/duplicateMovieClip with a new _x/_y but use the same name?
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  10. #10
    Say hello to Bob Kakihara's Avatar
    Join Date
    Jul 2004
    Location
    kent, England
    Posts
    1,067
    dont remove it in the first place. just move it off stage instead then reposition it in the new position.

    so instead of removeMovieClip() just put mc._x=1000;
    then just alter the x and y when you want to place it back on stage.
    If our body is a clock ticking away and if while we experience all that this world has to offer time has still continued to pass, are we living or just experiencing a slow death?

  11. #11
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by Kakihara
    dont remove it in the first place. just move it off stage instead then reposition it in the new position.

    so instead of removeMovieClip() just put mc._x=1000;
    then just alter the x and y when you want to place it back on stage.
    That's another good idea, it'll save me creating 1000's of instance names too, I think i'll go for this method until I really need to create more of items.

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