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.