Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load<SpriteFont>(@"Fonts/Arial");
            text = new Text(spriteBatch, font);

            LoadTextures(legsTexture, @"gfx/legs");
            LoadTextures(headTexture, @"gfx/head");
            LoadTextures(torsoTexture, @"gfx/torso");
            LoadTextures(weaponTexture, @"gfx/weapon");

            saveIcon = Content.Load<Texture2D>(@"gfx/save_icon");
            openFolderIcon = Content.Load<Texture2D>(@"gfx/folder_open_icon");
            upArrowTexture = Content.Load<Texture2D>(@"gfx/upArrow");
            downArrowTexture = Content.Load<Texture2D>(@"gfx/downArrow");
            nullTexture = Content.Load<Texture2D>(@"gfx/1x1");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Content = new ContentManager(Services, "WindowsContent");

            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load<SpriteFont>(@"Fonts/Arial");
            text = new Text(spriteBatch, font);

            stopWatch = Stopwatch.StartNew();

            // I did test different values but / 120 equals to about 64 FPS on my laptop - tested with fraps
            TargetElapsedTime = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 120);
            MaxElapsedTime = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 10);

            timer = new Timer();
            timer.Interval = (int)TargetElapsedTime.TotalMilliseconds;
            timer.Tick += Tick;
            timer.Start();

            LoadTextures(legsTexture, @"gfx/legs");
            LoadTextures(headTexture, @"gfx/head");
            LoadTextures(torsoTexture, @"gfx/torso");
            LoadTextures(weaponTexture, @"gfx/weapon");

            LoadBitmaps(headBitmap, "head");
            LoadBitmaps(torsoBitmap, "torso");
            LoadBitmaps(legsBitmap, "legs");
            LoadBitmaps(weaponsBitmap, "weapon");

            nullTexture = Content.Load<Texture2D>(@"gfx/1x1");

            characterDefinition = new CharacterDefinition();

            // not needed anymore since we have a new timer
            // Hook the idle event to constantly redraw our animation.
            //Application.Idle += delegate { Invalidate(); };
        }