Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - namuol

Pages: [1]
1
Feature requests / Manually setting Z-order
« on: September 21, 2010, 05:56:16 pm »
Quote from: "Xorlium"
But then if you modify the z-value of a sprite, don't you invalidate the multi-set?


The best solution would be to use accessor/mutator functions which automatically sort the list if the z value has changed.

Here's a Z-sorted sprite example (psuedo-C++):

Code: [Select]

class ZSprite : public sf::Sprite
{
  private:
    double z;
    std::list<ZSprite*>* list;
   
  public:
    ZSprite([[Sprite args...]],
                double z=0.0,
                std::list<ZSprite*>* list)
    {
        this->z = z;
        this->list = list;
    }

    double GetZ() { return z; }

    void SetZ(double value)
    {
        if( z != value )
        {
            z = value;
            [[sort your list here...]]
        }
    }
};

Pages: [1]