Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. //Scene creation (load content on game class)
  2. /// <summary>
  3. /// LoadContent will be called once per game and is the place to load
  4. /// all of your content.
  5. /// </summary>
  6. protected override void LoadContent()
  7. {
  8. // Create a new SpriteBatch, which can be used to draw textures.
  9. spriteBatch = new SpriteBatch(GraphicsDevice);
  10.  
  11. _scenes.Add(
  12. new Scene()
  13. {
  14. Objects = new List<GameObject>()
  15. {
  16. (GameObject)new Button(Content.Load<Texture2D>("GUI/buttonDesaturated"),Content.Load<Texture2D>("GUI/buttonDesaturatedDown"),Content.Load<Texture2D>("GUI/buttonDesaturatedHover"))
  17. {
  18. ButtonColor = Color.Red,
  19. text = "Test",
  20. font = Content.Load<SpriteFont>("GUI/Font"),
  21. TextColor = Color.Black,
  22. Position = new Vector2(70,100)
  23. }
  24. }
  25. });
  26.  
  27. _curSceneIndex = 0;
  28.  
  29. }
  30.  
  31. //button class draw event (draws sprite in base, then draws text on top)
  32.  
  33. public override void Draw(SpriteBatch spriteBatch, GameTime delta)
  34. {
  35. base.Draw(spriteBatch, delta);
  36. spriteBatch.DrawString(font, text, Position, _curTextColor);
  37. }
  38.  
  39.  
  40. //sprite class draw event
  41. /// <summary>
  42. /// Draw event for this sprite.
  43. /// </summary>
  44. /// <param name="spriteBatch"></param>
  45. /// <param name="delta"></param>
  46. public override void Draw(SpriteBatch spriteBatch, GameTime delta)
  47. {
  48. if (DrawSprite)
  49. spriteBatch.Draw(Texture, (Rectangle)GetRectangle(), null, Color, Rotation, Origin, Flip, LayerDepth);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement