-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
58 lines (47 loc) · 1.37 KB
/
Square.java
File metadata and controls
58 lines (47 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.example.jason.a4x4;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import static com.example.jason.a4x4.SceneManager.HEIGHT;
import static com.example.jason.a4x4.SceneManager.WIDTH;
/**
* Created by JASON on 9/7/2018.
*/
public class Square implements GameObject {
private Drawable picture;
private Rect rectangle;
private int number;
Square(int number, Rect rectangle, Drawable picture){
this.number = number;
this.rectangle = rectangle;
this.picture = picture;
this.picture.setBounds(rectangle);
}
@Override
public void draw(Canvas canvas){
picture.draw(canvas);
}
@Override
public void update(){
picture.invalidateSelf();
}
public void update(int number, Drawable picture){};
public Drawable getPic(){
return picture;
}
public int getNum(){
return number;
}
public void change(int number, Drawable picture){
this.number = number;
this.picture = picture;
picture.setBounds(rectangle);
}
public void move(Rect rectangle){
this.rectangle = rectangle;
picture.setBounds(rectangle);
}
}