예제 #1
0
        public ISpriteInstance AddSprite(Sprite sprite)
        {
            Contract.Requires(sprite != null && sprite.SpriteSheet == SpriteSheet);

            var instance = new SpriteInstance(this, sprite);

            instance.Size = new Vector2(sprite.Size.X, sprite.Size.Y);
            instance.Color = new Color4ub(255, 255, 255, 255);
            instance.RotateFromOrigin = false;

            lock (m_instances)
            {
                m_instances.Add(instance);
            }

            return instance;
        }
예제 #2
0
 public SnowTexture()
 {
     m_backgroundTexture = Texture2D.Load(typeof(Floor).Assembly.GetManifestResourceStream("Zombie.Game.Textures.snow.jpg"));
     m_backgroundSheet = new SpriteSheet(m_backgroundTexture);
     m_backgroundSprite = m_backgroundSheet.AddSprite("", new Box2i(Vector2i.Zero, m_backgroundTexture.Size));
 }
예제 #3
0
 public SpriteInstance(SpriteRenderer renderer, Sprite sprite)
 {
     m_renderer = renderer;
     m_sprite = sprite;
 }
예제 #4
0
        public Sprite AddSprite(string name, Box2i coordinates)
        {
            var tw = (float)Texture.Size.X;
            var th = (float)Texture.Size.Y;

            var sprite = new Sprite(
                this,
                name,
                coordinates.Size,
                new Box2(
                    coordinates.Position.X / tw,
                    coordinates.Position.Y / th,
                    coordinates.Size.X / tw,
                    coordinates.Size.Y / th
            ));

            m_sprites.Add(sprite.Name, sprite);
            return sprite;
        }