예제 #1
0
        public StarField()
        {
            m_layers = new ArrayList();

            Random rnd = new Random();
            for (int nLayer = -1; nLayer < 2; nLayer++)
            {

                //before, I started with nLayer = -2 to get a layer in front of the "play area", but it was a bit confusing.

                //create layer, name it, set how fast it should scroll
                //(actually, for -1, we could use the default layer, but this looks more clean.)
                ParallaxLayer layer = new ParallaxLayer();
                m_layers.Add(layer);

                layer.Name = "Scroll"+nLayer.ToString();
                float fScrollFact = (float)Math.Pow(0.5, nLayer+1);
                layer.ScrollFactor = new EPointF(fScrollFact,fScrollFact);
                layer.Parent = EndogineHub.Instance.Stage.Camera;
                layer.LocZ = -nLayer-1;

                //create some sprites in each parallax layer
                for (int nSprite = 0; nSprite < 10; nSprite++)
                {
                    WrappingSprite star = new WrappingSprite();
                    star.Loc = new EPointF(rnd.Next(640)-320, rnd.Next(480)-240);
                    star.WrapRect = new ERectangleF(new EPointF(0,0), EndogineHub.Instance.Stage.Size.ToEPointF());
                    star.Parent = layer;
                    star.Ink = RasterOps.ROPs.AddPin;
                    star.MemberName = "Star";
                }
            }
        }
예제 #2
0
 public override Sprite Copy()
 {
     ParallaxLayer sp = new ParallaxLayer();
     this.CopyTo(sp);
     return sp;
 }
예제 #3
0
        protected void CreateRootSprite(ERectangle a_rct)
        {
            _spRoot = new Sprite();
            _spRoot.SourceRect = a_rct;
            _spRoot.Name = "root";

            _cam = new Camera();
            _cam.Name = "Camera";
            _cam.Parent = _spRoot;

            ParallaxLayer layer = new ParallaxLayer();
            layer.Name = "DefaultLayer";
            layer.Parent = (Sprite)_cam;

            this._defaultParent = layer;
        }