Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mobile.evanmclay.mobile_assessment.model;
- import android.content.Context;
- import android.content.res.Resources;
- import android.graphics.drawable.Drawable;
- public class Sprite {
- private float x, y, width, height, angle;
- private Context context;
- public Drawable drawable;
- private Resources res;
- public Sprite (float _x, float _y, float _width, float _height, float _angle, Context _context) {
- x = _x;
- y = _y;
- width = _width;
- height = _height;
- angle = _angle;
- context = _context;
- res = context.getResources();
- }
- public void setX(float _x) {
- x = _x;
- }
- public void setY(float _y) {
- y = _y;
- }
- public void setAngle(float _angle) {
- angle = _angle;
- }
- public float getAngle() {
- return angle;
- }
- public float getX() {
- return x;
- }
- public float getY() {
- return y;
- }
- public float getWidth() {
- return width;
- }
- public float getHeight() {
- return height;
- }
- public Context getContext() {
- return context;
- }
- public void setDrawable(Drawable _sprite) {
- drawable = _sprite;
- }
- public Drawable getDrawable() {
- return drawable;
- }
- public Resources getRes() {
- return res;
- }
- public void setBounds() {
- drawable.setBounds((int)x, (int)y, (int)(x + width), (int)(y + height));
- }
- public void moveSprite(int _xVel, int _yVel) {
- x = x + (float) _xVel;
- y = y + (float) _yVel;
- drawable.setBounds((int)x, (int)y, (int)(x + width), (int)(y + height));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement