-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneManager.java
More file actions
53 lines (45 loc) · 1.48 KB
/
SceneManager.java
File metadata and controls
53 lines (45 loc) · 1.48 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
package com.example.jason.a4x4;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.view.MotionEvent;
import java.util.ArrayList;
/**
* Created by JASON on 9/4/2018.
*/
public class SceneManager {
private ArrayList<Scene> scenes = new ArrayList<>();
public static int ACTIVE_SCENE;
public static int WIDTH;
public static int HEIGHT;
private boolean scoreSceneFlag;
public SceneManager(Context context){
ACTIVE_SCENE = 0;
WIDTH = Resources.getSystem().getDisplayMetrics().widthPixels;
HEIGHT = Resources.getSystem().getDisplayMetrics().heightPixels;
scoreSceneFlag = true;
scenes.add(new MainMenuScene(context));
scenes.add(new GameplayScene(context));
scenes.add(new ScoreScene(context));
}
public void receiveTouch(MotionEvent event){
scenes.get(ACTIVE_SCENE).receiveTouch(event);
}
public void update() {
//slow down update rate of ScoreScene
//only updates when scene 2 is opened
if(ACTIVE_SCENE == 2){
if(scoreSceneFlag){
scenes.get(ACTIVE_SCENE).update();
scoreSceneFlag = false;
}
}
else {
scoreSceneFlag = true;
scenes.get(ACTIVE_SCENE).update();
}
}
public void draw(Canvas canvas){
scenes.get(ACTIVE_SCENE).draw(canvas);
}
}