Advertisement
Trident_Tail

Untitled

Nov 23rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. package mobile.evanmclay.mobile_assessment.model;
  2.  
  3. import android.content.Context;
  4. import android.content.res.Resources;
  5. import android.graphics.drawable.Drawable;
  6.  
  7. public class Sprite {
  8.  
  9. private float x, y, width, height, angle;
  10. private Context context;
  11. public Drawable drawable;
  12. private Resources res;
  13. public Sprite (float _x, float _y, float _width, float _height, float _angle, Context _context) {
  14. x = _x;
  15. y = _y;
  16. width = _width;
  17. height = _height;
  18. angle = _angle;
  19. context = _context;
  20. res = context.getResources();
  21. }
  22.  
  23. public void setX(float _x) {
  24. x = _x;
  25. }
  26.  
  27. public void setY(float _y) {
  28. y = _y;
  29. }
  30.  
  31. public void setAngle(float _angle) {
  32. angle = _angle;
  33. }
  34.  
  35. public float getAngle() {
  36. return angle;
  37. }
  38.  
  39. public float getX() {
  40. return x;
  41. }
  42.  
  43. public float getY() {
  44. return y;
  45. }
  46.  
  47. public float getWidth() {
  48. return width;
  49. }
  50.  
  51. public float getHeight() {
  52. return height;
  53. }
  54.  
  55. public Context getContext() {
  56. return context;
  57. }
  58.  
  59. public void setDrawable(Drawable _sprite) {
  60. drawable = _sprite;
  61.  
  62. }
  63.  
  64. public Drawable getDrawable() {
  65. return drawable;
  66. }
  67.  
  68. public Resources getRes() {
  69. return res;
  70. }
  71.  
  72. public void setBounds() {
  73. drawable.setBounds((int)x, (int)y, (int)(x + width), (int)(y + height));
  74. }
  75.  
  76. public void moveSprite(int _xVel, int _yVel) {
  77. x = x + (float) _xVel;
  78. y = y + (float) _yVel;
  79. drawable.setBounds((int)x, (int)y, (int)(x + width), (int)(y + height));
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement