Example #1
0
        private static void checkForDepthProblems(Renderable r1, Renderable r2)
        {
            if (r1 != r2)
            {
                if (r1 is Sprite && r2 is Sprite)
                {
                    if (r1.Layer == r2.Layer)
                    {
                        Sprite s1 = ((Sprite)r1);
                        Sprite s2 = ((Sprite)r2);

                        bool found = false;
                        foreach (SpriteWarnPair sp in swp)
                        {
                            if ((sp.s1 == s1 && sp.s2 == s2) ||
                                (sp.s2 == s1 && sp.s1 == s2))
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            if (Intersects(new Rectangle(s1.X, s1.Y, s1.Width, s1.Height),
                                           new Rectangle(s2.X, s2.Y, s2.Width, s2.Height)))
                            {
                                Log.w("Sprites w/tex: " + s1.GetTexture().Filename + ", "
                                      + s2.GetTexture().Filename);
                                Log.e("Two sprites with depth '" + r1.Layer.ToString() + "' overlap.");
                                Log.e("The sort results are UNDEFINED, and will probably fluctuate!");
                                Log.i("You will not be warned about this sprite overlap pair again.");

                                SpriteWarnPair sw = new SpriteWarnPair();
                                sw.s1 = s1;
                                sw.s2 = s2;
                                swp.Add(sw);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private static void checkForDepthProblems(Renderable r1, Renderable r2)
        {
            if (r1 != r2)
                if (r1 is Sprite && r2 is Sprite)
                    if (r1.Layer == r2.Layer)
                    {
                        Sprite s1 = ((Sprite)r1);
                        Sprite s2 = ((Sprite)r2);

                        bool found = false;
                        foreach (SpriteWarnPair sp in swp)
                            if ((sp.s1 == s1 && sp.s2 == s2)
                                || (sp.s2 == s1 && sp.s1 == s2))
                            {
                                found = true;
                            }

                        if (!found)
                        {
                            if (Intersects(new Rectangle(s1.X, s1.Y, s1.Width, s1.Height),
                                new Rectangle(s2.X, s2.Y, s2.Width, s2.Height)))
                            {
                                Log.w("Sprites w/tex: " + s1.GetTexture().Filename + ", "
                                    + s2.GetTexture().Filename);
                                Log.e("Two sprites with depth '" + r1.Layer.ToString() + "' overlap.");
                                Log.e("The sort results are UNDEFINED, and will probably fluctuate!");
                                Log.i("You will not be warned about this sprite overlap pair again.");

                                SpriteWarnPair sw = new SpriteWarnPair();
                                sw.s1 = s1;
                                sw.s2 = s2;
                                swp.Add(sw);
                            }
                        }
                    }
        }