Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4059538
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:13:19+00:00 2026-05-20T15:13:19+00:00

Hey guys, i’m trying to use the following drawing logic: Class Game { Character

  • 0

Hey guys, i’m trying to use the following drawing logic:

Class Game
{
    Character x;

    public Draw(...)
    {
        spriteBatch.Begin(transformation1);
        x.Draw();
        spriteBatch.End();

        spriteBatch.Begin(transformation2);
        otherThing.Draw();
        spriteBatch.End();
    }
}

Class Character
{
    Animation[] animations;
    int currentAnimation;

    public Draw(...)
    {
        this.animations[this.currentAnimation].Draw();
    }
}

Class Animation
{
    Frame[] frames;
    int currentFrame;

    public Draw(...)
    {
        this.frames[this.currentFrame].Draw();
    }
}
Class Frame
{
    Texture2D texture;
    Texture2D shadow;

    public Draw(...)
    {
        spriteBatch.Begin(sub_transformation1);
        spriteBatch.Draw(texture1, ...);
        spriteBatch.End();

        spriteBatch.Begin(sub_transformation2);
        spriteBatch.Draw(shadow, ...);
        spriteBatch.End();
    }
}

If i try this logic i get a “Begin cannot be called again until End has been successfully called.” error. So i’m asking if this logic is possible / makes sense? I’m using Begin() within Begin() to make additive transformations. If i have a character on x = 100 and y = 100 and i want the texture and shadow of the frame and everything else i want (bounding boxes, etc), to be drawn using that 100,100 translation, plus the -Xscale or +Xscale to flip horizontally the character (i know i could use the SpriteEffects.FlipHorizontally in the .Draw, but i wanted something that applied automatically to the bottom levels (animation and frame)), and finally in the Frame level the texture has a transformation on top of the one from the character and the shadow has another one. Don’t know if i explained myself well, but ask if you have any doubts.

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:13:19+00:00Added an answer on May 20, 2026 at 3:13 pm

    I kind of understand where you’re coming from, but it just isn’t possible. SpriteBatch can’t be hierarchical like you’re wanting. Your objects, however, can.

    Edited slightly to address your question below:

    Class Frame
    {
        // World - parent transformation to build from, passed 
        // from animation, from character, on up the chain...
        // localTransform - local coordinates
        // shadowTransform - maybe not needed?
        public Draw(Matrix world, Matrix localTransform, Matrix shadowTransform)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(
                texture1, 
                ..., 
                Matrix.Transform(world * localTransform),
                ...);
    
            spriteBatch.Draw(
                shadowTexture, 
                ..., 
                Matrix.Transform(world * localTransform * shadowTransform), 
                ...);
    
            spriteBatch.End();
        }
    }
    

    You don’t have to pass down all the character or object information into the frame – just need a transform to be set by the frame parent. Your original code was already receiving a transform (sub_transformation1 and 2) from somewhere – here we just pass that value into the Draw function. You could make the localTransform a class variable too, set it on instantiation.

    The Animation class would have a similar Draw(Matrix world…) signature. I think it achieves what you’re looking for and kind of similar to how OpenGL handles things – just more manual (from the little I remember of it from years ago).

    Side note, there is gamedev.stackexchange.com for game related questions too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
Hey guys i want to use the jquery Autocomplete plugin and instead of separating
Hey guys I'm trying to add the string 'url( ) ' around my a
Hey guys, I'm trying to get my head around LINQ and FP, so forgive
Hey guys I'm following the rails tutorial found here http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ and I've gotten to
Hey guys I am making a 2D game and I have generating a random
Hey guys I can't seem to get the syntax here right, I'm just trying
Hey guys I'm getting three things right now that I'm trying to take care
Hey guys im trying to connect to an database and collect some data out
Hey guys can someone explain the big o notation for each of the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.