Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ** sprite class i'm using for project **
- class Sprite
- {
- public Texture2D image; // image representing sprite
- public Vector2 position; // position for sprite
- public Rectangle Rect // physical representation of sprite
- {
- get
- {
- return new Rectangle((int)this.position.X, (int)this.position.Y, this.image.Width, this.image.Height); // getter returns rectangle based on images size and xy position
- }
- }
- public Sprite(Texture2D image, Vector2 position)
- {
- this.image = image;
- this.position = position;
- }
- public void Draw(SpriteBatch spriteBatch) // call this to draw the sprite to the screen, takes a spritebatch as an argument
- {
- spriteBatch.Draw(this.image, Rect, Color.White)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement