Beispiel #1
0
        public void Draw(SpriteBatch spriteBatch, PrimitiveBatch primitiveBatch, string text, Point at, float scale, Color color)
        {
            int dx = (int)(this.dx * scale);
            int x  = at.X;
            int y  = at.Y;

            foreach (char c in text.ToArray())
            {
                if (c == ' ')
                {
                    x += dx;
                    continue;
                }
                int index = c - 32;
                if (index < 0)
                {
                    continue;
                }
                if (index > 256)
                {
                    continue;
                }
                spriteBatch.DrawSprite(letters[index], x, y, scale, color);

                x += dx;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create a new static object
        /// </summary>
        /// <param name="creation">Delegate creation function</param>
        /// <returns></returns>
        public static StaticObject Create(DrawEvt creation)
        {
            StaticObject   obj     = new StaticObject();
            BufferBuilder  builder = new BufferBuilder();
            RenderTarget   target  = new RenderTarget(builder);
            SpriteBatch    sBatch  = new SpriteBatch(target);
            PrimitiveBatch pBatch  = new PrimitiveBatch(target);

            creation(sBatch, pBatch);
            target.Flush();
            obj.arrays = builder.Arrays;
            return(obj);
        }