Neoforce + game, drawing

Oct 3, 2015 at 1:12 PM
Hi, how to make neoforce to work with mygame?
I added manager, initialized it, i also added update function and window controll but when im trying to draw it, purple background from neoforce covers all my game drawings.

This is my Draw() function:
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.LightGray);

            spriteBatch.Begin();
            /*switch (GAME_STATE)
            {
                case 0:

                    break;

                case 1:
                    _Practice.Draw();
                    break;
            }*/

            _Practice.Draw();
            spriteBatch.End();


            manager.BeginDraw(gameTime);
            //manager.GraphicsDevice.Clear(Color.Transparent);
            //manager.Draw(gameTime);
            manager.EndDraw();

            base.Draw(gameTime);
        }
Developer
Oct 4, 2015 at 5:42 AM
Hi RichieDev,

Here is an example
protected override void Draw(GameTime gameTime)
{
    manager.BeginDraw(gameTime);
    GraphicsDevice.Clear(Color.Black); // Any color will do

    //Draw your game here

    manager.EndDraw();
    base.Draw(gameTime);
}
Oct 4, 2015 at 11:19 AM
Edited Oct 4, 2015 at 11:19 AM
Thanks for your answer.
So i wrote simple code just to check if it will work and it wont work :/
            manager.BeginDraw(gameTime);
            GraphicsDevice.Clear(Color.LightGray); // Any color will do

            //Draw your game here
            spriteBatch.Draw(texture, new Rectangle(300, 50, 32, 32), Color.White);
            manager.EndDraw();
My game is compilling but after start im getting this error:
Begin must be called successfully before a Draw can be called.
Should i use spriteBatch that is in manager? Or does manager have its own drawing function?

So i put this in my main class just before methods:
Manager manager;
Then in constructor of my main class i put:
manager = new Manager(this, graphics, "Default");
Then in Initialize() method:
manager.Initialize();
And in my Update(GameTime gameTime) method:
manager.Update(gameTime);
And my Draw(GameTime gameTime) method:
        protected override void Draw(GameTime gameTime)
        {
            manager.BeginDraw(gameTime);
            GraphicsDevice.Clear(Color.LightGray); // Any color will do

            //Draw your game here
            spriteBatch.Draw(texture, new Rectangle(300, 50, 32, 32), Color.White);
            manager.EndDraw();

            base.Draw(gameTime);
        }
What im doing wrong? :/
Developer
Oct 5, 2015 at 2:56 AM
You need to being the spritebatch before drawing, and end after.

Example
protected override void Draw(GameTime gameTime)
{
    manager.BeginDraw(gameTime);
    GraphicsDevice.Clear(Color.LightGray); // Any color will do

    //Draw your game here
    spriteBatch.Begin(); // Begin drawing
    spriteBatch.Draw(texture, new Rectangle(300, 50, 32, 32), Color.White);
    spriteBatch.End(); //End Drawing

    manager.EndDraw();

    base.Draw(gameTime);
}
Oct 5, 2015 at 8:02 AM
Thanks alot! Before, I tried putting manager.BeginDraw after spriteBatch.Begin and it didnt worked, so i never tried the opossite way because i thought it wont work anyway, but it works :) Thanks again :) Problem solved.