예제 #1
0
        /// <summary>
        /// Private constructor used when calling the Clone() method on a Sprite.
        /// </summary>
        private Sprite(Sprite sprite)
        {
            id       = Guid.NewGuid().ToString();
            animator = new Animator(this);
            movement = new Movement(this);
            Sprites._spriteList.Add(this);

            parentGrid          = sprite.parentGrid;
            frame               = sprite.frame;
            DetectCollision     = sprite.collisionDetection;
            horizAlign          = sprite.horizAlign;
            vertAlign           = sprite.vertAlign;
            nudgeX              = sprite.nudgeX;
            nudgeY              = sprite.nudgeY;
            renderSize          = sprite.renderSize;
            ZOrder              = sprite.zOrder;
            visible             = sprite.visible;
            gridCoordinates     = sprite.gridCoordinates;
            AdjustCollisionArea = sprite.AdjustCollisionArea;

            if (parentGrid != null)
            {
                parentGrid.RefreshQueue.AddPixelRangeToRefreshQueue(this.DrawLocation, true);
            }

            Sprites.SubscribeToSpriteEvents(this);

            CreateChildSprites();
        }
예제 #2
0
        private void OnDeserialized(StreamingContext context)
        {
            animator       = new Animator(this);
            movement       = new Movement(this);
            pauseAnimation = false;
            pauseMovement  = false;

            if (parentGrid != null)
            {
                parentGrid.RefreshQueue.AddPixelRangeToRefreshQueue(this.DrawLocation, true);
            }

            Sprites._spriteList.Add(this);
            Sprites.SubscribeToSpriteEvents(this);

            CreateChildSprites();
        }