-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathCameraFactory.java
More file actions
55 lines (43 loc) · 1.89 KB
/
CameraFactory.java
File metadata and controls
55 lines (43 loc) · 1.89 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
package org.anddev.andengine.engine.camera;
import android.content.Context;
import android.util.DisplayMetrics;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 13:50:42 - 03.07.2010
*/
public class CameraFactory {
// ===========================================================
// Constants
// ===========================================================
private CameraFactory() {}
// ===========================================================
// Fields
// ===========================================================
// ===========================================================
// Constructors
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
public static Camera createPixelPerfectCamera(final Context pContext, final float pCenterX, final float pCenterY) {
final DisplayMetrics displayMetrics = CameraFactory.getDisplayMetrics(pContext);
final float width = displayMetrics.widthPixels;
final float height = displayMetrics.heightPixels;
return new Camera(pCenterX - width * 0.5f, pCenterY - height * 0.5f, width, height);
}
private static DisplayMetrics getDisplayMetrics(final Context pContext) {
return pContext.getResources().getDisplayMetrics();
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}