Jump to content

  • Log In with Google      Sign In   
  • Create Account

rotating sprites and entities using XNA


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Thanamos   Members   -  Reputation: 151

Like
0Likes
Like

Posted 18 July 2014 - 03:27 PM

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.

 

Attached Thumbnails

  • doors_closed.png
  • doors_open.png


Sponsor:

#2 Truerror   Members   -  Reputation: 454

Like
0Likes
Like

Posted 19 July 2014 - 01:21 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS