-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameActivity.java
50 lines (42 loc) · 1.32 KB
/
GameActivity.java
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
package com.lud.root.jetfighter;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Point;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Display;
public class GameActivity extends AppCompatActivity{
private GameView gameView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get the display object
Display display = getWindowManager().getDefaultDisplay();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//Get the screen Resolution
Point size = new Point();
display.getSize(size);
//initialize the gameview object
gameView = new GameView(this, size.x,size.y);
setContentView(gameView);
}
@Override
protected void onPause() {
super.onPause();
gameView.pause();
gameView.pauseMusic();
}
@Override
protected void onResume() {
super.onResume();
System.gc();
gameView.resume();
gameView.resumeMusic();
}
@Override
public void onBackPressed() {
startActivity(new Intent(this, MyActivity.class));
}
}