About Store Forum Documentation Contact
Donations:
178$/mo



Post Reply 
[SOLVED] How do I temporary remove object
Author Message
rstralberg Offline
Member

Post: #1
[SOLVED] How do I temporary remove object
I have the need for removing an object from the world, but not for good.
I will keep it in memory. Just want it invisible (and not colliding either).

Just temporary as I need to restore it later. Couldn't find anything on that in the docs.

Any hints on that?
(This post was last modified: 07-08-2015 09:43 AM by rstralberg.)
07-06-2015 11:23 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: How do I temporary remove object
can't really think of anything not involving separate extra container workarounds or adding extra variables- functions for the object that would disable the physics object and disabling the drawing in drawPrepare etc.
07-07-2015 03:34 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: How do I temporary remove object
Hi,

You'd need to make a custom parameter something like "bool removed" and then handle the logic based on that.
07-07-2015 03:42 AM
Find all posts by this user Quote this message in a reply
3DRaddict Offline
Member

Post: #4
RE: How do I temporary remove object
07-07-2015 06:56 AM
Visit this user's website Find all posts by this user Quote this message in a reply
rstralberg Offline
Member

Post: #5
RE: How do I temporary remove object
Okay. Thanks guys.

You lead me in the right direction.
Here is what works for me.

Code:
class myItem : Game.Item
{

    // ... code not relevant here
    // ...
    // ...

private:
   //
   // --- pretend we are not existing
   //
   Bool     _removed = false;

   void remove()
   {
      _removed = true;
      actor.active(false);
   }
  
   void restore()
   {
      _removed = false;
      actor.active(true);
   }
  
   Bool is_removed() C
   {
      return _removed;
   }
  
public:
   UInt drawPrepare()
   {
      if( _removed )
      {
         // make us invisble
         uint draw_mask=0xFFFFFFFF;
         FlagDisable(draw_mask, IndexToFlag(Body)); // clear head draw group flag
      
         SetDrawMask(draw_mask);
         super.drawPrepare(); // call default drawing after setting the mask
         SetDrawMask(); // reset default mask
      }
      else
      {
         super.drawPrepare();
      }
   }

   void drawShadow()
   {
      if( _removed )
      {
         // prevent shadows
      }
      else
      {
         super.drawShadow();
      }
   }
}
(This post was last modified: 07-07-2015 12:38 PM by rstralberg.)
07-07-2015 12:04 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply