execute() public méthode

public execute ( ) : System.Boolean
Résultat System.Boolean
Exemple #1
0
        public Boolean execute()
        {
            Boolean overlapProcessed = false;
            FlxList iterator;

            if (_headA.Object != null)
            {
                iterator = _headA;
                while (iterator != null)
                {
                    _object = iterator.Object;
                    if (_useBothLists)
                    {
                        _iterator = _headB;
                    }
                    else
                    {
                        _iterator = iterator.next;
                    }
                    if (_object.Exists && (_object.AllowCollisions > 0) &&
                        (_iterator != null) && (_iterator.Object != null) &&
                        _iterator.Object.Exists && overlapNode())
                    {
                        overlapProcessed = true;
                    }
                    iterator = iterator.next;
                }
            }

            //Advance through the tree by calling overlap on each child
            if ((_northWestTree != null) && _northWestTree.execute())
            {
                overlapProcessed = true;
            }
            if ((_northEastTree != null) && _northEastTree.execute())
            {
                overlapProcessed = true;
            }
            if ((_southEastTree != null) && _southEastTree.execute())
            {
                overlapProcessed = true;
            }
            if ((_southWestTree != null) && _southWestTree.execute())
            {
                overlapProcessed = true;
            }

            return(overlapProcessed);
        }
Exemple #2
0
        /// <summary>
        /// Returns true if the two FlxObjects overlap.  Optional Callback function of return type bool with two FlxObject parameters will be called if true.
        /// </summary>
        /// <param name="ObjectOrGroup1"></param>
        /// <param name="ObjectOrGroup2"></param>
        /// <param name="NotifyCallback"></param>
        /// <param name="ProcessCallback"></param>
        /// <returns></returns>
        static public Boolean overlap(FlxObject ObjectOrGroup1 = null, FlxObject ObjectOrGroup2 = null, Func <FlxObject, FlxObject, Boolean> NotifyCallback = null, Func <FlxObject, FlxObject, Boolean> ProcessCallback = null)
        {
            if (ObjectOrGroup1 == null)
            {
                ObjectOrGroup1 = FlxG.state;
            }
            if (ObjectOrGroup2 == ObjectOrGroup1)
            {
                ObjectOrGroup2 = null;
            }
            FlxQuadTree.divisions = FlxG.worldDivisions;
            FlxQuadTree quadTree = new FlxQuadTree(FlxG.worldBounds.x, FlxG.worldBounds.y, FlxG.worldBounds.width, FlxG.worldBounds.height);

            quadTree.load(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback);
            Boolean result = quadTree.execute();

            quadTree.destroy();
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Call this function to see if one <code>FlxObject</code> overlaps another.
        /// Can be called with one object and one group, or two groups, or two objects,
        /// whatever floats your boat! For maximum performance try bundling a lot of objects
        /// together using a <code>FlxGroup</code> (or even bundling groups together!).
        /// 
        /// <p>NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.</p>
        /// </summary>
        /// <param name="ObjectOrGroup1">The first object or group you want to check.</param>
        /// <param name="ObjectOrGroup2">The second object or group you want to check. If it is the same as the first, flixel knows to just do a comparison within that group.</param>
        /// <param name="NotifyCallback">A function with two <code>FlxObject</code> parameters - e.g. <code>myOverlapFunction(Object1:FlxObject,Object2:FlxObject)</code> - that is called if those two objects overlap.</param>
        /// <param name="ProcessCallback">A function with two <code>FlxObject</code> parameters - e.g. <code>myOverlapFunction(Object1:FlxObject,Object2:FlxObject)</code> - that is called if those two objects overlap. If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects!</param>
        /// <returns></returns>
        public static Boolean overlap(FlxObject ObjectOrGroup1 = null, FlxObject ObjectOrGroup2 = null, Func<FlxObject, FlxObject, Boolean> NotifyCallback = null, Func<FlxObject, FlxObject, Boolean> ProcessCallback = null)
        {
            if (ObjectOrGroup1 == null)
            {
                ObjectOrGroup1 = FlxG.State;
            }

            if (ObjectOrGroup2 == ObjectOrGroup1)
            {
                ObjectOrGroup2 = null;
            }

            FlxQuadTree.divisions = FlxG.worldDivisions;
            FlxQuadTree quadTree = new FlxQuadTree(FlxG.worldBounds.X, FlxG.worldBounds.Y, FlxG.worldBounds.Width, FlxG.worldBounds.Height);
            quadTree.load(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback);
            Boolean result = quadTree.execute();
            quadTree.destroy();
            return result;
        }