Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input.Touch;
- using Microsoft.Xna.Framework.Media;
- namespace SaccoGame
- {
- public class Jogador
- {
- static Texture2D characterSheetTexture;
- Texture2D _quadradoChutar;
- bool _IsTouched;
- Rectangle _posicao;
- GraphicsDevice _graphicsDevice;
- public Jogador(GraphicsDevice graphicsDevice, Rectangle posicaoJogador)
- {
- _graphicsDevice = graphicsDevice;
- _posicao = posicaoJogador;
- if (characterSheetTexture == null)
- {
- using (var stream = TitleContainer.OpenStream("Content/Jogador_Azul.png"))
- characterSheetTexture = Texture2D.FromStream(graphicsDevice, stream);
- }
- }
- public void Update(GameTime gameTime)
- {
- _IsTouched = CheckRectangleTouch(_posicao);
- }
- bool CheckRectangleTouch(Rectangle target)
- {
- TouchCollection touchCollection = TouchPanel.GetState();
- if (touchCollection.Count > 0)
- foreach (var touch in touchCollection)
- if (target.Contains(touch.Position))
- return true;
- return false;
- }
- public void Draw(SpriteBatch spriteBatch)
- {
- if (_IsTouched)
- {
- spriteBatch.Draw(characterSheetTexture, new Vector2(_posicao.X,_posicao.Y), null,
- Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
- if (_quadradoChutar!=null)
- {
- spriteBatch.Draw(_quadradoChutar, new Vector2(_posicao.X-100, _posicao.Y+100), null,
- Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
- }
- }
- else
- spriteBatch.Draw(characterSheetTexture, new Rectangle(_posicao.X, _posicao.Y,_posicao.Width, _posicao.Height), Color.White);
- }
- public void SetQuadradoChutar(Texture2D quadrado)
- {
- _quadradoChutar = quadrado;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement