• Advertisement
Sign in to follow this  

rotating sprites and entities using XNA

This topic is 1281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, so I started making this 2D top-down game using C# and XNA (because I am really familiar with C# and not famliar with game development). I am using the Entity / Component / System pattern and everything has been great so far. But now things are getting a little tricky so I was hoping people here could give me some tips and pointers.

 

As mentioned, my system is based on Entities that work as holders for a set of Components, some very simple ones like Spatial (takes a Vector2 as a position), Collider (sets a hitbox relative to the spatial component). Others are a bit more advanced like a door. The door can disable the Collider when the door is open, and rotate the sprite over time to make it seem like the door is opening.

 

I am having issues because I wanted to rotate the door to an angle (0, 90, 180, 270) to be able to have doors on all sides of houses, but this is a problem because of the origin being set to (0,0). All my sprites are using 0,0 as origin and I am thinking if this was a dumb choice. Maybe I should always set Origin to the center of the object.

 

So there is my question, when people build games like my 2D top-down game, do they set Origin to the center of the sprite and rotate, or should I create 4 unique doors, each one facing a certain direction?

 

I have added screenshots of my doors open and closed if that is better.

 

Share this post


Link to post
Share on other sites
Advertisement

I don't know how you implement your entity-component system, but XNA's SpriteBatch.Draw() method has an overloaded version that allows you to specify the origin and rotation of that sprite.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement