Пример #1
0
 public static GlobalHelper getInstance()
 {
     if (instance_ == null)
     {
         instance_ = new GlobalHelper();
     }
     return instance_;
 }
Пример #2
0
        /// <summary>
        /// Create a GameTexture from the specified name, with the specified SpriteBatch and
        /// GraphicsDevice, without requiring TextureMap.
        /// </summary>
        /// <param name="filepath">Path to the image file</param>
        /// <param name="spriteBatch">SpriteBatch for the game</param>
        /// <param name="graphics">GraphicsDevice for the game</param>
        /// <param name="content">ContentManager containing the image</param>
        public GameTexture(string filename, SpriteBatch spriteBatch, GraphicsDevice graphics, ContentManager content)
        {
            spriteBatch_ = spriteBatch;

            texture_ = content.Load<Texture2D>(filename);

            imageDimensions_ = new Rectangle[1];
            imageDimensions_[0] = new Rectangle(0, 0, texture_.Width, texture_.Height);
            helper_ = GlobalHelper.getInstance();
        }
Пример #3
0
 /// <summary>
 /// Default constructor for a GameTexture
 /// </summary>
 public GameTexture()
 {
     helper_ = GlobalHelper.getInstance();
 }
Пример #4
0
        /// <summary>
        /// Create a GameTexture from the specified name, with the specified SpriteBatch and
        /// GraphicsDevice.
        /// </summary>
        /// <param name="filepath">Name of the image file</param>
        /// <param name="spriteBatch">SpriteBatch for the game</param>
        /// <param name="graphics">GraphicsDevice for the game</param>
        public GameTexture(string filename, SpriteBatch spriteBatch, GraphicsDevice graphics)
        {
            //TODO: add functionality to read from a file to get imageDims

            spriteBatch_ = spriteBatch;

            texture_ = TextureMap.getInstance().getContent().Load<Texture2D>(filename);

            imageDimensions_ = new Rectangle[1];
            imageDimensions_[0] = new Rectangle(0, 0, texture_.Width, texture_.Height);
            helper_ = GlobalHelper.getInstance();
        }
Пример #5
0
        /// <summary>
        /// Create a copy of the GameTexture gTexture.
        /// </summary>
        /// <param name="gTexture">The GameTexture to be copied</param>
        public GameTexture(GameTexture gTexture)
        {
            spriteBatch_ = gTexture.spriteBatch_;

            texture_ = gTexture.texture_;

            Array.Copy(gTexture.imageDimensions_, imageDimensions_, gTexture.imageDimensions_.GetLength(0));
            helper_ = GlobalHelper.getInstance();
        }